From 185b717aa8527fbf25b38f7a7f2aa29a4465980b Mon Sep 17 00:00:00 2001 From: WestLangley Date: Fri, 27 Mar 2015 21:04:05 -0400 Subject: [PATCH] support cameras with transformed parents in setFromCamera() --- src/core/Raycaster.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/Raycaster.js b/src/core/Raycaster.js index 104f487b2b..d9fc20a707 100644 --- a/src/core/Raycaster.js +++ b/src/core/Raycaster.js @@ -67,12 +67,10 @@ 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(); + this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); + this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); } else if ( camera instanceof THREE.OrthographicCamera ) { -- GitLab