Browse Source

Some space to tabs changes in Matrix4. Updated Matrix4 doc.

Mr.doob 13 years ago
parent
commit
df83164eac
2 changed files with 90 additions and 95 deletions
  1. 2 32
      docs/api/core/Matrix4.html
  2. 88 63
      src/core/Matrix4.js

+ 2 - 32
docs/api/core/Matrix4.html

@@ -33,37 +33,7 @@ m.multiplySelf( m3 );
 
 <h2>Properties</h2>
 
-<h3>.[page:Float n11]</h3>
-
-<h3>.[page:Float n12]</h3>
-
-<h3>.[page:Float n13]</h3>
-
-<h3>.[page:Float n14]</h3>
-
-<h3>.[page:Float n21]</h3>
-
-<h3>.[page:Float n22]</h3>
-
-<h3>.[page:Float n23]</h3>
-
-<h3>.[page:Float n24]</h3>
-
-<h3>.[page:Float n31]</h3>
-
-<h3>.[page:Float n32]</h3>
-
-<h3>.[page:Float n33]</h3>
-
-<h3>.[page:Float n34]</h3>
-
-<h3>.[page:Float n41]</h3>
-
-<h3>.[page:Float n42]</h3>
-
-<h3>.[page:Float n43]</h3>
-
-<h3>.[page:Float n44]</h3>
+<h3>.[page:Float32Array elements]</h3>
 
 
 <h2>Methods</h2>
@@ -329,4 +299,4 @@ Creates orthographic projection matrix.
 
 <h2>Source</h2>
 
-[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 88 - 63
src/core/Matrix4.js

@@ -12,7 +12,7 @@
 
 THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 
-    this.elements = new Float32Array(16);
+	this.elements = new Float32Array( 16 );
 
 	this.set(
 
@@ -30,8 +30,9 @@ THREE.Matrix4.prototype = {
 	constructor: THREE.Matrix4,
 
 	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		te[0] = n11; te[4] = n12; te[8] = n13; te[12] = n14;
 		te[1] = n21; te[5] = n22; te[9] = n23; te[13] = n24;
 		te[2] = n31; te[6] = n32; te[10] = n33; te[14] = n34;
@@ -57,9 +58,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	copy: function ( m ) {
-        
-        var me = m.elements;
-        
+
+		var me = m.elements;
+
 		this.set(
 
 			me[0], me[4], me[8], me[12],
@@ -74,8 +75,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	lookAt: function ( eye, target, up ) {
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		var x = THREE.Matrix4.__v1;
 		var y = THREE.Matrix4.__v2;
 		var z = THREE.Matrix4.__v3;
@@ -109,10 +111,10 @@ THREE.Matrix4.prototype = {
 	},
 
 	multiply: function ( a, b ) {
-        
-        var ae = a.elements,
-            be = b.elements,
-            te = this.elements;
+
+		var ae = a.elements;
+		var be = b.elements;
+		var te = this.elements;
 
 		var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
 		var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
@@ -134,7 +136,7 @@ THREE.Matrix4.prototype = {
 		te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
 		te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
 
-        te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
+		te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
 		te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
 		te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
 		te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
@@ -155,9 +157,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	multiplyToArray: function ( a, b, r ) {
-        
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		this.multiply( a, b );
 
 		r[ 0 ] = te[0]; r[ 1 ] = te[1]; r[ 2 ] = te[2]; r[ 3 ] = te[3];
@@ -170,9 +172,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	multiplyScalar: function ( s ) {
-        
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		te[0] *= s; te[4] *= s; te[8] *= s; te[12] *= s;
 		te[1] *= s; te[5] *= s; te[9] *= s; te[13] *= s;
 		te[2] *= s; te[6] *= s; te[10] *= s; te[14] *= s;
@@ -183,8 +185,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	multiplyVector3: function ( v ) {
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		var vx = v.x, vy = v.y, vz = v.z;
 		var d = 1 / ( te[3] * vx + te[7] * vy + te[11] * vz + te[15] );
 
@@ -197,8 +200,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	multiplyVector4: function ( v ) {
-        
-        var te = this.elements;
+
+		var te = this.elements;
 		var vx = v.x, vy = v.y, vz = v.z, vw = v.w;
 
 		v.x = te[0] * vx + te[4] * vy + te[8] * vz + te[12] * vw;
@@ -211,8 +214,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	rotateAxis: function ( v ) {
-        
-        var te = this.elements;
+
+		var te = this.elements;
 		var vx = v.x, vy = v.y, vz = v.z;
 
 		v.x = vx * te[0] + vy * te[4] + vz * te[8];
@@ -226,8 +229,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	crossVector: function ( a ) {
-        
-        var te = this.elements;
+
+		var te = this.elements;
 		var v = new THREE.Vector4();
 
 		v.x = te[0] * a.x + te[4] * a.y + te[8] * a.z + te[12] * a.w;
@@ -242,8 +245,8 @@ THREE.Matrix4.prototype = {
 
 	determinant: function () {
 
-        var te = this.elements;
-        
+		var te = this.elements;
+
 		var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
 		var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
 		var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
@@ -287,8 +290,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	transpose: function () {
-        var te = this.elements;
-        
+
+		var te = this.elements;
 		var tmp;
 
 		tmp = te[1]; te[1] = te[4]; te[4] = tmp;
@@ -305,7 +308,7 @@ THREE.Matrix4.prototype = {
 
 	flattenToArray: function ( flat ) {
 
-        var te = this.elements;
+		var te = this.elements;
 		flat[ 0 ] = te[0]; flat[ 1 ] = te[1]; flat[ 2 ] = te[2]; flat[ 3 ] = te[3];
 		flat[ 4 ] = te[4]; flat[ 5 ] = te[5]; flat[ 6 ] = te[6]; flat[ 7 ] = te[7];
 		flat[ 8 ]  = te[8]; flat[ 9 ]  = te[9]; flat[ 10 ] = te[10]; flat[ 11 ] = te[11];
@@ -317,7 +320,7 @@ THREE.Matrix4.prototype = {
 
 	flattenToArrayOffset: function( flat, offset ) {
 
-        var te = this.elements;
+		var te = this.elements;
 		flat[ offset ] = te[0];
 		flat[ offset + 1 ] = te[1];
 		flat[ offset + 2 ] = te[2];
@@ -343,14 +346,16 @@ THREE.Matrix4.prototype = {
 	},
 
 	getPosition: function () {
-        var te = this.elements;
-        
+
+		var te = this.elements;
 		return THREE.Matrix4.__v1.set( te[12], te[13], te[14] );
 
 	},
 
 	setPosition: function ( v ) {
-        var te = this.elements;
+
+		var te = this.elements;
+
 		te[12] = v.x;
 		te[13] = v.y;
 		te[14] = v.z;
@@ -360,19 +365,22 @@ THREE.Matrix4.prototype = {
 	},
 
 	getColumnX: function () {
-        var te = this.elements;
+
+		var te = this.elements;
 		return THREE.Matrix4.__v1.set( te[0], te[1], te[2] );
 
 	},
 
 	getColumnY: function () {
-        var te = this.elements;
+
+		var te = this.elements;
 		return THREE.Matrix4.__v1.set( te[4], te[5], te[6] );
 
 	},
 
 	getColumnZ: function() {
-        var te = this.elements;
+
+		var te = this.elements;
 		return THREE.Matrix4.__v1.set( te[8], te[9], te[10] );
 
 	},
@@ -380,9 +388,9 @@ THREE.Matrix4.prototype = {
 	getInverse: function ( m ) {
 
 		// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
-        var te = this.elements;
-        var me = m.elements;
-                
+		var te = this.elements;
+		var me = m.elements;
+
 		var n11 = me[0], n12 = me[4], n13 = me[8], n14 = me[12];
 		var n21 = me[1], n22 = me[5], n23 = me[9], n24 = me[13];
 		var n31 = me[2], n32 = me[6], n33 = me[10], n34 = me[14];
@@ -411,8 +419,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	setRotationFromEuler: function( v, order ) {
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		var x = v.x, y = v.y, z = v.z;
 		var a = Math.cos( x ), b = Math.sin( x );
 		var c = Math.cos( y ), d = Math.sin( y );
@@ -530,8 +539,9 @@ THREE.Matrix4.prototype = {
 
 
 	setRotationFromQuaternion: function( q ) {
-        var te = this.elements;
-        
+
+		var te = this.elements;
+
 		var x = q.x, y = q.y, z = q.z, w = q.w;
 		var x2 = x + x, y2 = y + y, z2 = z + z;
 		var xx = x * x2, xy = x * y2, xz = x * z2;
@@ -555,7 +565,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	compose: function ( translation, rotation, scale ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var mRotation = THREE.Matrix4.__m1;
 		var mScale = THREE.Matrix4.__m2;
 
@@ -576,8 +587,9 @@ THREE.Matrix4.prototype = {
 
 	decompose: function ( translation, rotation, scale ) {
 
+		var te = this.elements;
+
 		// grab the axis vectors
-        var te = this.elements;
 		var x = THREE.Matrix4.__v1;
 		var y = THREE.Matrix4.__v2;
 		var z = THREE.Matrix4.__v3;
@@ -623,8 +635,10 @@ THREE.Matrix4.prototype = {
 	},
 
 	extractPosition: function ( m ) {
-        var te = this.elements;
-        var me = m.elements;
+
+		var te = this.elements;
+		var me = m.elements;
+
 		te[12] = me[12];
 		te[13] = me[13];
 		te[14] = me[14];
@@ -634,9 +648,10 @@ THREE.Matrix4.prototype = {
 	},
 
 	extractRotation: function ( m ) {
-        var te = this.elements;
-        var me = m.elements;
-        
+
+		var te = this.elements;
+		var me = m.elements;
+
 		var vector = THREE.Matrix4.__v1;
 
 		var scaleX = 1 / vector.set( me[0], me[1], me[2] ).length();
@@ -662,7 +677,8 @@ THREE.Matrix4.prototype = {
 	//
 
 	translate: function ( v ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var x = v.x, y = v.y, z = v.z;
 
 		te[12] = te[0] * x + te[4] * y + te[8] * z + te[12];
@@ -675,7 +691,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	rotateX: function ( angle ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var m12 = te[4];
 		var m22 = te[5];
 		var m32 = te[6];
@@ -699,10 +716,11 @@ THREE.Matrix4.prototype = {
 
 		return this;
 
-  	},
+	},
 
 	rotateY: function ( angle ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var m11 = te[0];
 		var m21 = te[1];
 		var m31 = te[2];
@@ -729,7 +747,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	rotateZ: function ( angle ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var m11 = te[0];
 		var m21 = te[1];
 		var m31 = te[2];
@@ -756,7 +775,9 @@ THREE.Matrix4.prototype = {
 	},
 
 	rotateByAxis: function ( axis, angle ) {
-        var te = this.elements;
+
+		var te = this.elements;
+
 		// optimize by checking axis
 
 		if ( axis.x === 1 && axis.y === 0 && axis.z === 0 ) {
@@ -931,7 +952,7 @@ THREE.Matrix4.prototype = {
 
 		this.set(
 
-		 	tx * x + c, tx * y - s * z, tx * z + s * y, 0,
+			tx * x + c, tx * y - s * z, tx * z + s * y, 0,
 			tx * y + s * z, ty * y + c, ty * z - s * x, 0,
 			tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
 			0, 0, 0, 1
@@ -958,7 +979,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	makeFrustum: function ( left, right, bottom, top, near, far ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var x = 2 * near / ( right - left );
 		var y = 2 * near / ( top - bottom );
 
@@ -988,7 +1010,8 @@ THREE.Matrix4.prototype = {
 	},
 
 	makeOrthographic: function ( left, right, top, bottom, near, far ) {
-        var te = this.elements;
+
+		var te = this.elements;
 		var w = right - left;
 		var h = top - bottom;
 		var p = far - near;
@@ -1008,7 +1031,9 @@ THREE.Matrix4.prototype = {
 
 
 	clone: function () {
-        var te = this.elements;
+
+		var te = this.elements;
+
 		return new THREE.Matrix4(
 
 			te[0], te[4], te[8], te[12],