InstancedBufferAttribute.js 856 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { BufferAttribute } from './BufferAttribute.js';
  2. class InstancedBufferAttribute extends BufferAttribute {
  3. constructor( array, itemSize, normalized, meshPerAttribute = 1 ) {
  4. if ( typeof normalized === 'number' ) {
  5. meshPerAttribute = normalized;
  6. normalized = false;
  7. console.error( 'THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.' );
  8. }
  9. super( array, itemSize, normalized );
  10. this.isInstancedBufferAttribute = true;
  11. this.meshPerAttribute = meshPerAttribute;
  12. }
  13. copy( source ) {
  14. super.copy( source );
  15. this.meshPerAttribute = source.meshPerAttribute;
  16. return this;
  17. }
  18. toJSON() {
  19. const data = super.toJSON();
  20. data.meshPerAttribute = this.meshPerAttribute;
  21. data.isInstancedBufferAttribute = true;
  22. return data;
  23. }
  24. }
  25. export { InstancedBufferAttribute };
粤ICP备19079148号