InstancedBufferAttribute.js 1.0 KB

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