InstancedBufferAttribute.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { BufferAttribute } from './BufferAttribute.js';
  2. /**
  3. * @author benaadams / https://twitter.com/ben_a_adams
  4. */
  5. function InstancedBufferAttribute( array, itemSize, normalized, meshPerAttribute ) {
  6. if ( typeof ( normalized ) === 'number' ) {
  7. meshPerAttribute = normalized;
  8. normalized = false;
  9. console.error( 'THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.' );
  10. }
  11. BufferAttribute.call( this, array, itemSize, normalized );
  12. this.meshPerAttribute = meshPerAttribute || 1;
  13. }
  14. InstancedBufferAttribute.prototype = Object.assign( Object.create( BufferAttribute.prototype ), {
  15. constructor: InstancedBufferAttribute,
  16. isInstancedBufferAttribute: true,
  17. copy: function ( source ) {
  18. BufferAttribute.prototype.copy.call( this, source );
  19. this.meshPerAttribute = source.meshPerAttribute;
  20. return this;
  21. },
  22. toJSON: function () {
  23. var data = BufferAttribute.prototype.toJSON.call( this );
  24. data.meshPerAttribute = this.meshPerAttribute;
  25. data.isInstancedBufferAttribute = true;
  26. return data;
  27. }
  28. } );
  29. export { InstancedBufferAttribute };