I have a collection of objects grouped together in Object3D and I'm attempting to detect when they are clicked on.
My scene has dimensions of 600x400
, my camera is part of a three-object, and the code for handling events looks like this:
function onDocumentMouseDown( event ) {
event.preventDefault();
var mouse = {};
mouse.x = ( event.clientX / 600 ) * 2 - 1;
mouse.y = - ( event.clientY / 400 ) * 2 + 1;
var vector = new THREE.Vector3( mouse.x, mouse.y, 1 );
projector.unprojectVector( vector, three.camera );
var ray = new THREE.Ray( three.camera.position, vector.subSelf( three.camera.position ).normalize() );
var intersects = ray.intersectObjects( group.children );
alert(intersects.length);
[...]
}
Currently, I am displaying the number of intersected objects. However, it always remains at zero. It seems unable to find any intersected objects. I've experimented with adjusting the x, y, and z values of my projection vector but haven't had any success.
I have provided a simplified example illustrating this issue on jsfiddle. Perhaps someone can offer a quick insight into what might be causing this problem?