InstancedBufferGeometry.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @author benaadams / https://twitter.com/ben_a_adams
  3. */
  4. THREE.InstancedBufferGeometry = function () {
  5. THREE.BufferGeometry.call( this );
  6. this.type = 'InstancedBufferGeometry';
  7. this.maxInstancedCount = undefined;
  8. };
  9. THREE.InstancedBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
  10. THREE.InstancedBufferGeometry.prototype.constructor = THREE.InstancedBufferGeometry;
  11. THREE.InstancedBufferGeometry.prototype.addDrawCall = function ( start, count, indexOffset, instances ) {
  12. this.drawcalls.push( {
  13. start: start,
  14. count: count,
  15. index: indexOffset !== undefined ? indexOffset : 0,
  16. instances: instances
  17. } );
  18. };
  19. THREE.InstancedBufferGeometry.prototype.copy = function ( source ) {
  20. for ( var attr in source.attributes ) {
  21. var sourceAttr = source.attributes[ attr ];
  22. this.addAttribute( attr, sourceAttr.clone() );
  23. }
  24. for ( var i = 0, il = source.drawcalls.length; i < il; i ++ ) {
  25. var offset = source.drawcalls[ i ];
  26. this.addDrawCall( offset.start, offset.count, offset.index, offset.instances );
  27. }
  28. return this;
  29. };
  30. THREE.EventDispatcher.prototype.apply( THREE.InstancedBufferGeometry.prototype );