InstancedBufferGeometry.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { BufferGeometry } from './BufferGeometry';
  2. /**
  3. * @author benaadams / https://twitter.com/ben_a_adams
  4. */
  5. function InstancedBufferGeometry() {
  6. BufferGeometry.call( this );
  7. this.type = 'InstancedBufferGeometry';
  8. this.maxInstancedCount = undefined;
  9. }
  10. InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry.prototype ), {
  11. constructor: InstancedBufferGeometry,
  12. isInstancedBufferGeometry: true,
  13. addGroup: function ( start, count, materialIndex ) {
  14. this.groups.push( {
  15. start: start,
  16. count: count,
  17. materialIndex: materialIndex
  18. } );
  19. },
  20. copy: function ( source ) {
  21. var index = source.index;
  22. if ( index !== null ) {
  23. this.setIndex( index.clone() );
  24. }
  25. var attributes = source.attributes;
  26. for ( var name in attributes ) {
  27. var attribute = attributes[ name ];
  28. this.addAttribute( name, attribute.clone() );
  29. }
  30. var groups = source.groups;
  31. for ( var i = 0, l = groups.length; i < l; i ++ ) {
  32. var group = groups[ i ];
  33. this.addGroup( group.start, group.count, group.materialIndex );
  34. }
  35. return this;
  36. }
  37. } );
  38. export { InstancedBufferGeometry };