Browse Source

StereoCamera: Fix distortion when zoom is not equal to one. (#9648)

* Fix distortion on stereo camera when zoom is not equal to one.

* Add parenthesis to make the code changes clearer.

* Add a local zoom variable to StereoCamera to keep track of changes.
Alan Wu 9 years ago
parent
commit
185f4d622c
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/cameras/StereoCamera.js

+ 4 - 3
src/cameras/StereoCamera.js

@@ -28,7 +28,7 @@ Object.assign( StereoCamera.prototype, {
 
 
 	update: ( function () {
 	update: ( function () {
 
 
-		var focus, fov, aspect, near, far;
+		var focus, fov, aspect, near, far, zoom;
 
 
 		var eyeRight = new Matrix4();
 		var eyeRight = new Matrix4();
 		var eyeLeft = new Matrix4();
 		var eyeLeft = new Matrix4();
@@ -37,7 +37,7 @@ Object.assign( StereoCamera.prototype, {
 
 
 			var needsUpdate = focus !== camera.focus || fov !== camera.fov ||
 			var needsUpdate = focus !== camera.focus || fov !== camera.fov ||
 												aspect !== camera.aspect * this.aspect || near !== camera.near ||
 												aspect !== camera.aspect * this.aspect || near !== camera.near ||
-												far !== camera.far;
+												far !== camera.far || zoom !== camera.zoom;
 
 
 			if ( needsUpdate ) {
 			if ( needsUpdate ) {
 
 
@@ -46,6 +46,7 @@ Object.assign( StereoCamera.prototype, {
 				aspect = camera.aspect * this.aspect;
 				aspect = camera.aspect * this.aspect;
 				near = camera.near;
 				near = camera.near;
 				far = camera.far;
 				far = camera.far;
+				zoom = camera.zoom;
 
 
 				// Off-axis stereoscopic effect based on
 				// Off-axis stereoscopic effect based on
 				// http://paulbourke.net/stereographics/stereorender/
 				// http://paulbourke.net/stereographics/stereorender/
@@ -53,7 +54,7 @@ Object.assign( StereoCamera.prototype, {
 				var projectionMatrix = camera.projectionMatrix.clone();
 				var projectionMatrix = camera.projectionMatrix.clone();
 				var eyeSep = this.eyeSep / 2;
 				var eyeSep = this.eyeSep / 2;
 				var eyeSepOnProjection = eyeSep * near / focus;
 				var eyeSepOnProjection = eyeSep * near / focus;
-				var ymax = near * Math.tan( _Math.DEG2RAD * fov * 0.5 );
+				var ymax = ( near * Math.tan( _Math.DEG2RAD * fov * 0.5 ) ) / zoom;
 				var xmin, xmax;
 				var xmin, xmax;
 
 
 				// translate xOffset
 				// translate xOffset