From 390b2147494a6d607cef7c7aed3adc4333375bd9 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 24 Feb 2013 07:54:07 +0100 Subject: [PATCH] Updated builds. --- build/three.js | 92 +++++++++++++++++++++++++++++++--------------- build/three.min.js | 19 +++++----- 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/build/three.js b/build/three.js index 07c4477017..4f9a64ccd9 100644 --- a/build/three.js +++ b/build/three.js @@ -594,6 +594,12 @@ THREE.extend( THREE.Color.prototype, { }, + equals: function ( c ) { + + return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b ); + + }, + clone: function () { return new THREE.Color().setRGB( this.r, this.g, this.b ); @@ -6203,6 +6209,7 @@ THREE.EventDispatcher = function () { * @author mrdoob / http://mrdoob.com/ * @author mikael emtinger / http://gomo.se/ * @author alteredq / http://alteredqualia.com/ + * @author WestLangley / http://github.com/WestLangley */ THREE.Object3D = function () { @@ -6252,18 +6259,33 @@ THREE.Object3D.prototype = { constructor: THREE.Object3D, - applyMatrix: function ( matrix ) { + applyMatrix: function () { - this.matrix.multiplyMatrices( matrix, this.matrix ); + var m1 = new THREE.Matrix4(); - this.scale.getScaleFromMatrix( this.matrix ); + return function ( matrix ) { - var mat = new THREE.Matrix4().extractRotation( this.matrix ); - this.rotation.setEulerFromRotationMatrix( mat, this.eulerOrder ); + this.matrix.multiplyMatrices( matrix, this.matrix ); - this.position.getPositionFromMatrix( this.matrix ); + this.position.getPositionFromMatrix( this.matrix ); - }, + this.scale.getScaleFromMatrix( this.matrix ); + + m1.extractRotation( this.matrix ); + + if ( this.useQuaternion === true ) { + + this.quaternion.setFromRotationMatrix( m1 ); + + } else { + + this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder ); + + } + + } + + }(), translate: function ( distance, axis ) { @@ -6296,33 +6318,41 @@ THREE.Object3D.prototype = { }, - worldToLocal: function ( vector ) { + worldToLocal: function () { - return vector.applyMatrix4( THREE.Object3D.__m1.getInverse( this.matrixWorld ) ); + var m1 = new THREE.Matrix4(); - }, + return function ( vector ) { + + return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) ); + + }; - lookAt: function ( vector ) { + }(), - // TODO: Add hierarchy support. + lookAt: function () { - this.matrix.lookAt( vector, this.position, this.up ); + // This routine does not support objects with rotated and/or translated parent(s) - if ( this.rotationAutoUpdate ) { + var m1 = new THREE.Matrix4(); - if ( this.useQuaternion === false ) { + return function ( vector ) { - this.rotation.setEulerFromRotationMatrix( this.matrix, this.eulerOrder ); + m1.lookAt( vector, this.position, this.up ); + + if ( this.useQuaternion === true ) { + + this.quaternion.setFromRotationMatrix( m1 ); } else { - this.quaternion.copy( this.matrix.decompose()[ 1 ] ); + this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder ); } - } + }; - }, + }(), add: function ( object ) { @@ -6554,7 +6584,6 @@ THREE.Object3D.prototype = { }; -THREE.Object3D.__m1 = new THREE.Matrix4(); THREE.Object3D.defaultEulerOrder = 'XYZ', THREE.Object3DIdCount = 0; @@ -8680,7 +8709,8 @@ THREE.BufferGeometry.prototype = { /** * @author mrdoob / http://mrdoob.com/ * @author mikael emtinger / http://gomo.se/ - */ + * @author WestLangley / http://github.com/WestLangley +*/ THREE.Camera = function () { @@ -8695,27 +8725,29 @@ THREE.Camera = function () { THREE.Camera.prototype = Object.create( THREE.Object3D.prototype ); -THREE.Camera.prototype.lookAt = function ( vector ) { +THREE.Camera.prototype.lookAt = function () { - // TODO: Add hierarchy support. + // This routine does not support cameras with rotated and/or translated parent(s) - this.matrix.lookAt( this.position, vector, this.up ); + var m1 = new THREE.Matrix4(); - if ( this.rotationAutoUpdate === true ) { + return function ( vector ) { - if ( this.useQuaternion === false ) { + m1.lookAt( this.position, vector, this.up ); - this.rotation.setEulerFromRotationMatrix( this.matrix, this.eulerOrder ); + if ( this.useQuaternion === true ) { + + this.quaternion.setFromRotationMatrix( m1 ); } else { - this.quaternion.copy( this.matrix.decompose()[ 1 ] ); + this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder ); } - } + }; -}; +}(); /** * @author alteredq / http://alteredqualia.com/ */ diff --git a/build/three.min.js b/build/three.min.js index 0fb0b73271..5d9b54d7ac 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -13,7 +13,7 @@ b,c){if(0===b)this.r=this.g=this.b=c;else{var d=function(a,b,c){0>c&&(c+=1);1=h?i/(e+f):i/(2-e-f);switch(e){case b:g=(c-d)/i+(ce&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d< +THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(){var a=new THREE.Matrix4;return function(b){this.matrix.multiplyMatrices(b,this.matrix);this.position.getPositionFromMatrix(this.matrix);this.scale.getScaleFromMatrix(this.matrix);a.extractRotation(this.matrix);!0===this.useQuaternion?this.quaternion.setFromRotationMatrix(a):this.rotation.setEulerFromRotationMatrix(a,this.eulerOrder)}}(),translate:function(a,b){this.matrix.rotateAxis(b);this.position.add(b.multiplyScalar(a))}, +translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new THREE.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),lookAt:function(){var a=new THREE.Matrix4;return function(b){a.lookAt(b,this.position,this.up);!0===this.useQuaternion? +this.quaternion.setFromRotationMatrix(a):this.rotation.setEulerFromRotationMatrix(a,this.eulerOrder)}}(),add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(a instanceof THREE.Object3D){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(-1!==b){a.parent=void 0; +this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__removeObject(a)}},traverse:function(a){a(this);for(var b=0,c=this.children.length;be&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d< c)return!1;a.lerp(b,c);b.lerp(a,1-d);return!0}var e,f,g=[],h=0,i,k,l=[],m=0,n,s,r=[],p=0,q,y=[],v=0,z,t,A=[],I=0,B,x,G=[],J=0,E={objects:[],sprites:[],lights:[],elements:[]},H=new THREE.Vector3,C=new THREE.Vector4,W=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),F=new THREE.Box3,K=Array(3),L=Array(4),U=new THREE.Matrix4,da=new THREE.Matrix4,Fa,Pa=new THREE.Matrix4,M=new THREE.Matrix3,ea=new THREE.Matrix3,wa=new THREE.Vector3,ia=new THREE.Frustum,sa=new THREE.Vector4,N=new THREE.Vector4; this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);da.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);return a.applyProjection(da)};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);da.multiplyMatrices(b.matrixWorld,b.projectionMatrixInverse);return a.applyProjection(da)};this.pickingRay=function(a,b){a.z=-1;var c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.sub(a).normalize();return new THREE.Raycaster(a, c)};this.projectScene=function(g,h,m,Oa){var Ea=!1,ma,ga,pa,Y,ba,ja,Z,qa,bb,mb,ha,cb,Va;x=t=q=s=0;E.elements.length=0;g.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();U.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));da.multiplyMatrices(h.projectionMatrix,U);ea.getInverse(U);ea.transpose();ia.setFromMatrix(da);f=0;E.objects.length=0;E.sprites.length=0;E.lights.length=0;var Wa=function(b){for(var c=0,d=b.children.length;cwa?-1:1;h[4*a]=U.x;h[4*a+1]=U.y;h[4*a+2]=U.z;h[4*a+3]=M}if(void 0===this.attributes.index||void 0===this.attributes.position|| void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array,i=[],k=[],g=0;g