I am used the THREE.js CSS Render and have created a 3D cube out of 6 CSS3DObjects. I have been following this (code) example to add raytracing so that I can figure out on which side of the code the mouse is on.
function onDocumentMouseMove( event ) {
event.preventDefault();
let mouse3D = new THREE.Vector2(
( event.clientX / window.innerWidth ) * 2 - 1,
-( event.clientY / window.innerHeight ) * 2 + 1);
let raycaster = new THREE.Raycaster();
raycaster.setFromCamera( mouse3D, camera );
let intersects = raycaster.intersectObjects( scene.children, true );
if ( intersects.length > 0 ) {
console.log(intersects);
}
}
However, even if the mouse is over the cube, the intersects object stay empty
UPDATE
So I tried to add a Mesh to the scene. Although the renderer will not render it, the raytracer appears to be picking it up. Does this mean that the CSS objects do not have a size?
var geometry = new THREE.BoxGeometry( 500, 500, 10 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
var cubeeee = new THREE.Mesh( geometry, material );
scene.add( cubeeee )