Browse Source

Added fromArray() to Vector* for convenience.

Mr.doob 12 years ago
parent
commit
e68aeeacaf
3 changed files with 24 additions and 0 deletions
  1. 7 0
      src/math/Vector2.js
  2. 8 0
      src/math/Vector3.js
  3. 9 0
      src/math/Vector4.js

+ 7 - 0
src/math/Vector2.js

@@ -295,6 +295,13 @@ THREE.Vector2.prototype = {
 
 	},
 
+	fromArray: function ( array ) {
+
+		this.x = array[ 0 ];
+		this.y = array[ 1 ];
+
+	},
+
 	toArray: function () {
 
 		return [ this.x, this.y ];

+ 8 - 0
src/math/Vector3.js

@@ -739,6 +739,14 @@ THREE.Vector3.prototype = {
 
 	},
 
+	fromArray: function ( array ) {
+
+		this.x = array[ 0 ];
+		this.y = array[ 1 ];
+		this.z = array[ 2 ];
+
+	},
+
 	toArray: function () {
 
 		return [ this.x, this.y, this.z ];

+ 9 - 0
src/math/Vector4.js

@@ -547,6 +547,15 @@ THREE.Vector4.prototype = {
 
 	},
 
+	fromArray: function ( array ) {
+
+		this.x = array[ 0 ];
+		this.y = array[ 1 ];
+		this.z = array[ 2 ];
+		this.w = array[ 3 ];
+
+	},
+
 	toArray: function () {
 
 		return [ this.x, this.y, this.z, this.w ];