【发布时间】:2015-05-03 13:30:36
【问题描述】:
三.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?
【问题讨论】:
-
@WestLangley 非常感谢。现在太难理解了,但我知道这就是我想要的。
-
如果有困难,请使用EventControls
标签: three.js raycasting