From 131cd0d5d48862ab1088c84edf166bd0e5f03289 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 26 Nov 2019 16:32:03 -0600 Subject: [PATCH] WebVRManager: Do not modify camera position and quaternion. --- src/renderers/webvr/WebVRManager.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/renderers/webvr/WebVRManager.js b/src/renderers/webvr/WebVRManager.js index 44e0646878..6ebb192e6e 100644 --- a/src/renderers/webvr/WebVRManager.js +++ b/src/renderers/webvr/WebVRManager.js @@ -41,6 +41,8 @@ function WebVRManager( renderer ) { var tempQuaternion = new Quaternion(); var tempPosition = new Vector3(); + var tempCamera = new PerspectiveCamera(); + var cameraL = new PerspectiveCamera(); cameraL.viewport = new Vector4(); cameraL.layers.enable( 1 ); @@ -303,14 +305,13 @@ function WebVRManager( renderer ) { var pose = frameData.pose; - // We want to manipulate camera by its position and quaternion components since users may rely on them. - camera.matrix.copy( standingMatrix ); - camera.matrix.decompose( camera.position, camera.quaternion, camera.scale ); + tempCamera.matrix.copy( standingMatrix ); + tempCamera.matrix.decompose( tempCamera.position, tempCamera.quaternion, tempCamera.scale ); if ( pose.orientation !== null ) { tempQuaternion.fromArray( pose.orientation ); - camera.quaternion.multiply( tempQuaternion ); + tempCamera.quaternion.multiply( tempQuaternion ); } @@ -319,11 +320,23 @@ function WebVRManager( renderer ) { tempQuaternion.setFromRotationMatrix( standingMatrix ); tempPosition.fromArray( pose.position ); tempPosition.applyQuaternion( tempQuaternion ); - camera.position.add( tempPosition ); + tempCamera.position.add( tempPosition ); } - camera.updateMatrixWorld(); + tempCamera.updateMatrixWorld(); + + // + + camera.matrixWorld.copy( tempCamera.matrixWorld ); + + var children = camera.children; + + for ( var i = 0, l = children.length; i < l; i ++ ) { + + children[ i ].updateMatrixWorld( true ); + + } // -- GitLab