Browse Source

Added transpose method to Matrix4

Nicolas Garcia Belmonte 15 years ago
parent
commit
20be01f159
1 changed files with 18 additions and 1 deletions
  1. 18 1
      src/core/Matrix4.js

+ 18 - 1
src/core/Matrix4.js

@@ -185,7 +185,24 @@ THREE.Matrix4.prototype = {
 			this.n11 * this.n22 * this.n33 * this.n44 );
 
 	},
-
+	
+  transpose: function () {
+    function swap(obj, p1, p2) {
+      var aux = obj[p1];
+      obj[p1] = obj[p2];
+      obj[p2] = aux;
+    }
+    
+    swap(this, 'n21', 'n12');
+    swap(this, 'n31', 'n13');
+    swap(this, 'n32', 'n23');
+    swap(this, 'n41', 'n14');
+    swap(this, 'n42', 'n24');
+    swap(this, 'n43', 'n34');
+    return this;
+    
+  },
+  
 	clone: function () {
 
 		var m = new THREE.Matrix4();