Browse Source

Cache xyz components in crossVectors function.

stephomi 12 years ago
parent
commit
bbaa398e19
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/math/Vector3.js

+ 6 - 3
src/math/Vector3.js

@@ -484,9 +484,12 @@ THREE.Vector3.prototype = {
 
 
 	crossVectors: function ( a, b ) {
 	crossVectors: function ( a, b ) {
 
 
-		this.x = a.y * b.z - a.z * b.y;
-		this.y = a.z * b.x - a.x * b.z;
-		this.z = a.x * b.y - a.y * b.x;
+		var ax = a.x, ay = a.y, az = a.z;
+		var bx = b.x, by = b.y, bz = b.z;
+
+		this.x = ay * bz - az * by;
+		this.y = az * bx - ax * bz;
+		this.z = ax * by - ay * bx;
 
 
 		return this;
 		return this;