Browse Source

Vector2: Added array and offset to toArray()

Alexander Rose 10 years ago
parent
commit
1a0153b9b5
1 changed files with 13 additions and 2 deletions
  1. 13 2
      src/math/Vector2.js

+ 13 - 2
src/math/Vector2.js

@@ -386,9 +386,20 @@ THREE.Vector2.prototype = {
 
 	},
 
-	toArray: function () {
+	toArray: function ( array, offset ) {
 
-		return [ this.x, this.y ];
+		if ( array ) {
+
+			if ( offset === undefined ) offset = 0;
+
+			array[ offset ] = this.x;
+			array[ offset + 1 ] = this.y;
+
+		} else {
+
+			return [ this.x, this.y ];
+
+		}
 
 	},