Browse Source

Merge pull request #5995 from Wandalen/dev

Color/Euler: 'toArray' broken expectations fix
Mr.doob 10 years ago
parent
commit
d42125f87a
2 changed files with 17 additions and 4 deletions
  1. 8 2
      src/math/Color.js
  2. 9 2
      src/math/Euler.js

+ 8 - 2
src/math/Color.js

@@ -372,10 +372,16 @@ THREE.Color.prototype = {
 
 
 	},
 	},
 
 
-	toArray: function () {
+	toArray: function ( array, offset ) {
 
 
-		return [ this.r, this.g, this.b ];
+		if ( array === undefined ) array = [];
+		if ( offset === undefined ) offset = 0;
 
 
+		array[ offset ] = this.r;
+		array[ offset + 1 ] = this.g;
+		array[ offset + 2 ] = this.b;
+
+		return array;
 	},
 	},
 
 
 	clone: function () {
 	clone: function () {

+ 9 - 2
src/math/Euler.js

@@ -280,10 +280,17 @@ THREE.Euler.prototype = {
 
 
 	},
 	},
 
 
-	toArray: function () {
+	toArray: function ( array, offset ) {
 
 
-		return [ this._x, this._y, this._z, this._order ];
+		if ( array === undefined ) array = [];
+		if ( offset === undefined ) offset = 0;
 
 
+		array[ offset ] = this._x;
+		array[ offset + 1 ] = this._y;
+		array[ offset + 2 ] = this._z;
+		array[ offset + 3 ] = this._order;
+
+		return array;
 	},
 	},
 
 
 	toVector3: function ( optionalResult ) {
 	toVector3: function ( optionalResult ) {