WebGPUObjects.js 551 B

123456789101112131415161718192021222324252627282930313233343536
  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 ( this.geometries.has( geometry ) === false || updateMap.get( geometry ) !== frame ) {
  12. this.geometries.update( geometry );
  13. updateMap.set( geometry, frame );
  14. }
  15. }
  16. dispose() {
  17. this.updateMap = new WeakMap();
  18. }
  19. }
  20. export default WebGPUObjects;