Skip to content

Commit

Permalink
Merge pull request #5735 from WestLangley/dev-attrib
Browse files Browse the repository at this point in the history
Added fromAttribute() method to the Vector* classes
  • Loading branch information
mrdoob committed Dec 8, 2014
2 parents 48c2a37 + a48b715 commit 189c984
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/math/Vector2.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,19 @@ THREE.Vector2.prototype = {

},

fromAttribute: function ( attribute, index, offset ) {

if ( offset === undefined ) offset = 0;

index = index * attribute.itemSize + offset;

this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];

return this;

},

clone: function () {

return new THREE.Vector2( this.x, this.y );
Expand Down
14 changes: 14 additions & 0 deletions src/math/Vector3.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,20 @@ THREE.Vector3.prototype = {

},

fromAttribute: function ( attribute, index, offset ) {

if ( offset === undefined ) offset = 0;

index = index * attribute.itemSize + offset;

this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];
this.z = attribute.array[ index + 2 ];

return this;

},

clone: function () {

return new THREE.Vector3( this.x, this.y, this.z );
Expand Down
15 changes: 15 additions & 0 deletions src/math/Vector4.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,21 @@ THREE.Vector4.prototype = {

},

fromAttribute: function ( attribute, index, offset ) {

if ( offset === undefined ) offset = 0;

index = index * attribute.itemSize + offset;

this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];
this.z = attribute.array[ index + 2 ];
this.w = attribute.array[ index + 3 ];

return this;

},

clone: function () {

return new THREE.Vector4( this.x, this.y, this.z, this.w );
Expand Down

0 comments on commit 189c984

Please sign in to comment.