提交 db1c841e 编写于 作者: M Mr.doob

Updated builds.

上级 90ad637b
......@@ -17160,6 +17160,97 @@ THREE.PerspectiveCamera.prototype.toJSON = function ( meta ) {
};
// File:src/cameras/StereoCamera.js
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.StereoCamera = function ( fov, aspect, near, far ) {
THREE.PerspectiveCamera.call( this, fov, aspect, near, far );
this.type = 'StereoCamera';
this.focalLength = 125;
this.cameraL = new THREE.PerspectiveCamera();
this.cameraL.matrixAutoUpdate = false;
this.cameraR = new THREE.PerspectiveCamera();
this.cameraR.matrixAutoUpdate = false;
};
THREE.StereoCamera.prototype = Object.create( THREE.PerspectiveCamera.prototype );
THREE.StereoCamera.prototype.constructor = THREE.StereoCamera;
THREE.StereoCamera.prototype.updateMatrixWorld = ( function () {
var focalLength, fov, aspect, near, far;
var eyeRight = new THREE.Matrix4();
var eyeLeft = new THREE.Matrix4();
return function updateMatrixWorld ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
var needsUpdate = focalLength !== this.focalLength || fov !== this.fov ||
aspect !== this.aspect || near !== this.near ||
far !== this.far;
if ( needsUpdate ) {
focalLength = this.focalLength;
fov = this.fov;
aspect = this.aspect;
near = this.near;
far = this.far;
// Off-axis stereoscopic effect based on
// http://paulbourke.net/stereographics/stereorender/
var projectionMatrix = this.projectionMatrix.clone();
var eyeSep = focalLength / 30 * 0.5;
var eyeSepOnProjection = eyeSep * near / focalLength;
var ymax = near * Math.tan( THREE.Math.degToRad( fov * 0.5 ) );
var xmin, xmax;
// translate xOffset
eyeLeft.elements[ 12 ] = - eyeSep;
eyeRight.elements[ 12 ] = eyeSep;
// for left eye
xmin = - ymax * aspect + eyeSepOnProjection;
xmax = ymax * aspect + eyeSepOnProjection;
projectionMatrix.elements[ 0 ] = 2 * near / ( xmax - xmin );
projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
this.cameraL.projectionMatrix.copy( projectionMatrix );
// for right eye
xmin = - ymax * aspect - eyeSepOnProjection;
xmax = ymax * aspect - eyeSepOnProjection;
projectionMatrix.elements[ 0 ] = 2 * near / ( xmax - xmin );
projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
this.cameraR.projectionMatrix.copy( projectionMatrix );
}
this.cameraL.matrixWorld.copy( this.matrixWorld ).multiply( eyeLeft );
this.cameraR.matrixWorld.copy( this.matrixWorld ).multiply( eyeRight );
};
} )();
// File:src/lights/Light.js
/**
......
......@@ -355,7 +355,10 @@ THREE.OrthographicCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype
THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){void 0===b&&(b=24);this.fov=2*THREE.Math.radToDeg(Math.atan(b/(2*a)));this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var a=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var b=this.fullWidth/this.fullHeight,a=Math.tan(THREE.Math.degToRad(.5*a))*this.near,c=-a,d=b*c,b=Math.abs(b*a-d),c=Math.abs(a-c);this.projectionMatrix.makeFrustum(d+this.x*b/this.fullWidth,d+(this.x+this.width)*b/this.fullWidth,a-(this.y+this.height)*c/this.fullHeight,a-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(a,
this.aspect,this.near,this.far)};THREE.PerspectiveCamera.prototype.copy=function(a){THREE.Camera.prototype.copy.call(this,a);this.fov=a.fov;this.aspect=a.aspect;this.near=a.near;this.far=a.far;this.zoom=a.zoom;return this};THREE.PerspectiveCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.fov=this.fov;a.object.aspect=this.aspect;a.object.near=this.near;a.object.far=this.far;return a};
THREE.Light=function(a,b){THREE.Object3D.call(this);this.type="Light";this.color=new THREE.Color(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this};
THREE.StereoCamera=function(a,b,c,d){THREE.PerspectiveCamera.call(this,a,b,c,d);this.type="StereoCamera";this.focalLength=125;this.cameraL=new THREE.PerspectiveCamera;this.cameraL.matrixAutoUpdate=!1;this.cameraR=new THREE.PerspectiveCamera;this.cameraR.matrixAutoUpdate=!1};THREE.StereoCamera.prototype=Object.create(THREE.PerspectiveCamera.prototype);THREE.StereoCamera.prototype.constructor=THREE.StereoCamera;
THREE.StereoCamera.prototype.updateMatrixWorld=function(){var a,b,c,d,e,f=new THREE.Matrix4,g=new THREE.Matrix4;return function(h){THREE.Object3D.prototype.updateMatrixWorld.call(this,h);if(a!==this.focalLength||b!==this.fov||c!==this.aspect||d!==this.near||e!==this.far){a=this.focalLength;b=this.fov;c=this.aspect;d=this.near;e=this.far;h=this.projectionMatrix.clone();var k=a/30*.5,l=k*d/a,m=d*Math.tan(THREE.Math.degToRad(.5*b)),p;g.elements[12]=-k;f.elements[12]=k;k=-m*c+l;p=m*c+l;h.elements[0]=
2*d/(p-k);h.elements[8]=(p+k)/(p-k);this.cameraL.projectionMatrix.copy(h);k=-m*c-l;p=m*c-l;h.elements[0]=2*d/(p-k);h.elements[8]=(p+k)/(p-k);this.cameraR.projectionMatrix.copy(h)}this.cameraL.matrixWorld.copy(this.matrixWorld).multiply(g);this.cameraR.matrixWorld.copy(this.matrixWorld).multiply(f)}}();THREE.Light=function(a,b){THREE.Object3D.call(this);this.type="Light";this.color=new THREE.Color(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);
THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this};
THREE.Light.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.exponent&&(a.object.exponent=this.exponent);return a};
THREE.LightShadow=function(a){this.camera=a;this.bias=0;this.darkness=1;this.mapSize=new THREE.Vector2(512,512);this.matrix=this.map=null};THREE.LightShadow.prototype={constructor:THREE.LightShadow,copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.darkness=a.darkness;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)}};THREE.AmbientLight=function(a,b){THREE.Light.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0};
THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a,b);this.type="DirectionalLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.shadow=new THREE.LightShadow(new THREE.OrthographicCamera(-5,5,5,-5,.5,500))};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册