InstancedBufferGeometry.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.addGroup = function ( start, count, instances ) {
  12. this.groups.push( {
  13. start: start,
  14. count: count,
  15. instances: instances
  16. } );
  17. };
  18. THREE.InstancedBufferGeometry.prototype.copy = function ( source ) {
  19. var index = source.index;
  20. if ( index !== null ) {
  21. this.setIndex( index.clone() );
  22. }
  23. var attributes = source.attributes;
  24. for ( var name in attributes ) {
  25. var attribute = attributes[ name ];
  26. this.addAttribute( name, attribute.clone() );
  27. }
  28. var groups = source.groups;
  29. for ( var i = 0, l = groups.length; i < l; i ++ ) {
  30. var group = groups[ i ];
  31. this.addGroup( group.start, group.count, group.instances );
  32. }
  33. return this;
  34. };
  35. THREE.EventDispatcher.prototype.apply( THREE.InstancedBufferGeometry.prototype );