Sfoglia il codice sorgente

Merge pull request #6301 from WestLangley/dev-raycaster

support cameras with transformed parents in setFromCamera()
Ricardo Cabello 10 anni fa
parent
commit
b1d4518e49
1 ha cambiato i file con 2 aggiunte e 4 eliminazioni
  1. 2 4
      src/core/Raycaster.js

+ 2 - 4
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 ) {