From e46327be4539480895362c38b1f19709373cb9d4 Mon Sep 17 00:00:00 2001 From: Alexander Rose Date: Tue, 14 Oct 2014 21:16:05 +0200 Subject: [PATCH] Vector3: Added array and offset to toArray() --- src/math/Vector3.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/math/Vector3.js b/src/math/Vector3.js index 19f774f4d0..4d68bc32f7 100644 --- a/src/math/Vector3.js +++ b/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 ]; + + } }, -- GitLab