InstancedMesh.js 920 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { BufferAttribute } from '../core/BufferAttribute.js';
  5. import { Matrix3 } from '../math/Matrix3.js';
  6. import { Mesh } from './Mesh.js';
  7. var _matrix3 = new Matrix3();
  8. function InstancedMesh( geometry, material, count ) {
  9. Mesh.call( this, geometry, material );
  10. this.instanceMatrix = new BufferAttribute( new Float32Array( count * 16 ), 16 );
  11. this.instanceNormalMatrix = new BufferAttribute( new Float32Array( count * 9 ), 9 );
  12. }
  13. InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
  14. constructor: InstancedMesh,
  15. isInstancedMesh: true,
  16. raycast: function () {},
  17. setMatrixAt: function ( index, matrix ) {
  18. matrix.toArray( this.instanceMatrix.array, index * 16 );
  19. _matrix3.getNormalMatrix( matrix ).toArray( this.instanceNormalMatrix.array, index * 9 );
  20. },
  21. updateMorphTargets: function () {}
  22. } );
  23. export { InstancedMesh };
粤ICP备19079148号