WebGPUObjects.js 658 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. class WebGPUObjects {
  2. constructor( geometries, info ) {
  3. this.geometries = geometries;
  4. this.info = info;
  5. this.updateMap = new WeakMap();
  6. }
  7. update( object ) {
  8. const geometry = object.geometry;
  9. const updateMap = this.updateMap;
  10. const frame = this.info.render.frame;
  11. if ( geometry.isBufferGeometry !== true ) {
  12. throw 'THREE.WebGPURenderer: This renderer only supports THREE.BufferGeometry for geometries.';
  13. }
  14. if ( updateMap.get( geometry ) !== frame ) {
  15. this.geometries.update( geometry );
  16. updateMap.set( geometry, frame );
  17. }
  18. }
  19. dispose() {
  20. this.updateMap = new WeakMap();
  21. }
  22. }
  23. export default WebGPUObjects;