wgsl-renderer 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -629,7 +629,7 @@ var WGSLRenderer = class {
629
629
  addressModeV: "clamp-to-edge"
630
630
  }, options));
631
631
  }
632
- async loadImageTexture(image, format) {
632
+ async loadImageTexture(image, format, options) {
633
633
  if (typeof image === "string") if (image.startsWith("data:")) {
634
634
  const base64Data = image.split(",")[1];
635
635
  const binaryString = atob(base64Data);
@@ -644,7 +644,7 @@ var WGSLRenderer = class {
644
644
  });
645
645
  image = await (await resp).blob();
646
646
  }
647
- const future = createImageBitmap(image);
647
+ const future = createImageBitmap(image, options);
648
648
  future.catch((err) => {
649
649
  console.error("Failed to load texture:", err);
650
650
  });
@@ -713,6 +713,11 @@ var WGSLRenderer = class {
713
713
  this.animationFrameId = null;
714
714
  }
715
715
  }
716
+ reset() {
717
+ this.stopLoop();
718
+ this.passes = [];
719
+ this.textureManager.destroy();
720
+ }
716
721
  };
717
722
  async function createWGSLRenderer(cvs, options) {
718
723
  const renderer = new WGSLRenderer(cvs, options);
@@ -217,7 +217,7 @@ declare class WGSLRenderer {
217
217
  * Create a sampler
218
218
  */
219
219
  createSampler(options?: GPUSamplerDescriptor): GPUSampler;
220
- loadImageTexture(image: Blob | string, format?: GPUTextureFormat): Promise<{
220
+ loadImageTexture(image: Blob | string, format?: GPUTextureFormat, options?: ImageBitmapOptions): Promise<{
221
221
  texture: GPUTexture;
222
222
  bitMap: ImageBitmap;
223
223
  width: number;
@@ -228,6 +228,7 @@ declare class WGSLRenderer {
228
228
  (t: number): void;
229
229
  }): void;
230
230
  stopLoop(): void;
231
+ reset(): void;
231
232
  }
232
233
  declare function createWGSLRenderer(cvs: HTMLCanvasElement, options?: WGSLRendererOptions): Promise<WGSLRenderer>;
233
234
  //#endregion
package/dist/esm/index.js CHANGED
@@ -628,7 +628,7 @@ var WGSLRenderer = class {
628
628
  addressModeV: "clamp-to-edge"
629
629
  }, options));
630
630
  }
631
- async loadImageTexture(image, format) {
631
+ async loadImageTexture(image, format, options) {
632
632
  if (typeof image === "string") if (image.startsWith("data:")) {
633
633
  const base64Data = image.split(",")[1];
634
634
  const binaryString = atob(base64Data);
@@ -643,7 +643,7 @@ var WGSLRenderer = class {
643
643
  });
644
644
  image = await (await resp).blob();
645
645
  }
646
- const future = createImageBitmap(image);
646
+ const future = createImageBitmap(image, options);
647
647
  future.catch((err) => {
648
648
  console.error("Failed to load texture:", err);
649
649
  });
@@ -712,6 +712,11 @@ var WGSLRenderer = class {
712
712
  this.animationFrameId = null;
713
713
  }
714
714
  }
715
+ reset() {
716
+ this.stopLoop();
717
+ this.passes = [];
718
+ this.textureManager.destroy();
719
+ }
715
720
  };
716
721
  async function createWGSLRenderer(cvs, options) {
717
722
  const renderer = new WGSLRenderer(cvs, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgsl-renderer",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A multi-pass renderer based on WebGPU and WGSL.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",