From a2663dfd0fac68b6392ad4f798ecc59222fa66ea Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 13 Feb 2018 16:58:59 -0800 Subject: [PATCH] Clean up. --- src/renderers/webvr/WebVRManager.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/renderers/webvr/WebVRManager.js b/src/renderers/webvr/WebVRManager.js index fb6bb92c79..8b7539dbbb 100644 --- a/src/renderers/webvr/WebVRManager.js +++ b/src/renderers/webvr/WebVRManager.js @@ -19,8 +19,6 @@ function WebVRManager( renderer ) { var standingMatrix = new Matrix4(); var standingMatrixInverse = new Matrix4(); - scope.userHeight = 1.6; - if ( typeof window !== 'undefined' && 'VRFrameData' in window ) { frameData = new window.VRFrameData(); @@ -75,6 +73,7 @@ function WebVRManager( renderer ) { // this.enabled = false; + this.userHeight = 1.6; this.getDevice = function () { @@ -126,13 +125,16 @@ function WebVRManager( renderer ) { var stageParameters = device.stageParameters; - if (stageParameters) { - standingMatrix.fromArray( stageParameters.sittingToStandingTransform ); + if ( stageParameters ) { + + standingMatrix.fromArray( stageParameters.sittingToStandingTransform ); + } else { - standingMatrix.makeTranslation(0, scope.userHeight, 0); + + standingMatrix.makeTranslation( 0, scope.userHeight, 0 ); + } - standingMatrixInverse.getInverse( standingMatrix ); poseObject.position.applyMatrix4( standingMatrix ); poseObject.updateMatrixWorld(); @@ -152,6 +154,10 @@ function WebVRManager( renderer ) { cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix ); cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix ); + // TODO (mrdoob) Double check this code + + standingMatrixInverse.getInverse( standingMatrix ); + cameraL.matrixWorldInverse.multiply( standingMatrixInverse ); cameraR.matrixWorldInverse.multiply( standingMatrixInverse ); @@ -174,7 +180,7 @@ function WebVRManager( renderer ) { cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix ); cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix ); - // HACK @mrdoob + // HACK (mrdoob) // https://github.com/w3c/webvr/issues/203 cameraVR.projectionMatrix.copy( cameraL.projectionMatrix ); -- GitLab