Three.js r70源代码
setFromCamera: function ( coords, camera ) {
// camera is assumed _not_ to be a child of a transformed object
if ( camera instanceof THREE.PerspectiveCamera ) {
this.ray.origin.copy( camera.position );
this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( camera.position ).normalize();
}
此行,设置鼠标的位置和z的默认值0.5。
this.ray.direction.set( coords.x, coords.y, 0.5 )
关于光线投射的大多数示例代码,如
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
我想知道它是如何工作的,( event.clientX / window.innerWidth ) * 2 - 1
意味着什么,为什么设置z 0.5?