Skip to content

Commit

Permalink
InstancedBufferGeometry: Fix .copy() and .clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Aug 18, 2017
1 parent 177bf99 commit af19783
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 35 deletions.
5 changes: 4 additions & 1 deletion examples/webgl_buffergeometry_instancing_billboards.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@
scene = new THREE.Scene();

geometry = new THREE.InstancedBufferGeometry();
geometry.copy( new THREE.CircleBufferGeometry( 1, 6 ) );
var circleGeometry = new THREE.CircleBufferGeometry( 1, 6 );

geometry.index = circleGeometry.index;
geometry.attributes = circleGeometry.attributes;

var particleCount = 75000;

Expand Down
40 changes: 6 additions & 34 deletions src/core/InstancedBufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,19 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry

isInstancedBufferGeometry: true,

addGroup: function ( start, count, materialIndex ) {

this.groups.push( {

start: start,
count: count,
materialIndex: materialIndex

} );

},

copy: function ( source ) {

var index = source.index;

if ( index !== null ) {

this.setIndex( index.clone() );
BufferGeometry.prototype.copy.call( this, source );

}
this.maxInstancedCount = source.maxInstancedCount;

var attributes = source.attributes;

for ( var name in attributes ) {

var attribute = attributes[ name ];
this.addAttribute( name, attribute.clone() );

}

var groups = source.groups;

for ( var i = 0, l = groups.length; i < l; i ++ ) {
return this;

var group = groups[ i ];
this.addGroup( group.start, group.count, group.materialIndex );
},

}
clone: function () {

return this;
return new this.constructor().copy( this );

}

Expand Down

0 comments on commit af19783

Please sign in to comment.