瀏覽代碼

Some space/tabs clean up.

Mr.doob 12 年之前
父節點
當前提交
189148edf7
共有 5 個文件被更改,包括 87 次插入86 次删除
  1. 1 1
      examples/canvas_materials.html
  2. 8 7
      src/math/Matrix3.js
  3. 44 45
      src/math/Matrix4.js
  4. 16 15
      src/math/Vector2.js
  5. 18 18
      src/math/Vector3.js

+ 1 - 1
examples/canvas_materials.html

@@ -63,7 +63,7 @@
 
 				// Spheres
 
-				var geometry = new THREE.SphereGeometry( 100, 14, 7, false );
+				var geometry = new THREE.SphereGeometry( 100, 14, 7 );
 
 				var materials = [
 

+ 8 - 7
src/math/Matrix3.js

@@ -112,13 +112,15 @@ THREE.Matrix3.prototype = {
 	},
 
 	determinant: function () {
+
 		var te = this.elements;
-		
+
 		var a = te[0], b = te[1], c = te[2],
 			d = te[3], e = te[4], f = te[5],
 			g = te[6], h = te[7], i = te[8];
 
 		return a*e*i - a*f*h - b*d*i + b*f*g + c*d*h - c*e*g;
+
 	},
 
 	getInverse: function ( matrix, throwOnInvertible ) {
@@ -128,7 +130,7 @@ THREE.Matrix3.prototype = {
 
 		var me = matrix.elements;
 		var te = this.elements;
-	
+
 		te[ 0 ] =   me[10] * me[5] - me[6] * me[9];
 		te[ 1 ] = - me[10] * me[1] + me[2] * me[9];
 		te[ 2 ] =   me[6] * me[1] - me[2] * me[5];
@@ -147,12 +149,11 @@ THREE.Matrix3.prototype = {
 
 			var msg = "Matrix3.getInverse(): can't invert matrix, determinant is 0";
 
-			if( throwOnInvertible || false ) {
+			if ( throwOnInvertible || false ) {
 
 				throw new Error( msg ); 
 
-			}
-			else {
+			} else {
 
 				console.warn( msg );
 
@@ -161,7 +162,7 @@ THREE.Matrix3.prototype = {
 			this.identity();
 
 			return this;
-			
+
 		}
 
 		this.multiplyScalar( 1.0 / det );
@@ -218,4 +219,4 @@ THREE.Matrix3.prototype = {
 
 };
 
-THREE.Matrix3.__v1 = new THREE.Vector3();
+THREE.Matrix3.__v1 = new THREE.Vector3();

+ 44 - 45
src/math/Matrix4.js

@@ -417,37 +417,37 @@ THREE.Matrix4.prototype = {
 
 		return (
 			n41 * (
-		      +n14 * n23 * n32
-		      -n13 * n24 * n32
-		      -n14 * n22 * n33
-		      +n12 * n24 * n33
-		      +n13 * n22 * n34
-		      -n12 * n23 * n34
-		      ) +
+				+n14 * n23 * n32
+				-n13 * n24 * n32
+				-n14 * n22 * n33
+				+n12 * n24 * n33
+				+n13 * n22 * n34
+				-n12 * n23 * n34
+			) +
 			n42 * (
-		      +n11 * n23 * n34
-		      -n11 * n24 * n33
-		      +n14 * n21 * n33
-		      -n13 * n21 * n34
-		      +n13 * n24 * n31
-		      -n14 * n23 * n31
-		      ) +
+				+n11 * n23 * n34
+				-n11 * n24 * n33
+				+n14 * n21 * n33
+				-n13 * n21 * n34
+				+n13 * n24 * n31
+				-n14 * n23 * n31
+			) +
 			n43 * (
-		      +n11 * n24 * n32
-		      -n11 * n22 * n34
-		      -n14 * n21 * n32
-		      +n12 * n21 * n34
-		      +n14 * n22 * n31
-		      -n12 * n24 * n31
-		      ) +
-		    n44 * (
-		      -n13 * n22 * n31
-		      -n11 * n23 * n32
-		      +n11 * n22 * n33
-		      +n13 * n21 * n32
-		      -n12 * n21 * n33
-		      +n12 * n23 * n31
-		      )
+				+n11 * n24 * n32
+				-n11 * n22 * n34
+				-n14 * n21 * n32
+				+n12 * n21 * n34
+				+n14 * n22 * n31
+				-n12 * n24 * n31
+			) +
+			n44 * (
+				-n13 * n22 * n31
+				-n11 * n23 * n32
+				+n11 * n22 * n33
+				+n13 * n21 * n32
+				-n12 * n21 * n33
+				+n12 * n23 * n31
+			)
 
 		);
 
@@ -475,7 +475,7 @@ THREE.Matrix4.prototype = {
 		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];
+		flat[ 8 ] = te[8]; flat[ 9 ] = te[9]; flat[ 10 ] = te[10]; flat[ 11 ] = te[11];
 		flat[ 12 ] = te[12]; flat[ 13 ] = te[13]; flat[ 14 ] = te[14]; flat[ 15 ] = te[15];
 
 		return flat;
@@ -579,16 +579,15 @@ THREE.Matrix4.prototype = {
 
 		var det = me[ 0 ] * te[ 0 ] + me[ 1 ] * te[ 4 ] + me[ 2 ] * te[ 8 ] + me[ 3 ] * te[ 12 ];
 
-		if( det == 0 ) {
+		if ( det == 0 ) {
 
 			var msg = "Matrix4.getInverse(): can't invert matrix, determinant is 0";
 
-			if( throwOnInvertible || false ) {
+			if ( throwOnInvertible || false ) {
 
 				throw new Error( msg ); 
 
-			}
-			else {
+			} else {
 
 				console.warn( msg );
 
@@ -905,9 +904,9 @@ THREE.Matrix4.prototype = {
 
 		var te = this.elements;
 
-		var scaleXSq =  te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
-		var scaleYSq =  te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
-		var scaleZSq =  te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
+		var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
+		var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
+		var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
 
 		return Math.sqrt( Math.max( scaleXSq, Math.max( scaleYSq, scaleZSq ) ) );
 
@@ -1030,10 +1029,10 @@ THREE.Matrix4.prototype = {
 		var c = - ( far + near ) / ( far - near );
 		var d = - 2 * far * near / ( far - near );
 
-		te[0] = x;  te[4] = 0;  te[8] = a;   te[12] = 0;
-		te[1] = 0;  te[5] = y;  te[9] = b;   te[13] = 0;
-		te[2] = 0;  te[6] = 0;  te[10] = c;   te[14] = d;
-		te[3] = 0;  te[7] = 0;  te[11] = - 1; te[15] = 0;
+		te[0] = x;	te[4] = 0;	te[8] = a;	te[12] = 0;
+		te[1] = 0;	te[5] = y;	te[9] = b;	te[13] = 0;
+		te[2] = 0;	te[6] = 0;	te[10] = c;	te[14] = d;
+		te[3] = 0;	te[7] = 0;	te[11] = - 1;	te[15] = 0;
 
 		return this;
 
@@ -1061,10 +1060,10 @@ THREE.Matrix4.prototype = {
 		var y = ( top + bottom ) / h;
 		var z = ( far + near ) / p;
 
-		te[0] = 2 / w; te[4] = 0;     te[8] = 0;      te[12] = -x;
-		te[1] = 0;     te[5] = 2 / h; te[9] = 0;      te[13] = -y;
-		te[2] = 0;     te[6] = 0;     te[10] = -2 / p; te[14] = -z;
-		te[3] = 0;     te[7] = 0;     te[11] = 0;      te[15] = 1;
+		te[0] = 2 / w;	te[4] = 0;	te[8] = 0;	te[12] = -x;
+		te[1] = 0;	te[5] = 2 / h;	te[9] = 0;	te[13] = -y;
+		te[2] = 0;	te[6] = 0;	te[10] = -2/p;	te[14] = -z;
+		te[3] = 0;	te[7] = 0;	te[11] = 0;	te[15] = 1;
 
 		return this;
 

+ 16 - 15
src/math/Vector2.js

@@ -42,28 +42,29 @@ THREE.Vector2.prototype = {
 	},
 
 
-    setComponent: function ( index, value ) {
+	setComponent: function ( index, value ) {
 
-        switch( index ) {
+		switch ( index ) {
 
-            case 0: this.x = value; break;
-            case 1: this.y = value; break;
-            default: throw new Error( "index is out of range: " + index );
+			case 0: this.x = value; break;
+			case 1: this.y = value; break;
+			default: throw new Error( "index is out of range: " + index );
 
-        }
+		}
+
+	},
 
-    },
+	getComponent: function ( index ) {
 
-    getComponent: function ( index ) {
+		switch ( index ) {
 
-        switch( index ) {
+			case 0: return this.x;
+			case 1: return this.y;
+			default: throw new Error( "index is out of range: " + index );
 
-            case 0: return this.x;
-            case 1: return this.y;
-            default: throw new Error( "index is out of range: " + index );
+		}
 
-    	}
-    },
+	},
 
 	copy: function ( v ) {
 
@@ -286,4 +287,4 @@ THREE.Vector2.prototype = {
 
 	}
 
-};
+};

+ 18 - 18
src/math/Vector3.js

@@ -54,31 +54,31 @@ THREE.Vector3.prototype = {
 
 	},
 
-    setComponent: function ( index, value ) {
+	setComponent: function ( index, value ) {
 
-        switch( index ) {
+		switch ( index ) {
 
-            case 0: this.x = value; break;
-            case 1: this.y = value; break;
-            case 2: this.z = value; break;
-            default: throw new Error( "index is out of range: " + index );
+			case 0: this.x = value; break;
+			case 1: this.y = value; break;
+			case 2: this.z = value; break;
+			default: throw new Error( "index is out of range: " + index );
 
-        }
+		}
 
-    },
+	},
 
-    getComponent: function ( index ) {
+	getComponent: function ( index ) {
 
-        switch( index ) {
+		switch ( index ) {
 
-            case 0: return this.x;
-            case 1: return this.y;
-            case 2: return this.z;
-            default: throw new Error( "index is out of range: " + index );
+			case 0: return this.x;
+			case 1: return this.y;
+			case 2: return this.z;
+			default: throw new Error( "index is out of range: " + index );
 
-        }
+		}
 
-    },
+	},
 
 	copy: function ( v ) {
 
@@ -325,7 +325,7 @@ THREE.Vector3.prototype = {
 	setLength: function ( l ) {
 
 		var oldLength = this.length();
-		
+
 		if ( oldLength !== 0 && l !== oldLength  ) {
 
 			this.multiplyScalar( l / oldLength );
@@ -604,4 +604,4 @@ THREE.Vector3.prototype = {
 
 	}
 
-};
+};