WebGPUObjects.js 618 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. const material = object.material;
  13. this.geometries.update( geometry, material.wireframe === true );
  14. updateMap.set( geometry, frame );
  15. }
  16. }
  17. dispose() {
  18. this.updateMap = new WeakMap();
  19. }
  20. }
  21. export default WebGPUObjects;