InstancedBufferGeometry.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.clone = function () {
  20. var geometry = new THREE.InstancedBufferGeometry();
  21. for ( var attr in this.attributes ) {
  22. var sourceAttr = this.attributes[attr];
  23. geometry.addAttribute( attr, sourceAttr.clone() );
  24. }
  25. for ( var i = 0, il = this.offsets.length; i < il; i++ ) {
  26. var offset = this.offsets[i];
  27. geometry.offsets.push( {
  28. start: offset.start,
  29. index: offset.index,
  30. count: offset.count,
  31. instances: offset.instances
  32. } );
  33. }
  34. return geometry;
  35. };
  36. THREE.EventDispatcher.prototype.apply( THREE.InstancedBufferGeometry.prototype );
粤ICP备19079148号