|
@@ -10391,6 +10391,84 @@ THREE.Camera.prototype.clone = function (camera) {
|
|
|
return camera;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Camera for rendering cube maps
|
|
|
+ * - renders scene into axis-aligned cube
|
|
|
+ *
|
|
|
+ * @author alteredq / http://alteredqualia.com/
|
|
|
+ */
|
|
|
+
|
|
|
+THREE.CubeCamera = function ( near, far, cubeResolution ) {
|
|
|
+
|
|
|
+ THREE.Object3D.call( this );
|
|
|
+
|
|
|
+ var fov = 90, aspect = 1;
|
|
|
+
|
|
|
+ var cameraPX = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraPX.up.set( 0, -1, 0 );
|
|
|
+ cameraPX.lookAt( new THREE.Vector3( 1, 0, 0 ) );
|
|
|
+ this.add( cameraPX );
|
|
|
+
|
|
|
+ var cameraNX = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraNX.up.set( 0, -1, 0 );
|
|
|
+ cameraNX.lookAt( new THREE.Vector3( -1, 0, 0 ) );
|
|
|
+ this.add( cameraNX );
|
|
|
+
|
|
|
+ var cameraPY = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraPY.up.set( 0, 0, 1 );
|
|
|
+ cameraPY.lookAt( new THREE.Vector3( 0, 1, 0 ) );
|
|
|
+ this.add( cameraPY );
|
|
|
+
|
|
|
+ var cameraNY = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraNY.up.set( 0, 0, -1 );
|
|
|
+ cameraNY.lookAt( new THREE.Vector3( 0, -1, 0 ) );
|
|
|
+ this.add( cameraNY );
|
|
|
+
|
|
|
+ var cameraPZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraPZ.up.set( 0, -1, 0 );
|
|
|
+ cameraPZ.lookAt( new THREE.Vector3( 0, 0, 1 ) );
|
|
|
+ this.add( cameraPZ );
|
|
|
+
|
|
|
+ var cameraNZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ cameraNZ.up.set( 0, -1, 0 );
|
|
|
+ cameraNZ.lookAt( new THREE.Vector3( 0, 0, -1 ) );
|
|
|
+ this.add( cameraNZ );
|
|
|
+
|
|
|
+ this.renderTarget = new THREE.WebGLRenderTargetCube( cubeResolution, cubeResolution, { format: THREE.RGBFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter } );
|
|
|
+
|
|
|
+ this.updateCubeMap = function ( renderer, scene ) {
|
|
|
+
|
|
|
+ var renderTarget = this.renderTarget;
|
|
|
+ var generateMipmaps = renderTarget.generateMipmaps;
|
|
|
+
|
|
|
+ renderTarget.generateMipmaps = false;
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 0;
|
|
|
+ renderer.render( scene, cameraPX, renderTarget );
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 1;
|
|
|
+ renderer.render( scene, cameraNX, renderTarget );
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 2;
|
|
|
+ renderer.render( scene, cameraPY, renderTarget );
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 3;
|
|
|
+ renderer.render( scene, cameraNY, renderTarget );
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 4;
|
|
|
+ renderer.render( scene, cameraPZ, renderTarget );
|
|
|
+
|
|
|
+ renderTarget.generateMipmaps = generateMipmaps;
|
|
|
+
|
|
|
+ renderTarget.activeCubeFace = 5;
|
|
|
+ renderer.render( scene, cameraNZ, renderTarget );
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+THREE.CubeCamera.prototype = Object.create( THREE.Object3D.prototype );
|
|
|
+
|
|
|
/**
|
|
|
* @author alteredq / http://alteredqualia.com/
|
|
|
*/
|
|
@@ -31227,321 +31305,6 @@ THREE.MorphAnimation.prototype = {
|
|
|
|
|
|
};
|
|
|
|
|
|
-/**
|
|
|
- * Camera for rendering cube maps
|
|
|
- * - renders scene into axis-aligned cube
|
|
|
- *
|
|
|
- * @author alteredq / http://alteredqualia.com/
|
|
|
- */
|
|
|
-
|
|
|
-THREE.CubeCamera = function ( near, far, cubeResolution ) {
|
|
|
-
|
|
|
- THREE.Object3D.call( this );
|
|
|
-
|
|
|
- var fov = 90, aspect = 1;
|
|
|
-
|
|
|
- var cameraPX = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraPX.up.set( 0, -1, 0 );
|
|
|
- cameraPX.lookAt( new THREE.Vector3( 1, 0, 0 ) );
|
|
|
- this.add( cameraPX );
|
|
|
-
|
|
|
- var cameraNX = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraNX.up.set( 0, -1, 0 );
|
|
|
- cameraNX.lookAt( new THREE.Vector3( -1, 0, 0 ) );
|
|
|
- this.add( cameraNX );
|
|
|
-
|
|
|
- var cameraPY = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraPY.up.set( 0, 0, 1 );
|
|
|
- cameraPY.lookAt( new THREE.Vector3( 0, 1, 0 ) );
|
|
|
- this.add( cameraPY );
|
|
|
-
|
|
|
- var cameraNY = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraNY.up.set( 0, 0, -1 );
|
|
|
- cameraNY.lookAt( new THREE.Vector3( 0, -1, 0 ) );
|
|
|
- this.add( cameraNY );
|
|
|
-
|
|
|
- var cameraPZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraPZ.up.set( 0, -1, 0 );
|
|
|
- cameraPZ.lookAt( new THREE.Vector3( 0, 0, 1 ) );
|
|
|
- this.add( cameraPZ );
|
|
|
-
|
|
|
- var cameraNZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
|
|
|
- cameraNZ.up.set( 0, -1, 0 );
|
|
|
- cameraNZ.lookAt( new THREE.Vector3( 0, 0, -1 ) );
|
|
|
- this.add( cameraNZ );
|
|
|
-
|
|
|
- this.renderTarget = new THREE.WebGLRenderTargetCube( cubeResolution, cubeResolution, { format: THREE.RGBFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter } );
|
|
|
-
|
|
|
- this.updateCubeMap = function ( renderer, scene ) {
|
|
|
-
|
|
|
- var renderTarget = this.renderTarget;
|
|
|
- var generateMipmaps = renderTarget.generateMipmaps;
|
|
|
-
|
|
|
- renderTarget.generateMipmaps = false;
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 0;
|
|
|
- renderer.render( scene, cameraPX, renderTarget );
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 1;
|
|
|
- renderer.render( scene, cameraNX, renderTarget );
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 2;
|
|
|
- renderer.render( scene, cameraPY, renderTarget );
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 3;
|
|
|
- renderer.render( scene, cameraNY, renderTarget );
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 4;
|
|
|
- renderer.render( scene, cameraPZ, renderTarget );
|
|
|
-
|
|
|
- renderTarget.generateMipmaps = generateMipmaps;
|
|
|
-
|
|
|
- renderTarget.activeCubeFace = 5;
|
|
|
- renderer.render( scene, cameraNZ, renderTarget );
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CubeCamera.prototype = Object.create( THREE.Object3D.prototype );
|
|
|
-
|
|
|
-/**
|
|
|
- * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
|
|
|
- *
|
|
|
- * A general perpose camera, for setting FOV, Lens Focal Length,
|
|
|
- * and switching between perspective and orthographic views easily.
|
|
|
- * Use this only if you do not wish to manage
|
|
|
- * both a Orthographic and Perspective Camera
|
|
|
- *
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orthoFar ) {
|
|
|
-
|
|
|
- THREE.Camera.call( this );
|
|
|
-
|
|
|
- this.fov = fov;
|
|
|
-
|
|
|
- this.left = -width / 2;
|
|
|
- this.right = width / 2
|
|
|
- this.top = height / 2;
|
|
|
- this.bottom = -height / 2;
|
|
|
-
|
|
|
- // We could also handle the projectionMatrix internally, but just wanted to test nested camera objects
|
|
|
-
|
|
|
- this.cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, orthoNear, orthoFar );
|
|
|
- this.cameraP = new THREE.PerspectiveCamera( fov, width / height, near, far );
|
|
|
-
|
|
|
- this.zoom = 1;
|
|
|
-
|
|
|
- this.toPerspective();
|
|
|
-
|
|
|
- var aspect = width/height;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toPerspective = function () {
|
|
|
-
|
|
|
- // Switches to the Perspective Camera
|
|
|
-
|
|
|
- this.near = this.cameraP.near;
|
|
|
- this.far = this.cameraP.far;
|
|
|
-
|
|
|
- this.cameraP.fov = this.fov / this.zoom ;
|
|
|
-
|
|
|
- this.cameraP.updateProjectionMatrix();
|
|
|
-
|
|
|
- this.projectionMatrix = this.cameraP.projectionMatrix;
|
|
|
-
|
|
|
- this.inPerspectiveMode = true;
|
|
|
- this.inOrthographicMode = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toOrthographic = function () {
|
|
|
-
|
|
|
- // Switches to the Orthographic camera estimating viewport from Perspective
|
|
|
-
|
|
|
- var fov = this.fov;
|
|
|
- var aspect = this.cameraP.aspect;
|
|
|
- var near = this.cameraP.near;
|
|
|
- var far = this.cameraP.far;
|
|
|
-
|
|
|
- // The size that we set is the mid plane of the viewing frustum
|
|
|
-
|
|
|
- var hyperfocus = ( near + far ) / 2;
|
|
|
-
|
|
|
- var halfHeight = Math.tan( fov / 2 ) * hyperfocus;
|
|
|
- var planeHeight = 2 * halfHeight;
|
|
|
- var planeWidth = planeHeight * aspect;
|
|
|
- var halfWidth = planeWidth / 2;
|
|
|
-
|
|
|
- halfHeight /= this.zoom;
|
|
|
- halfWidth /= this.zoom;
|
|
|
-
|
|
|
- this.cameraO.left = -halfWidth;
|
|
|
- this.cameraO.right = halfWidth;
|
|
|
- this.cameraO.top = halfHeight;
|
|
|
- this.cameraO.bottom = -halfHeight;
|
|
|
-
|
|
|
- // this.cameraO.left = -farHalfWidth;
|
|
|
- // this.cameraO.right = farHalfWidth;
|
|
|
- // this.cameraO.top = farHalfHeight;
|
|
|
- // this.cameraO.bottom = -farHalfHeight;
|
|
|
-
|
|
|
- // this.cameraO.left = this.left / this.zoom;
|
|
|
- // this.cameraO.right = this.right / this.zoom;
|
|
|
- // this.cameraO.top = this.top / this.zoom;
|
|
|
- // this.cameraO.bottom = this.bottom / this.zoom;
|
|
|
-
|
|
|
- this.cameraO.updateProjectionMatrix();
|
|
|
-
|
|
|
- this.near = this.cameraO.near;
|
|
|
- this.far = this.cameraO.far;
|
|
|
- this.projectionMatrix = this.cameraO.projectionMatrix;
|
|
|
-
|
|
|
- this.inPerspectiveMode = false;
|
|
|
- this.inOrthographicMode = true;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.setSize = function( width, height ) {
|
|
|
-
|
|
|
- this.cameraP.aspect = width / height;
|
|
|
- this.left = -width / 2;
|
|
|
- this.right = width / 2
|
|
|
- this.top = height / 2;
|
|
|
- this.bottom = -height / 2;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.setFov = function( fov ) {
|
|
|
-
|
|
|
- this.fov = fov;
|
|
|
-
|
|
|
- if ( this.inPerspectiveMode ) {
|
|
|
-
|
|
|
- this.toPerspective();
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.toOrthographic();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-// For mantaining similar API with PerspectiveCamera
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {
|
|
|
-
|
|
|
- if ( this.inPerspectiveMode ) {
|
|
|
-
|
|
|
- this.toPerspective();
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.toPerspective();
|
|
|
- this.toOrthographic();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-/*
|
|
|
-* Uses Focal Length (in mm) to estimate and set FOV
|
|
|
-* 35mm (fullframe) camera is used if frame size is not specified;
|
|
|
-* Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
|
|
|
-*/
|
|
|
-THREE.CombinedCamera.prototype.setLens = function ( focalLength, frameHeight ) {
|
|
|
-
|
|
|
- if ( frameHeight === undefined ) frameHeight = 24;
|
|
|
-
|
|
|
- var fov = 2 * THREE.Math.radToDeg( Math.atan( frameHeight / ( focalLength * 2 ) ) );
|
|
|
-
|
|
|
- this.setFov( fov );
|
|
|
-
|
|
|
- return fov;
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.setZoom = function( zoom ) {
|
|
|
-
|
|
|
- this.zoom = zoom;
|
|
|
-
|
|
|
- if ( this.inPerspectiveMode ) {
|
|
|
-
|
|
|
- this.toPerspective();
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.toOrthographic();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toFrontView = function() {
|
|
|
-
|
|
|
- this.rotation.x = 0;
|
|
|
- this.rotation.y = 0;
|
|
|
- this.rotation.z = 0;
|
|
|
-
|
|
|
- // should we be modifing the matrix instead?
|
|
|
-
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toBackView = function() {
|
|
|
-
|
|
|
- this.rotation.x = 0;
|
|
|
- this.rotation.y = Math.PI;
|
|
|
- this.rotation.z = 0;
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toLeftView = function() {
|
|
|
-
|
|
|
- this.rotation.x = 0;
|
|
|
- this.rotation.y = - Math.PI / 2;
|
|
|
- this.rotation.z = 0;
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toRightView = function() {
|
|
|
-
|
|
|
- this.rotation.x = 0;
|
|
|
- this.rotation.y = Math.PI / 2;
|
|
|
- this.rotation.z = 0;
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toTopView = function() {
|
|
|
-
|
|
|
- this.rotation.x = - Math.PI / 2;
|
|
|
- this.rotation.y = 0;
|
|
|
- this.rotation.z = 0;
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-THREE.CombinedCamera.prototype.toBottomView = function() {
|
|
|
-
|
|
|
- this.rotation.x = Math.PI / 2;
|
|
|
- this.rotation.y = 0;
|
|
|
- this.rotation.z = 0;
|
|
|
- this.rotationAutoUpdate = false;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
|