Browse Source

Vector*: Simpler negate code.

Mr.doob 11 years ago
parent
commit
2c4f25af3d
3 changed files with 15 additions and 3 deletions
  1. 4 1
      src/math/Vector2.js
  2. 5 1
      src/math/Vector3.js
  3. 6 1
      src/math/Vector4.js

+ 4 - 1
src/math/Vector2.js

@@ -303,7 +303,10 @@ THREE.Vector2.prototype = {
 
 	negate: function () {
 
-		return this.multiplyScalar( - 1 );
+		this.x = - this.x;
+		this.y = - this.y;
+
+		return this;
 
 	},
 

+ 5 - 1
src/math/Vector3.js

@@ -506,7 +506,11 @@ THREE.Vector3.prototype = {
 
 	negate: function () {
 
-		return this.multiplyScalar( - 1 );
+		this.x = - this.x;
+		this.y = - this.y;
+		this.z = - this.z;
+
+		return this;
 
 	},
 

+ 6 - 1
src/math/Vector4.js

@@ -551,7 +551,12 @@ THREE.Vector4.prototype = {
 
 	negate: function () {
 
-		return this.multiplyScalar( - 1 );
+		this.x = - this.x;
+		this.y = - this.y;
+		this.z = - this.z;
+		this.w = - this.w;
+
+		return this;
 
 	},