Mr.doob преди 7 години
родител
ревизия
a2663dfd0f
променени са 1 файла, в които са добавени 13 реда и са изтрити 7 реда
  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 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 );