提交 a22d828b 编写于 作者: M Mr.doob

Raycaster: Added setFromCamera (old projector.pickingRay()). Fixes #5587.

上级 bad7a04d
......@@ -59,9 +59,32 @@
set: function ( origin, direction ) {
this.ray.set( origin, direction );
// direction is assumed to be normalized (for accurate distance calculations)
this.ray.set( origin, direction );
},
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();
} else if ( camera instanceof THREE.OrthographicCamera ) {
this.ray.origin.set( coords.x, coords.y, - 1 ).unproject( camera );
this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
} else {
console.error( 'THREE.Raycaster: Unsupported camera type.' );
}
},
intersectObject: function ( object, recursive ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册