瀏覽代碼

Updated builds.

Mr.doob 7 年之前
父節點
當前提交
ef88a0c47d
共有 3 個文件被更改,包括 286 次插入194 次删除
  1. 51 5
      build/three.js
  2. 184 184
      build/three.min.js
  3. 51 5
      build/three.module.js

+ 51 - 5
build/three.js

@@ -21475,6 +21475,7 @@
 	function WebXRManager( renderer ) {
 
 		var gl = renderer.context;
+
 		var device = null;
 		var session = null;
 
@@ -21551,9 +21552,56 @@
 
 		};
 
+		function updateCamera( camera, parent ) {
+
+			if ( parent === null ) {
+
+				camera.matrixWorld.copy( camera.matrix );
+
+			} else {
+
+				camera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );
+
+			}
+
+			camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+
+		}
+
 		this.getCamera = function ( camera ) {
 
-			return isPresenting() ? cameraVR : camera;
+			if ( isPresenting() ) {
+
+				var parent = camera.parent;
+				var cameras = cameraVR.cameras;
+
+				// apply camera.parent to cameraVR
+
+				updateCamera( cameraVR, parent );
+
+				for ( var i = 0; i < cameras.length; i ++ ) {
+
+					updateCamera( cameras[ i ], parent );
+
+				}
+
+				// update camera and its children
+
+				camera.matrixWorld.copy( cameraVR.matrixWorld );
+
+				var children = camera.children;
+
+				for ( var i = 0, l = children.length; i < l; i ++ ) {
+
+					children[ i ].updateMatrixWorld( true );
+
+				}
+
+				return cameraVR;
+
+			}
+
+			return camera;
 
 		};
 
@@ -21577,15 +21625,13 @@
 				var viewMatrix = pose.getViewMatrix( view );
 
 				var camera = cameraVR.cameras[ i ];
+				camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
 				camera.projectionMatrix.fromArray( view.projectionMatrix );
-				camera.matrixWorldInverse.fromArray( viewMatrix );
-				camera.matrixWorld.getInverse( camera.matrixWorldInverse );
 				camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
 				if ( i === 0 ) {
 
-					cameraVR.matrixWorld.copy( camera.matrixWorld );
-					cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
+					cameraVR.matrix.copy( camera.matrix );
 
 					// HACK (mrdoob)
 					// https://github.com/w3c/webvr/issues/203

File diff suppressed because it is too large
+ 184 - 184
build/three.min.js


+ 51 - 5
build/three.module.js

@@ -21469,6 +21469,7 @@ function WebVRManager( renderer ) {
 function WebXRManager( renderer ) {
 
 	var gl = renderer.context;
+
 	var device = null;
 	var session = null;
 
@@ -21545,9 +21546,56 @@ function WebXRManager( renderer ) {
 
 	};
 
+	function updateCamera( camera, parent ) {
+
+		if ( parent === null ) {
+
+			camera.matrixWorld.copy( camera.matrix );
+
+		} else {
+
+			camera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );
+
+		}
+
+		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
+
+	}
+
 	this.getCamera = function ( camera ) {
 
-		return isPresenting() ? cameraVR : camera;
+		if ( isPresenting() ) {
+
+			var parent = camera.parent;
+			var cameras = cameraVR.cameras;
+
+			// apply camera.parent to cameraVR
+
+			updateCamera( cameraVR, parent );
+
+			for ( var i = 0; i < cameras.length; i ++ ) {
+
+				updateCamera( cameras[ i ], parent );
+
+			}
+
+			// update camera and its children
+
+			camera.matrixWorld.copy( cameraVR.matrixWorld );
+
+			var children = camera.children;
+
+			for ( var i = 0, l = children.length; i < l; i ++ ) {
+
+				children[ i ].updateMatrixWorld( true );
+
+			}
+
+			return cameraVR;
+
+		}
+
+		return camera;
 
 	};
 
@@ -21571,15 +21619,13 @@ function WebXRManager( renderer ) {
 			var viewMatrix = pose.getViewMatrix( view );
 
 			var camera = cameraVR.cameras[ i ];
+			camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
 			camera.projectionMatrix.fromArray( view.projectionMatrix );
-			camera.matrixWorldInverse.fromArray( viewMatrix );
-			camera.matrixWorld.getInverse( camera.matrixWorldInverse );
 			camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
 
 			if ( i === 0 ) {
 
-				cameraVR.matrixWorld.copy( camera.matrixWorld );
-				cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
+				cameraVR.matrix.copy( camera.matrix );
 
 				// HACK (mrdoob)
 				// https://github.com/w3c/webvr/issues/203

Some files were not shown because too many files changed in this diff