|
@@ -48,19 +48,16 @@ THREE.CSS3DStereoRenderer = function () {
|
|
|
|
|
|
console.log( 'THREE.CSS3DRenderer', THREE.REVISION );
|
|
|
|
|
|
+ var _stereo = new THREE.StereoCamera();
|
|
|
+ _stereo.aspect = 0.5;
|
|
|
+
|
|
|
+ var _cameraL, _cameraR;
|
|
|
+
|
|
|
var _width, _height;
|
|
|
var _widthHalf, _heightHalf;
|
|
|
|
|
|
var matrix = new THREE.Matrix4();
|
|
|
|
|
|
- var _position = new THREE.Vector3();
|
|
|
- var _quaternion = new THREE.Quaternion();
|
|
|
- var _scale = new THREE.Vector3();
|
|
|
-
|
|
|
- var _cameraL = new THREE.PerspectiveCamera();
|
|
|
- var _cameraR = new THREE.PerspectiveCamera();
|
|
|
- var _target = new THREE.Vector3();
|
|
|
-
|
|
|
this.separation = 6;
|
|
|
this.targetDistance = 500;
|
|
|
|
|
@@ -256,27 +253,13 @@ THREE.CSS3DStereoRenderer = function () {
|
|
|
|
|
|
if ( camera.parent === null ) camera.updateMatrixWorld();
|
|
|
|
|
|
- camera.matrixWorld.decompose( _position, _quaternion, _scale );
|
|
|
-
|
|
|
- _target.set( 0, 0, - this.targetDistance );
|
|
|
- _target.applyQuaternion( _quaternion );
|
|
|
- _target.add( _position );
|
|
|
+ _stereo.update( camera );
|
|
|
|
|
|
var fov = 0.5 / Math.tan( THREE.Math.degToRad( camera.fov * 0.5 ) ) * _height;
|
|
|
|
|
|
// Left
|
|
|
|
|
|
- _cameraL.fov = camera.fov;
|
|
|
- _cameraL.aspect = 0.5 * camera.aspect;
|
|
|
- _cameraL.updateProjectionMatrix();
|
|
|
-
|
|
|
- _cameraL.near = camera.near;
|
|
|
- _cameraL.far = camera.far;
|
|
|
-
|
|
|
- _cameraL.position.copy( _position );
|
|
|
- _cameraL.translateX( - this.separation );
|
|
|
- _cameraL.lookAt( _target );
|
|
|
- _cameraL.updateMatrixWorld();
|
|
|
+ _cameraL = _stereo.cameraL;
|
|
|
|
|
|
domElementL.style.WebkitPerspective = fov + "px";
|
|
|
domElementL.style.MozPerspective = fov + "px";
|
|
@@ -297,15 +280,7 @@ THREE.CSS3DStereoRenderer = function () {
|
|
|
|
|
|
// Right
|
|
|
|
|
|
- _cameraR.projectionMatrix = _cameraL.projectionMatrix;
|
|
|
-
|
|
|
- _cameraR.near = camera.near;
|
|
|
- _cameraR.far = camera.far;
|
|
|
-
|
|
|
- _cameraR.position.copy( _position );
|
|
|
- _cameraR.translateX( this.separation );
|
|
|
- _cameraR.lookAt( _target );
|
|
|
- _cameraR.updateMatrixWorld();
|
|
|
+ _cameraR = _stereo.cameraR;
|
|
|
|
|
|
domElementR.style.WebkitPerspective = fov + "px";
|
|
|
domElementR.style.MozPerspective = fov + "px";
|