Преглед изворни кода

Partial revert of some WebVR 1.1 changes (#9709)

They didn't produce correct eye translations in all cases (specifically
standing scenes.) This reverted version may not be 100% accurate on
future hardware (if the eyes have a rotation component, for example) but
it's correct on all current WebVR implementations. That's better than
blatantly wrong in some cases.

Use of the WebVR-provided projection matricies has been left in, since
that was working correctly.
Brandon Jones пре 8 година
родитељ
комит
75c9b190f0
1 измењених фајлова са 5 додато и 51 уклоњено
  1. 5 51
      examples/js/effects/VREffect.js

+ 5 - 51
examples/js/effects/VREffect.js

@@ -15,9 +15,6 @@ THREE.VREffect = function ( renderer, onError ) {
 	var eyeTranslationL = new THREE.Vector3();
 	var eyeTranslationR = new THREE.Vector3();
 	var renderRectL, renderRectR;
-	var headMatrix = new THREE.Matrix4();
-	var headToEyeMatrixL = new THREE.Matrix4();
-	var headToEyeMatrixR = new THREE.Matrix4();
 
 	var frameData = null;
 	if ( 'VRFrameData' in window ) {
@@ -293,6 +290,10 @@ THREE.VREffect = function ( renderer, onError ) {
 			camera.matrixWorld.decompose( cameraL.position, cameraL.quaternion, cameraL.scale );
 			camera.matrixWorld.decompose( cameraR.position, cameraR.quaternion, cameraR.scale );
 
+			var scale = this.scale;
+			cameraL.translateOnAxis( eyeTranslationL, scale );
+			cameraR.translateOnAxis( eyeTranslationR, scale );
+
 			if ( vrDisplay.getFrameData ) {
 
 				vrDisplay.depthNear = camera.near;
@@ -303,23 +304,12 @@ THREE.VREffect = function ( renderer, onError ) {
 				cameraL.projectionMatrix.elements = frameData.leftProjectionMatrix;
 				cameraR.projectionMatrix.elements = frameData.rightProjectionMatrix;
 
-				getHeadToEyeMatrices( frameData );
-
-				cameraL.updateMatrix();
-				cameraL.applyMatrix( headToEyeMatrixL );
-
-				cameraR.updateMatrix();
-				cameraR.applyMatrix( headToEyeMatrixR );
-
 			} else {
 
 				cameraL.projectionMatrix = fovToProjection( eyeParamsL.fieldOfView, true, camera.near, camera.far );
 				cameraR.projectionMatrix = fovToProjection( eyeParamsR.fieldOfView, true, camera.near, camera.far );
 
-				var scale = this.scale;
-				cameraL.translateOnAxis( eyeTranslationL, scale );
-				cameraR.translateOnAxis( eyeTranslationR, scale );
-
+				
 			}
 
 			// render left eye
@@ -387,42 +377,6 @@ THREE.VREffect = function ( renderer, onError ) {
 
 	//
 
-	var poseOrientation = new THREE.Quaternion();
-	var posePosition = new THREE.Vector3();
-
-	function getHeadToEyeMatrices( frameData ) {
-
-		// Compute the matrix for the position of the head based on the pose
-		if ( frameData.pose.orientation ) {
-
-			poseOrientation.fromArray( frameData.pose.orientation );
-			headMatrix.makeRotationFromQuaternion( poseOrientation );
-
-		}	else {
-
-			headMatrix.identity();
-
-		}
-
-		if ( frameData.pose.position ) {
-
-			posePosition.fromArray( frameData.pose.position );
-			headMatrix.setPosition( posePosition );
-
-		}
-
-		// Take the view matricies and multiply them by the head matrix, which
-		// leaves only the head-to-eye transform.
-		headToEyeMatrixL.fromArray( frameData.leftViewMatrix );
-		headToEyeMatrixL.premultiply( headMatrix );
-		headToEyeMatrixL.getInverse( headToEyeMatrixL );
-
-		headToEyeMatrixR.fromArray( frameData.rightViewMatrix );
-		headToEyeMatrixR.premultiply( headMatrix );
-		headToEyeMatrixR.getInverse( headToEyeMatrixR );
-
-	}
-
 	function fovToNDCScaleOffset( fov ) {
 
 		var pxscale = 2.0 / ( fov.leftTan + fov.rightTan );