Browse Source

Simpler StereoEffect.

Mr.doob 11 years ago
parent
commit
8ae554e014
2 changed files with 6 additions and 14 deletions
  1. 6 13
      examples/js/effects/StereoEffect.js
  2. 0 1
      examples/webgl_effects_stereo.html

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

@@ -1,14 +1,14 @@
 /**
  * @author alteredq / http://alteredqualia.com/
  * @authod mrdoob / http://mrdoob.com/
+ * @authod arodic / http://aleksandarrodic.com/
  */
 
 THREE.StereoEffect = function ( renderer ) {
 
 	// API
 
-	this.separation = 6;
-	this.targetDistance = 500;
+	this.separation = 3;
 
 	// internals
 
@@ -20,7 +20,6 @@ THREE.StereoEffect = function ( renderer ) {
 
 	var _cameraL = new THREE.PerspectiveCamera();
 	var _cameraR = new THREE.PerspectiveCamera();
-	var _target = new THREE.Vector3();
 
 	// initialization
 
@@ -43,33 +42,27 @@ THREE.StereoEffect = function ( renderer ) {
 	
 		camera.matrixWorld.decompose( _position, _quaternion, _scale );
 
-		_target.set( 0, 0, - this.targetDistance );
-		_target.applyQuaternion( _quaternion );
-		_target.add( _position );
-
 		// left
 
 		_cameraL.fov = camera.fov;
 		_cameraL.aspect = 0.5 * camera.aspect;
-		_cameraL.updateProjectionMatrix();
-
 		_cameraL.near = camera.near;
 		_cameraL.far = camera.far;
+		_cameraL.updateProjectionMatrix();
 
 		_cameraL.position.copy( _position );
+		_cameraL.quaternion.copy( _quaternion );
 		_cameraL.translateX( - this.separation );
-		_cameraL.lookAt( _target );
 
 		// right
 
-		_cameraR.projectionMatrix = _cameraL.projectionMatrix;
-
 		_cameraR.near = camera.near;
 		_cameraR.far = camera.far;
+		_cameraR.projectionMatrix = _cameraL.projectionMatrix;
 
 		_cameraR.position.copy( _position );
+		_cameraR.quaternion.copy( _quaternion );
 		_cameraR.translateX( this.separation );
-		_cameraR.lookAt( _target );
 
 		//
 

+ 0 - 1
examples/webgl_effects_stereo.html

@@ -126,7 +126,6 @@
 
 				effect = new THREE.StereoEffect( renderer );
 				effect.separation = 10;
-				effect.targetDistance = 200;
 				effect.setSize( window.innerWidth, window.innerHeight );
 
 				//