2
0
Эх сурвалжийг харах

Vector*: Simpler negate code.

Mr.doob 11 жил өмнө
parent
commit
2c4f25af3d

+ 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;
 
 	},