提交 832377e3 编写于 作者: M Mr.doob

Merge pull request #5453 from arose/patch-1

Vector3: Added array and offset to toArray()
......@@ -483,9 +483,17 @@ THREE.Quaternion.prototype = {
},
toArray: function () {
toArray: function ( array, offset ) {
return [ this._x, this._y, this._z, this._w ];
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._w;
return array;
},
......
......@@ -386,9 +386,15 @@ THREE.Vector2.prototype = {
},
toArray: function () {
toArray: function ( array, offset ) {
return [ this.x, this.y ];
if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
array[ offset ] = this.x;
array[ offset + 1 ] = this.y;
return array;
},
......
......@@ -796,9 +796,16 @@ THREE.Vector3.prototype = {
},
toArray: function () {
toArray: function ( array, offset ) {
return [ this.x, this.y, this.z ];
if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
array[ offset ] = this.x;
array[ offset + 1 ] = this.y;
array[ offset + 2 ] = this.z;
return array;
},
......
......@@ -634,9 +634,17 @@ THREE.Vector4.prototype = {
},
toArray: function () {
toArray: function ( array, offset ) {
return [ this.x, this.y, this.z, this.w ];
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.w;
return array;
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册