浏览代码

StereoEffect set eye separation (#9432)

Michael Blix 9 年之前
父节点
当前提交
3d0dc519c6
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 6 0
      examples/js/effects/StereoEffect.js
  2. 3 1
      src/cameras/StereoCamera.js

+ 6 - 0
examples/js/effects/StereoEffect.js

@@ -16,6 +16,12 @@ THREE.StereoEffect = function ( renderer ) {
 
 
 	};
 	};
 
 
+	this.setEyeSep = function ( eyeSep ) {
+
+		_stereo.eyeSep = eyeSep;
+
+	};
+
 	this.render = function ( scene, camera ) {
 	this.render = function ( scene, camera ) {
 
 
 		scene.updateMatrixWorld();
 		scene.updateMatrixWorld();

+ 3 - 1
src/cameras/StereoCamera.js

@@ -12,6 +12,8 @@ function StereoCamera() {
 
 
 	this.aspect = 1;
 	this.aspect = 1;
 
 
+	this.eyeSep = 0.064;
+
 	this.cameraL = new PerspectiveCamera();
 	this.cameraL = new PerspectiveCamera();
 	this.cameraL.layers.enable( 1 );
 	this.cameraL.layers.enable( 1 );
 	this.cameraL.matrixAutoUpdate = false;
 	this.cameraL.matrixAutoUpdate = false;
@@ -49,7 +51,7 @@ Object.assign( StereoCamera.prototype, {
 				// http://paulbourke.net/stereographics/stereorender/
 				// http://paulbourke.net/stereographics/stereorender/
 
 
 				var projectionMatrix = camera.projectionMatrix.clone();
 				var projectionMatrix = camera.projectionMatrix.clone();
-				var eyeSep = 0.064 / 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 );
 				var xmin, xmax;
 				var xmin, xmax;