@woosh/meep-engine 2.118.2 → 2.118.3

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/build/meep.cjs CHANGED
@@ -51203,18 +51203,28 @@ const context_cache = new WeakMap();
51203
51203
  /**
51204
51204
  *
51205
51205
  * @param {HTMLCanvasElement} canvas
51206
- * @returns {Sampler2D}
51206
+ * @returns {CanvasRenderingContext2D}
51207
51207
  */
51208
- function html_canvas_to_sampler2d(canvas) {
51209
- const width = canvas.width;
51210
- const height = canvas.height;
51211
-
51208
+ function html_canvas_to_rendering_context2d_cached(canvas) {
51212
51209
  let context = context_cache.get(canvas);
51213
51210
 
51214
51211
  if (context === undefined) {
51215
51212
  context = canvas.getContext("2d");
51216
51213
  context_cache.set(canvas, context);
51217
51214
  }
51215
+ return context;
51216
+ }
51217
+
51218
+ /**
51219
+ *
51220
+ * @param {HTMLCanvasElement} canvas
51221
+ * @returns {Sampler2D}
51222
+ */
51223
+ function html_canvas_to_sampler2d(canvas) {
51224
+ const width = canvas.width;
51225
+ const height = canvas.height;
51226
+
51227
+ const context = html_canvas_to_rendering_context2d_cached(canvas);
51218
51228
 
51219
51229
  const imageData = context.getImageData(0, 0, width, height);
51220
51230
 
@@ -76451,6 +76461,17 @@ function murmur3_32(key, seed) {
76451
76461
  return h1 >>> 0;
76452
76462
  }
76453
76463
 
76464
+ /**
76465
+ *
76466
+ * @param {HTMLCanvasElement} canvas
76467
+ * @returns {number}
76468
+ */
76469
+ function computeHtmlCanvasElementHash(canvas) {
76470
+ const sampler = html_canvas_to_sampler2d(canvas);
76471
+
76472
+ return sampler.hash();
76473
+ }
76474
+
76454
76475
  /**
76455
76476
  * Guards against cases where ImageBitmap doesn't exist
76456
76477
  * @param {*} image
@@ -76695,6 +76716,10 @@ function computeImageDataHash(image) {
76695
76716
 
76696
76717
  result = computeStringHash(image.src);
76697
76718
 
76719
+ }else if(image instanceof HTMLCanvasElement) {
76720
+
76721
+ result = computeHtmlCanvasElementHash(image);
76722
+
76698
76723
  }
76699
76724
 
76700
76725
  let width = 0;