Browse Source

Merge remote-tracking branch 'gero3/matrixrefactor' into matrix

Mr.doob 13 năm trước cách đây
mục cha
commit
12e000a1ab

+ 17 - 15
src/core/Matrix3.js

@@ -4,7 +4,7 @@
 
 
 THREE.Matrix3 = function () {
 THREE.Matrix3 = function () {
 
 
-	this.m = [];
+	this.elements = new Float32Array(9);
 
 
 };
 };
 
 
@@ -17,17 +17,19 @@ THREE.Matrix3.prototype = {
 		// input: THREE.Matrix4
 		// input: THREE.Matrix4
 		// ( based on http://code.google.com/p/webgl-mjs/ )
 		// ( based on http://code.google.com/p/webgl-mjs/ )
 
 
-		var a11 =   matrix.n33 * matrix.n22 - matrix.n32 * matrix.n23;
-		var a21 = - matrix.n33 * matrix.n21 + matrix.n31 * matrix.n23;
-		var a31 =   matrix.n32 * matrix.n21 - matrix.n31 * matrix.n22;
-		var a12 = - matrix.n33 * matrix.n12 + matrix.n32 * matrix.n13;
-		var a22 =   matrix.n33 * matrix.n11 - matrix.n31 * matrix.n13;
-		var a32 = - matrix.n32 * matrix.n11 + matrix.n31 * matrix.n12;
-		var a13 =   matrix.n23 * matrix.n12 - matrix.n22 * matrix.n13;
-		var a23 = - matrix.n23 * matrix.n11 + matrix.n21 * matrix.n13;
-		var a33 =   matrix.n22 * matrix.n11 - matrix.n21 * matrix.n12;
+        var me = matrix.elements;
+        
+		var a11 =   me[10] * me[5] - me[6] * me[9];
+		var a21 = - me[10] * me[1] + me[2] * me[9];
+		var a31 =   me[6] * me[1] - me[2] * me[5];
+		var a12 = - me[10] * me[4] + me[6] * me[8];
+		var a22 =   me[10] * me[0] - me[2] * me[8];
+		var a32 = - me[6] * me[0] + me[2] * me[4];
+		var a13 =   me[9] * me[4] - me[5] * me[8];
+		var a23 = - me[9] * me[0] + me[1] * me[8];
+		var a33 =   me[5] * me[0] - me[1] * me[4];
 
 
-		var det = matrix.n11 * a11 + matrix.n21 * a12 + matrix.n31 * a13;
+		var det = me[0] * a11 + me[1] * a12 + me[2] * a13;
 
 
 		// no inverse
 		// no inverse
 
 
@@ -39,7 +41,7 @@ THREE.Matrix3.prototype = {
 
 
 		var idet = 1.0 / det;
 		var idet = 1.0 / det;
 
 
-		var m = this.m;
+		var m = this.elements;
 
 
 		m[ 0 ] = idet * a11; m[ 1 ] = idet * a21; m[ 2 ] = idet * a31;
 		m[ 0 ] = idet * a11; m[ 1 ] = idet * a21; m[ 2 ] = idet * a31;
 		m[ 3 ] = idet * a12; m[ 4 ] = idet * a22; m[ 5 ] = idet * a32;
 		m[ 3 ] = idet * a12; m[ 4 ] = idet * a22; m[ 5 ] = idet * a32;
@@ -49,10 +51,10 @@ THREE.Matrix3.prototype = {
 
 
 	},
 	},
 
 
-	/*
+	
 	transpose: function () {
 	transpose: function () {
 
 
-		var tmp, m = this.m;
+		var tmp, m = this.elements;
 
 
 		tmp = m[1]; m[1] = m[3]; m[3] = tmp;
 		tmp = m[1]; m[1] = m[3]; m[3] = tmp;
 		tmp = m[2]; m[2] = m[6]; m[6] = tmp;
 		tmp = m[2]; m[2] = m[6]; m[6] = tmp;
@@ -61,7 +63,7 @@ THREE.Matrix3.prototype = {
 		return this;
 		return this;
 
 
 	},
 	},
-	*/
+	
 
 
 	transposeIntoArray: function ( r ) {
 	transposeIntoArray: function ( r ) {
 
 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 350 - 318
src/core/Matrix4.js


+ 3 - 3
src/core/Projector.js

@@ -367,7 +367,7 @@ THREE.Projector = function() {
 
 
 			if ( object instanceof THREE.Particle ) {
 			if ( object instanceof THREE.Particle ) {
 
 
-				_vector4.set( objectMatrixWorld.n14, objectMatrixWorld.n24, objectMatrixWorld.n34, 1 );
+				_vector4.set( objectMatrixWorld.elements[12], objectMatrixWorld.elements[13], objectMatrixWorld.elements[14], 1 );
 				_projScreenMatrix.multiplyVector4( _vector4 );
 				_projScreenMatrix.multiplyVector4( _vector4 );
 
 
 				_vector4.z /= _vector4.w;
 				_vector4.z /= _vector4.w;
@@ -381,8 +381,8 @@ THREE.Projector = function() {
 
 
 					_particle.rotation = object.rotation.z;
 					_particle.rotation = object.rotation.z;
 
 
-					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) );
-					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) );
+					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.elements[0] ) / ( _vector4.w + camera.projectionMatrix.elements[12] ) );
+					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.elements[5] ) / ( _vector4.w + camera.projectionMatrix.elements[13] ) );
 
 
 					_particle.material = object.material;
 					_particle.material = object.material;
 
 

+ 7 - 7
src/core/Quaternion.js

@@ -92,13 +92,13 @@ THREE.Quaternion.prototype = {
 		}
 		}
 
 
 		var absQ = Math.pow( m.determinant(), 1.0 / 3.0 );
 		var absQ = Math.pow( m.determinant(), 1.0 / 3.0 );
-		this.w = Math.sqrt( Math.max( 0, absQ + m.n11 + m.n22 + m.n33 ) ) / 2;
-		this.x = Math.sqrt( Math.max( 0, absQ + m.n11 - m.n22 - m.n33 ) ) / 2;
-		this.y = Math.sqrt( Math.max( 0, absQ - m.n11 + m.n22 - m.n33 ) ) / 2;
-		this.z = Math.sqrt( Math.max( 0, absQ - m.n11 - m.n22 + m.n33 ) ) / 2;
-		this.x = copySign( this.x, ( m.n32 - m.n23 ) );
-		this.y = copySign( this.y, ( m.n13 - m.n31 ) );
-		this.z = copySign( this.z, ( m.n21 - m.n12 ) );
+		this.w = Math.sqrt( Math.max( 0, absQ + m.elements[0] + m.elements[5] + m.elements[10] ) ) / 2;
+		this.x = Math.sqrt( Math.max( 0, absQ + m.elements[0] - m.elements[5] - m.elements[10] ) ) / 2;
+		this.y = Math.sqrt( Math.max( 0, absQ - m.elements[0] + m.elements[5] - m.elements[10] ) ) / 2;
+		this.z = Math.sqrt( Math.max( 0, absQ - m.elements[0] - m.elements[5] + m.elements[10] ) ) / 2;
+		this.x = copySign( this.x, ( m.elements[6] - m.elements[9] ) );
+		this.y = copySign( this.y, ( m.elements[8] - m.elements[2] ) );
+		this.z = copySign( this.z, ( m.elements[1] - m.elements[4] ) );
 		this.normalize();
 		this.normalize();
 
 
 		return this;
 		return this;

+ 9 - 9
src/core/Vector3.js

@@ -262,9 +262,9 @@ THREE.Vector3.prototype = {
 
 
 	getPositionFromMatrix: function ( m ) {
 	getPositionFromMatrix: function ( m ) {
 
 
-		this.x = m.n14;
-		this.y = m.n24;
-		this.z = m.n34;
+		this.x = m.elements[12];
+		this.y = m.elements[13];
+		this.z = m.elements[14];
 
 
 		return this;
 		return this;
 
 
@@ -276,9 +276,9 @@ THREE.Vector3.prototype = {
 		var sy = scale ? scale.y : 1;
 		var sy = scale ? scale.y : 1;
 		var sz = scale ? scale.z : 1;
 		var sz = scale ? scale.z : 1;
 
 
-		var m11 = m.n11 / sx, m12 = m.n12 / sy, m13 = m.n13 / sz;
-		var m21 = m.n21 / sx, m22 = m.n22 / sy, m23 = m.n23 / sz;
-		var m33 = m.n33 / sz;
+		var m11 = m.elements[0] / sx, m12 = m.elements[4] / sy, m13 = m.elements[8] / sz;
+		var m21 = m.elements[1] / sx, m22 = m.elements[5] / sy, m23 = m.elements[9] / sz;
+		var m33 = m.elements[10] / sz;
 
 
 		this.y = Math.asin( m13 );
 		this.y = Math.asin( m13 );
 
 
@@ -355,9 +355,9 @@ THREE.Vector3.prototype = {
 
 
 	getScaleFromMatrix: function ( m ) {
 	getScaleFromMatrix: function ( m ) {
 
 
-		var sx = this.set( m.n11, m.n21, m.n31 ).length();
-		var sy = this.set( m.n12, m.n22, m.n32 ).length();
-		var sz = this.set( m.n13, m.n23, m.n33 ).length();
+		var sx = this.set( m.elements[0], m.elements[1], m.elements[2] ).length();
+		var sy = this.set( m.elements[4], m.elements[5], m.elements[6] ).length();
+		var sz = this.set( m.elements[8], m.elements[9], m.elements[10] ).length();
 
 
 		this.x = sx;
 		this.x = sx;
 		this.y = sy;
 		this.y = sy;

+ 19 - 19
src/extras/controls/RollControls.js

@@ -89,15 +89,15 @@ THREE.RollControls = function ( object, domElement ) {
 		xTemp.cross( yTemp, zTemp ).normalize();
 		xTemp.cross( yTemp, zTemp ).normalize();
 		yTemp.cross( zTemp, xTemp ).normalize();
 		yTemp.cross( zTemp, xTemp ).normalize();
 
 
-		this.object.matrix.n11 = xTemp.x; this.object.matrix.n12 = yTemp.x; this.object.matrix.n13 = zTemp.x;
-		this.object.matrix.n21 = xTemp.y; this.object.matrix.n22 = yTemp.y; this.object.matrix.n23 = zTemp.y;
-		this.object.matrix.n31 = xTemp.z; this.object.matrix.n32 = yTemp.z; this.object.matrix.n33 = zTemp.z;
+		this.object.matrix.elements[0] = xTemp.x; this.object.matrix.elements[4] = yTemp.x; this.object.matrix.elements[8] = zTemp.x;
+		this.object.matrix.elements[1] = xTemp.y; this.object.matrix.elements[5] = yTemp.y; this.object.matrix.elements[9] = zTemp.y;
+		this.object.matrix.elements[2] = xTemp.z; this.object.matrix.elements[6] = yTemp.z; this.object.matrix.elements[10] = zTemp.z;
 
 
 		// calculate roll matrix
 		// calculate roll matrix
 
 
 		rollMatrix.identity();
 		rollMatrix.identity();
-		rollMatrix.n11 = Math.cos( this.roll ); rollMatrix.n12 = -Math.sin( this.roll );
-		rollMatrix.n21 = Math.sin( this.roll ); rollMatrix.n22 =  Math.cos( this.roll );
+		rollMatrix.elements[0] = Math.cos( this.roll ); rollMatrix.elements[4] = -Math.sin( this.roll );
+		rollMatrix.elements[1] = Math.sin( this.roll ); rollMatrix.elements[5] =  Math.cos( this.roll );
 
 
 		// multiply camera with roll
 		// multiply camera with roll
 
 
@@ -106,34 +106,34 @@ THREE.RollControls = function ( object, domElement ) {
 
 
 		// set position
 		// set position
 
 
-		this.object.matrix.n14 = this.object.position.x;
-		this.object.matrix.n24 = this.object.position.y;
-		this.object.matrix.n34 = this.object.position.z;
+		this.object.matrix.elements[12] = this.object.position.x;
+		this.object.matrix.elements[13] = this.object.position.y;
+		this.object.matrix.elements[14] = this.object.position.z;
 
 
 
 
 	};
 	};
 
 
 	this.translateX = function ( distance ) {
 	this.translateX = function ( distance ) {
 
 
-		this.object.position.x += this.object.matrix.n11 * distance;
-		this.object.position.y += this.object.matrix.n21 * distance;
-		this.object.position.z += this.object.matrix.n31 * distance;
+		this.object.position.x += this.object.matrix.elements[0] * distance;
+		this.object.position.y += this.object.matrix.elements[1] * distance;
+		this.object.position.z += this.object.matrix.elements[2] * distance;
 
 
 	};
 	};
 
 
 	this.translateY = function ( distance ) {
 	this.translateY = function ( distance ) {
 
 
-		this.object.position.x += this.object.matrix.n12 * distance;
-		this.object.position.y += this.object.matrix.n22 * distance;
-		this.object.position.z += this.object.matrix.n32 * distance;
+		this.object.position.x += this.object.matrix.elements[4] * distance;
+		this.object.position.y += this.object.matrix.elements[5] * distance;
+		this.object.position.z += this.object.matrix.elements[6] * distance;
 
 
 	};
 	};
 
 
 	this.translateZ = function ( distance ) {
 	this.translateZ = function ( distance ) {
 
 
-		this.object.position.x -= this.object.matrix.n13 * distance;
-		this.object.position.y -= this.object.matrix.n23 * distance;
-		this.object.position.z -= this.object.matrix.n33 * distance;
+		this.object.position.x -= this.object.matrix.elements[8] * distance;
+		this.object.position.y -= this.object.matrix.elements[9] * distance;
+		this.object.position.z -= this.object.matrix.elements[10] * distance;
 
 
 	};
 	};
 
 
@@ -142,7 +142,7 @@ THREE.RollControls = function ( object, domElement ) {
 
 
 		// please note that the amount is NOT degrees, but a scale value
 		// please note that the amount is NOT degrees, but a scale value
 
 
-		xTemp.set( this.object.matrix.n11, this.object.matrix.n21, this.object.matrix.n31 );
+		xTemp.set( this.object.matrix.elements[0], this.object.matrix.elements[1], this.object.matrix.elements[2] );
 		xTemp.multiplyScalar( amount );
 		xTemp.multiplyScalar( amount );
 
 
 		this.forward.subSelf( xTemp );
 		this.forward.subSelf( xTemp );
@@ -154,7 +154,7 @@ THREE.RollControls = function ( object, domElement ) {
 
 
 		// please note that the amount is NOT degrees, but a scale value
 		// please note that the amount is NOT degrees, but a scale value
 
 
-		yTemp.set( this.object.matrix.n12, this.object.matrix.n22, this.object.matrix.n32 );
+		yTemp.set( this.object.matrix.elements[4], this.object.matrix.elements[5], this.object.matrix.elements[6] );
 		yTemp.multiplyScalar( amount );
 		yTemp.multiplyScalar( amount );
 
 
 		this.forward.addSelf( yTemp );
 		this.forward.addSelf( yTemp );

+ 6 - 6
src/extras/renderers/AnaglyphWebGLRenderer.js

@@ -126,16 +126,16 @@ if ( THREE.WebGLRenderer ) {
 
 
 				// translate xOffset
 				// translate xOffset
 
 
-				eyeRight.n14 = eyeSep;
-				eyeLeft.n14 = -eyeSep;
+				eyeRight.elements[12] = eyeSep;
+				eyeLeft.elements[12] = -eyeSep;
 
 
 				// for left eye
 				// for left eye
 
 
 				xmin = -ymax * _aspect + eyeSepOnProjection;
 				xmin = -ymax * _aspect + eyeSepOnProjection;
 				xmax = ymax * _aspect + eyeSepOnProjection;
 				xmax = ymax * _aspect + eyeSepOnProjection;
 
 
-				projectionMatrix.n11 = 2 * _near / ( xmax - xmin );
-				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin );
+				projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin );
 
 
 				_cameraL.projectionMatrix.copy( projectionMatrix );
 				_cameraL.projectionMatrix.copy( projectionMatrix );
 
 
@@ -144,8 +144,8 @@ if ( THREE.WebGLRenderer ) {
 				xmin = -ymax * _aspect - eyeSepOnProjection;
 				xmin = -ymax * _aspect - eyeSepOnProjection;
 				xmax = ymax * _aspect - eyeSepOnProjection;
 				xmax = ymax * _aspect - eyeSepOnProjection;
 
 
-				projectionMatrix.n11 = 2 * _near / ( xmax - xmin );
-				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin );
+				projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin );
 
 
 				_cameraR.projectionMatrix.copy( projectionMatrix );
 				_cameraR.projectionMatrix.copy( projectionMatrix );
 
 

+ 6 - 6
src/extras/renderers/ParallaxBarrierWebGLRenderer.js

@@ -128,16 +128,16 @@ if ( THREE.WebGLRenderer ) {
 
 
 				// translate xOffset
 				// translate xOffset
 
 
-				eyeRight.n14 = eyeSep;
-				eyeLeft.n14 = -eyeSep;
+				eyeRight.elements[12] = eyeSep;
+				eyeLeft.elements[12] = -eyeSep;
 
 
 				// for left eye
 				// for left eye
 
 
 				xmin = -ymax * _aspect + eyeSepOnProjection;
 				xmin = -ymax * _aspect + eyeSepOnProjection;
 				xmax = ymax * _aspect + eyeSepOnProjection;
 				xmax = ymax * _aspect + eyeSepOnProjection;
 
 
-				projectionMatrix.n11 = 2 * _near / ( xmax - xmin );
-				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin );
+				projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin );
 
 
 				_cameraL.projectionMatrix.copy( projectionMatrix );
 				_cameraL.projectionMatrix.copy( projectionMatrix );
 
 
@@ -146,8 +146,8 @@ if ( THREE.WebGLRenderer ) {
 				xmin = -ymax * _aspect - eyeSepOnProjection;
 				xmin = -ymax * _aspect - eyeSepOnProjection;
 				xmax = ymax * _aspect - eyeSepOnProjection;
 				xmax = ymax * _aspect - eyeSepOnProjection;
 
 
-				projectionMatrix.n11 = 2 * _near / ( xmax - xmin );
-				projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin );
+				projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin );
+				projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin );
 
 
 				_cameraR.projectionMatrix.copy( projectionMatrix );
 				_cameraR.projectionMatrix.copy( projectionMatrix );
 
 

+ 4 - 4
src/extras/renderers/plugins/DepthPassPlugin.js

@@ -92,8 +92,8 @@ THREE.DepthPassPlugin = function ( ) {
 
 
 				if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 				if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 
 
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
-					object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
+					//object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					object._modelViewMatrix.multiply( camera.matrixWorldInverse, object.matrixWorld);
 
 
 					webglObject.render = true;
 					webglObject.render = true;
 
 
@@ -157,11 +157,11 @@ THREE.DepthPassPlugin = function ( ) {
 
 
 				if( object.matrixAutoUpdate ) {
 				if( object.matrixAutoUpdate ) {
 
 
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					//object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
 				}
 				}
 
 
-				object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
+				object._modelViewMatrix.multiply( camera.matrixWorldInverse, object.matrixWorld);
 
 
 				_renderer.renderImmediateObject( camera, scene.__lights, fog, _depthMaterial, object );
 				_renderer.renderImmediateObject( camera, scene.__lights, fog, _depthMaterial, object );
 
 

+ 1 - 1
src/extras/renderers/plugins/LensFlarePlugin.js

@@ -164,7 +164,7 @@ THREE.LensFlarePlugin = function ( ) {
 
 
 			flare = flares[ i ];
 			flare = flares[ i ];
 
 
-			tempPosition.set( flare.matrixWorld.n14, flare.matrixWorld.n24, flare.matrixWorld.n34 );
+			tempPosition.set( flare.matrixWorld.elements[12], flare.matrixWorld.elements[13], flare.matrixWorld.elements[14] );
 
 
 			camera.matrixWorldInverse.multiplyVector3( tempPosition );
 			camera.matrixWorldInverse.multiplyVector3( tempPosition );
 			camera.projectionMatrix.multiplyVector3( tempPosition );
 			camera.projectionMatrix.multiplyVector3( tempPosition );

+ 4 - 4
src/extras/renderers/plugins/ShadowMapPlugin.js

@@ -222,8 +222,8 @@ THREE.ShadowMapPlugin = function ( ) {
 
 
 					if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 					if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 
 
-						object.matrixWorld.flattenToArray( object._objectMatrixArray );
-						object._modelViewMatrix.multiplyToArray( shadowCamera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
+						//object.matrixWorld.flattenToArray( object._objectMatrixArray );
+						object._modelViewMatrix.multiply( shadowCamera.matrixWorldInverse, object.matrixWorld);
 
 
 						webglObject.render = true;
 						webglObject.render = true;
 
 
@@ -287,11 +287,11 @@ THREE.ShadowMapPlugin = function ( ) {
 
 
 					if( object.matrixAutoUpdate ) {
 					if( object.matrixAutoUpdate ) {
 
 
-						object.matrixWorld.flattenToArray( object._objectMatrixArray );
+						//object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
 					}
 					}
 
 
-					object._modelViewMatrix.multiplyToArray( shadowCamera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
+					object._modelViewMatrix.multiply( shadowCamera.matrixWorldInverse, object.matrixWorld);
 
 
 					_renderer.renderImmediateObject( shadowCamera, scene.__lights, fog, _depthMaterial, object );
 					_renderer.renderImmediateObject( shadowCamera, scene.__lights, fog, _depthMaterial, object );
 
 

+ 3 - 3
src/extras/renderers/plugins/SpritePlugin.js

@@ -129,8 +129,8 @@ THREE.SpritePlugin = function ( ) {
 
 
 			if( ! sprite.useScreenCoordinates ) {
 			if( ! sprite.useScreenCoordinates ) {
 
 
-				sprite._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, sprite.matrixWorld, sprite._modelViewMatrixArray );
-				sprite.z = - sprite._modelViewMatrix.n34;
+				sprite._modelViewMatrix.multiply( camera.matrixWorldInverse, sprite.matrixWorld);
+				sprite.z = - sprite._modelViewMatrix.elements[14];
 
 
 			} else {
 			} else {
 
 
@@ -163,7 +163,7 @@ THREE.SpritePlugin = function ( ) {
 
 
 					_gl.uniform1i( uniforms.useScreenCoordinates, 0 );
 					_gl.uniform1i( uniforms.useScreenCoordinates, 0 );
 					_gl.uniform1i( uniforms.affectedByDistance, sprite.affectedByDistance ? 1 : 0 );
 					_gl.uniform1i( uniforms.affectedByDistance, sprite.affectedByDistance ? 1 : 0 );
-					_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, sprite._modelViewMatrixArray );
+					_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, sprite._modelViewMatrix.elements);
 
 
 				}
 				}
 
 

+ 1 - 1
src/objects/LOD.js

@@ -48,7 +48,7 @@ THREE.LOD.prototype.update = function ( camera ) {
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 
 
 		var inverse  = camera.matrixWorldInverse;
 		var inverse  = camera.matrixWorldInverse;
-		var distance = -( inverse.n31 * this.matrixWorld.n14 + inverse.n32 * this.matrixWorld.n24 + inverse.n33 * this.matrixWorld.n34 + inverse.n34 );
+		var distance = -( inverse.elements[2] * this.matrixWorld.elements[12] + inverse.elements[6] * this.matrixWorld.elements[13] + inverse.elements[10] * this.matrixWorld.elements[14] + inverse.elements[14] );
 
 
 		this.LODs[ 0 ].object3D.visible = true;
 		this.LODs[ 0 ].object3D.visible = true;
 
 

+ 6 - 6
src/renderers/CanvasRenderer.js

@@ -546,16 +546,16 @@ THREE.CanvasRenderer = function ( parameters ) {
 						var cameraMatrix = camera.matrixWorldInverse;
 						var cameraMatrix = camera.matrixWorldInverse;
 
 
 						_vector3.copy( element.vertexNormalsWorld[ uv1 ] );
 						_vector3.copy( element.vertexNormalsWorld[ uv1 ] );
-						_uv1x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
-						_uv1y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
+						_uv1x = ( _vector3.x * cameraMatrix.elements[0] + _vector3.y * cameraMatrix.elements[4] + _vector3.z * cameraMatrix.elements[8] ) * 0.5 + 0.5;
+						_uv1y = - ( _vector3.x * cameraMatrix.elements[1] + _vector3.y * cameraMatrix.elements[5] + _vector3.z * cameraMatrix.elements[9] ) * 0.5 + 0.5;
 
 
 						_vector3.copy( element.vertexNormalsWorld[ uv2 ] );
 						_vector3.copy( element.vertexNormalsWorld[ uv2 ] );
-						_uv2x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
-						_uv2y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
+						_uv2x = ( _vector3.x * cameraMatrix.elements[0] + _vector3.y * cameraMatrix.elements[4] + _vector3.z * cameraMatrix.elements[8] ) * 0.5 + 0.5;
+						_uv2y = - ( _vector3.x * cameraMatrix.elements[1] + _vector3.y * cameraMatrix.elements[5] + _vector3.z * cameraMatrix.elements[9] ) * 0.5 + 0.5;
 
 
 						_vector3.copy( element.vertexNormalsWorld[ uv3 ] );
 						_vector3.copy( element.vertexNormalsWorld[ uv3 ] );
-						_uv3x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
-						_uv3y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
+						_uv3x = ( _vector3.x * cameraMatrix.elements[0] + _vector3.y * cameraMatrix.elements[4] + _vector3.z * cameraMatrix.elements[8] ) * 0.5 + 0.5;
+						_uv3y = - ( _vector3.x * cameraMatrix.elements[1] + _vector3.y * cameraMatrix.elements[5] + _vector3.z * cameraMatrix.elements[9] ) * 0.5 + 0.5;
 
 
 						patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y, material.envMap );
 						patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y, material.envMap );
 
 

+ 11 - 11
src/renderers/WebGLRenderer.js

@@ -3370,7 +3370,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				if ( ! ( object instanceof THREE.Mesh || object instanceof THREE.ParticleSystem ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 				if ( ! ( object instanceof THREE.Mesh || object instanceof THREE.ParticleSystem ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 
 
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					//object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
 					setupMatrices( object, camera );
 					setupMatrices( object, camera );
 
 
@@ -3420,7 +3420,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				if( object.matrixAutoUpdate ) {
 				if( object.matrixAutoUpdate ) {
 
 
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					//object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
 				}
 				}
 
 
@@ -3827,11 +3827,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 			object._modelViewMatrix = new THREE.Matrix4();
 			object._modelViewMatrix = new THREE.Matrix4();
 			object._normalMatrix = new THREE.Matrix3();
 			object._normalMatrix = new THREE.Matrix3();
 
 
-			object._normalMatrixArray = new Float32Array( 9 );
-			object._modelViewMatrixArray = new Float32Array( 16 );
-			object._objectMatrixArray = new Float32Array( 16 );
+			//object._normalMatrixArray = new Float32Array( 9 );
+			//object._modelViewMatrixArray = new Float32Array( 16 );
+			//object._objectMatrixArray = new Float32Array( 16 );
 
 
-			object.matrixWorld.flattenToArray( object._objectMatrixArray );
+			//object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
 			if ( object instanceof THREE.Mesh ) {
 			if ( object instanceof THREE.Mesh ) {
 
 
@@ -4519,7 +4519,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			if ( p_uniforms.objectMatrix !== null ) {
 			if ( p_uniforms.objectMatrix !== null ) {
 
 
-				_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
+				_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object.matrixWorld.elements );
 
 
 			}
 			}
 
 
@@ -4707,11 +4707,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	function loadUniformsMatrices ( uniforms, object ) {
 	function loadUniformsMatrices ( uniforms, object ) {
 
 
-		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
+		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrix.elements );
 
 
 		if ( uniforms.normalMatrix ) {
 		if ( uniforms.normalMatrix ) {
 
 
-			_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray );
+			_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrix.elements );
 
 
 		}
 		}
 
 
@@ -4937,10 +4937,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	function setupMatrices ( object, camera ) {
 	function setupMatrices ( object, camera ) {
 
 
-		object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
+		object._modelViewMatrix.multiply( camera.matrixWorldInverse, object.matrixWorld);
 
 
 		object._normalMatrix.getInverse( object._modelViewMatrix );
 		object._normalMatrix.getInverse( object._modelViewMatrix );
-		object._normalMatrix.transposeIntoArray( object._normalMatrixArray );
+		object._normalMatrix.transpose();
 
 
 	};
 	};
 
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác