|
@@ -4,6 +4,12 @@
|
|
|
|
|
|
THREE.CrosseyedEffect = function ( renderer ) {
|
|
THREE.CrosseyedEffect = function ( renderer ) {
|
|
|
|
|
|
|
|
+ // API
|
|
|
|
+
|
|
|
|
+ this.separation = 10;
|
|
|
|
+
|
|
|
|
+ // internals
|
|
|
|
+
|
|
var _width, _height;
|
|
var _width, _height;
|
|
|
|
|
|
var _cameraL = new THREE.PerspectiveCamera();
|
|
var _cameraL = new THREE.PerspectiveCamera();
|
|
@@ -12,11 +18,7 @@ THREE.CrosseyedEffect = function ( renderer ) {
|
|
var _cameraR = new THREE.PerspectiveCamera();
|
|
var _cameraR = new THREE.PerspectiveCamera();
|
|
_cameraR.target = new THREE.Vector3();
|
|
_cameraR.target = new THREE.Vector3();
|
|
|
|
|
|
- var SCREEN_WIDTH = window.innerWidth;
|
|
|
|
- var SCREEN_HEIGHT = window.innerHeight;
|
|
|
|
- var HALF_WIDTH = SCREEN_WIDTH / 2;
|
|
|
|
-
|
|
|
|
- this.separation = 10;
|
|
|
|
|
|
+ // initialization
|
|
|
|
|
|
renderer.autoClear = false;
|
|
renderer.autoClear = false;
|
|
|
|
|
|
@@ -31,6 +33,8 @@ THREE.CrosseyedEffect = function ( renderer ) {
|
|
|
|
|
|
this.render = function ( scene, camera ) {
|
|
this.render = function ( scene, camera ) {
|
|
|
|
|
|
|
|
+ // left
|
|
|
|
+
|
|
_cameraL.fov = camera.fov;
|
|
_cameraL.fov = camera.fov;
|
|
_cameraL.aspect = 0.5 * camera.aspect;
|
|
_cameraL.aspect = 0.5 * camera.aspect;
|
|
_cameraL.near = camera.near;
|
|
_cameraL.near = camera.near;
|
|
@@ -42,6 +46,11 @@ THREE.CrosseyedEffect = function ( renderer ) {
|
|
_cameraL.translateX( this.separation );
|
|
_cameraL.translateX( this.separation );
|
|
_cameraL.lookAt( _cameraL.target );
|
|
_cameraL.lookAt( _cameraL.target );
|
|
|
|
|
|
|
|
+ // right
|
|
|
|
+
|
|
|
|
+ _cameraR.near = camera.near;
|
|
|
|
+ _cameraR.far = camera.far;
|
|
|
|
+
|
|
_cameraR.projectionMatrix = _cameraL.projectionMatrix;
|
|
_cameraR.projectionMatrix = _cameraL.projectionMatrix;
|
|
|
|
|
|
_cameraR.position.copy( camera.position );
|
|
_cameraR.position.copy( camera.position );
|
|
@@ -49,6 +58,8 @@ THREE.CrosseyedEffect = function ( renderer ) {
|
|
_cameraR.translateX( - this.separation );
|
|
_cameraR.translateX( - this.separation );
|
|
_cameraR.lookAt( _cameraR.target );
|
|
_cameraR.lookAt( _cameraR.target );
|
|
|
|
|
|
|
|
+ //
|
|
|
|
+
|
|
renderer.clear();
|
|
renderer.clear();
|
|
|
|
|
|
renderer.setViewport( 0, 0, _width, _height );
|
|
renderer.setViewport( 0, 0, _width, _height );
|