嗨,我明白在THREE 71版本中没有THREE.projector.
但我不会不知道,如何更换THREE.projector功能和什么?
这是我的点击功能:
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1,- ( event.clientY / window.innerHeight ) * 2 + 1,0.5 ); projector.unprojectVector( vector,camera ); var raycaster = new THREE.Raycaster( camera.position,vector.sub( camera.position ).normalize() ); var intersects = raycaster.intersectObjects( objects ); if ( intersects.length > 0 ) { clicked = intersects[0]; console.log("my clicked object:",clicked); }
什么是正确的方法?
解决方法
现在有一种比较简单的图案可以用于正视和透视相机类型:
var raycaster = new THREE.Raycaster(); // create once var mouse = new THREE.Vector2(); // create once ... mouse.x = ( event.clientX / renderer.domElement.clientWidth ) * 2 - 1; mouse.y = - ( event.clientY / renderer.domElement.clientHeight ) * 2 + 1; raycaster.setFromCamera( mouse,camera ); var intersects = raycaster.intersectObjects( objects,recursiveFlag );
three.js r.84