Browse Source

Added subScalar to Vector2 and Vector4 too.

Mr.doob 10 years ago
parent
commit
1f97cfaa5d
2 changed files with 26 additions and 6 deletions
  1. 15 6
      src/math/Vector2.js
  2. 11 0
      src/math/Vector4.js

+ 15 - 6
src/math/Vector2.js

@@ -90,19 +90,19 @@ THREE.Vector2.prototype = {
 
 	},
 
-	addVectors: function ( a, b ) {
+	addScalar: function ( s ) {
 
-		this.x = a.x + b.x;
-		this.y = a.y + b.y;
+		this.x += s;
+		this.y += s;
 
 		return this;
 
 	},
 
-	addScalar: function ( s ) {
+	addVectors: function ( a, b ) {
 
-		this.x += s;
-		this.y += s;
+		this.x = a.x + b.x;
+		this.y = a.y + b.y;
 
 		return this;
 
@@ -124,6 +124,15 @@ THREE.Vector2.prototype = {
 
 	},
 
+	subScalar: function ( s ) {
+
+		this.x -= s;
+		this.y -= s;
+
+		return this;
+
+	},
+
 	subVectors: function ( a, b ) {
 
 		this.x = a.x - b.x;

+ 11 - 0
src/math/Vector4.js

@@ -159,6 +159,17 @@ THREE.Vector4.prototype = {
 
 	},
 
+	subScalar: function ( s ) {
+
+		this.x -= s;
+		this.y -= s;
+		this.z -= s;
+		this.w -= s;
+
+		return this;
+
+	},
+
 	subVectors: function ( a, b ) {
 
 		this.x = a.x - b.x;