فهرست منبع

WebVRUtils: Fix NaNs and Infinity in setProjectionFromUnion().

Mr.doob 6 سال پیش
والد
کامیت
f25d81ede3
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      src/renderers/webvr/WebVRUtils.js

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

@@ -20,8 +20,8 @@ function setProjectionFromUnion( camera, cameraL, cameraR ) {
 
 	var ipd = cameraLPos.distanceTo( cameraRPos );
 
-	var projL = cameraL.projectionMatrix;
-	var projR = cameraR.projectionMatrix;
+	var projL = cameraL.projectionMatrix.elements;
+	var projR = cameraR.projectionMatrix.elements;
 
 	// VR systems will have identical far and near planes, and
 	// most likely identical top and bottom frustum extents.
@@ -40,7 +40,7 @@ function setProjectionFromUnion( camera, cameraL, cameraR ) {
 
 	// Calculate the new camera's position offset from the
 	// left camera.
-	var zOffset = ipd / ( leftFovL + rightFovR );
+	var zOffset = ipd / ( Math.abs( leftFovL ) + Math.abs( rightFovR ) );
 	var xOffset = zOffset * leftFovL;
 
 	// TODO: Better way to apply this offset?