Browse Source

Quaternion: Added array and offset to toArray()

Alexander Rose 10 years ago
parent
commit
654da558fb
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/math/Quaternion.js

+ 15 - 2
src/math/Quaternion.js

@@ -482,10 +482,23 @@ THREE.Quaternion.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 ];
+
+		}
 
 	},