Browse Source

Vector3: Added array and offset to toArray()

Alexander Rose 10 years ago
parent
commit
e46327be45
1 changed files with 14 additions and 2 deletions
  1. 14 2
      src/math/Vector3.js

+ 14 - 2
src/math/Vector3.js

@@ -796,9 +796,21 @@ THREE.Vector3.prototype = {
 
 
 	},
 	},
 
 
-	toArray: function () {
+	toArray: function ( array, offset ) {
 
 
-		return [ this.x, this.y, this.z ];
+		if ( array ) {
+
+			if ( offset === undefined ) offset = 0;
+
+			array[ offset ] = this.x;
+			array[ offset + 1 ] = this.y;
+			array[ offset + 2 ] = this.z;
+
+		} else {
+
+			return [ this.x, this.y, this.z ];
+
+		}
 
 
 	},
 	},