Browse Source

Vector4: Added array and offset to toArray()

Alexander Rose 10 years ago
parent
commit
4375424eba
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/math/Vector4.js

+ 15 - 2
src/math/Vector4.js

@@ -633,10 +633,23 @@ THREE.Vector4.prototype = {
 		return this;
 
 	},
+	
+	toArray: function ( array, offset ) {
 
-	toArray: function () {
+		if ( array ) {
 
-		return [ this.x, this.y, this.z, this.w ];
+			if ( offset === undefined ) offset = 0;
+
+			array[ offset ] = this.x;
+			array[ offset + 1 ] = this.y;
+			array[ offset + 2 ] = this.z;
+			array[ offset + 3 ] = this.w;
+
+		} else {
+
+			return [ this.x, this.y, this.z, this.w ];
+
+		}
 
 	},