It appears that there is an issue with the function "raycaster.intersectObjects" in the context of Three.js r54. The relevant code snippet is as follows:
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 75;
scene = new THREE.Scene();
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
var raycaster = new THREE.Raycaster();
var mouseVector = new THREE.Vector2();
function onDocumentMouseDown( e ) {
e.preventDefault();
mouseVector.x = ( e.clientX / window.innerWidth ) * 2 - 1;
mouseVector.y = - ( e.clientY / window.innerHeight ) * 2 + 1;
var intersects = raycaster.intersectObjects(scene.children, true);
console.log(intersects);
if (intersects.length>0){
intersects[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );
}
}
function render() {
requestAnimationFrame(render);
mesh.rotation.y += 0.005;
renderer.render(scene, camera);
}
To troubleshoot the issue, I included a "console.log" statement in the code and observed that it consistently outputs an empty array in the console. This occurs regardless of whether I click on a specific object or just the background.