Browse Source

Clean up.

Mr.doob 7 years ago
parent
commit
a2663dfd0f
1 changed files with 13 additions and 7 deletions
  1. 13 7
      src/renderers/webvr/WebVRManager.js

+ 13 - 7
src/renderers/webvr/WebVRManager.js

@@ -19,8 +19,6 @@ function WebVRManager( renderer ) {
 	var standingMatrix = new Matrix4();
 	var standingMatrix = new Matrix4();
 	var standingMatrixInverse = new Matrix4();
 	var standingMatrixInverse = new Matrix4();
 
 
-	scope.userHeight = 1.6;
-
 	if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
 	if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
 
 
 		frameData = new window.VRFrameData();
 		frameData = new window.VRFrameData();
@@ -75,6 +73,7 @@ function WebVRManager( renderer ) {
 	//
 	//
 
 
 	this.enabled = false;
 	this.enabled = false;
+	this.userHeight = 1.6;
 
 
 	this.getDevice = function () {
 	this.getDevice = function () {
 
 
@@ -126,13 +125,16 @@ function WebVRManager( renderer ) {
 
 
 		var stageParameters = device.stageParameters;
 		var stageParameters = device.stageParameters;
 
 
-		if (stageParameters) {
-		  standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
+		if ( stageParameters ) {
+
+			standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
+
 		} else {
 		} else {
-		  standingMatrix.makeTranslation(0, scope.userHeight, 0);
+
+			standingMatrix.makeTranslation( 0, scope.userHeight, 0 );
+
 		}
 		}
 
 
-		standingMatrixInverse.getInverse( standingMatrix );
 		poseObject.position.applyMatrix4( standingMatrix );
 		poseObject.position.applyMatrix4( standingMatrix );
 		poseObject.updateMatrixWorld();
 		poseObject.updateMatrixWorld();
 
 
@@ -152,6 +154,10 @@ function WebVRManager( renderer ) {
 		cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
 		cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
 		cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
 		cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
 
 
+		// TODO (mrdoob) Double check this code
+
+		standingMatrixInverse.getInverse( standingMatrix );
+
 		cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
 		cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
 		cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
 		cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
 
 
@@ -174,7 +180,7 @@ function WebVRManager( renderer ) {
 		cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
 		cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
 		cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
 		cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
 
 
-		// HACK @mrdoob
+		// HACK (mrdoob)
 		// https://github.com/w3c/webvr/issues/203
 		// https://github.com/w3c/webvr/issues/203
 
 
 		cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );
 		cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );