Я написал две очень похожие функции для mouseMove и mouseDown.Хотя первый работает нормально, последний продолжает получать пустой объект из var intersects = ray.intersectScene (scene).
Вы можете найти полный код здесь http://converteveryunit.com/pot/biluochun/temp/ Спасибо.
function onDocumentMouseMove(event) {
mouseX = event.clientX - homeWidth/2;
mouseY = event.clientY - homeHeight/2;
var vector = new THREE.Vector3( ( event.clientX / homeWidth ) * 2 - 1, - ( event.clientY / homeHeight ) * 2 + 1, 0.5 );
projector.unprojectVector( vector, camera );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectScene( scene );
}
function onDocumentMouseDown( event ) {
event.preventDefault();
var vector = new THREE.Vector3( ( event.clientX / homeWidth ) * 2 - 1, - ( event.clientY / homeHeight ) * 2 + 1, 100 );
projector.unprojectVector( vector, camera );
var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
var intersects = ray.intersectScene( scene );
console.log( intersects);
}