Browse Source

WebVRUtils: setProjectionFromUnion() now produces the correct frustum (changed thing blindly though)

Mr.doob 6 years ago
parent
commit
cf9f8ee16f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/renderers/webvr/WebVRUtils.js

+ 2 - 2
src/renderers/webvr/WebVRUtils.js

@@ -40,13 +40,13 @@ function setProjectionFromUnion( camera, cameraL, cameraR ) {
 
 
 	// Calculate the new camera's position offset from the
 	// Calculate the new camera's position offset from the
 	// left camera.
 	// left camera.
-	var zOffset = ipd / ( Math.abs( leftFovL ) + Math.abs( rightFovR ) );
+	var zOffset = ipd / ( leftFovL - rightFovR );
 	var xOffset = zOffset * leftFovL;
 	var xOffset = zOffset * leftFovL;
 
 
 	// TODO: Better way to apply this offset?
 	// TODO: Better way to apply this offset?
 	cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
 	cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
 	camera.translateX( xOffset );
 	camera.translateX( xOffset );
-	camera.translateZ( - zOffset );
+	camera.translateZ( - zOffset * 2 );
 	camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
 	camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
 	camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 	camera.matrixWorldInverse.getInverse( camera.matrixWorld );