Three.js RayCaster.setFromCamera,鼠标的位置和Z.

时间:2015-03-03 01:39:06

标签: three.js raycasting

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?

0 个答案:

没有答案