@woosh/meep-engine 2.117.11 → 2.117.13
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 +46 -23
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +46 -23
- package/package.json +1 -1
- package/src/core/events/signal/Signal.d.ts +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +1 -22
- package/src/engine/graphics/canvas/computeImageCanvasEquality.d.ts +8 -0
- package/src/engine/graphics/canvas/computeImageCanvasEquality.d.ts.map +1 -0
- package/src/engine/graphics/canvas/computeImageCanvasEquality.js +31 -0
- package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts +6 -1
- package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/Canvas2Sampler2D.js +16 -1
package/build/meep.cjs
CHANGED
|
@@ -51194,11 +51194,27 @@ class ObservedString extends String {
|
|
|
51194
51194
|
*/
|
|
51195
51195
|
ObservedString.prototype.isObservedString = true;
|
|
51196
51196
|
|
|
51197
|
+
/**
|
|
51198
|
+
*
|
|
51199
|
+
* @type {WeakMap<HTMLCanvasElement, CanvasRenderingContext2D>}
|
|
51200
|
+
*/
|
|
51201
|
+
const context_cache = new WeakMap();
|
|
51202
|
+
|
|
51203
|
+
/**
|
|
51204
|
+
*
|
|
51205
|
+
* @param {HTMLCanvasElement} canvas
|
|
51206
|
+
* @returns {Sampler2D}
|
|
51207
|
+
*/
|
|
51197
51208
|
function canvas2Sampler2D(canvas) {
|
|
51198
51209
|
const width = canvas.width;
|
|
51199
51210
|
const height = canvas.height;
|
|
51200
51211
|
|
|
51201
|
-
|
|
51212
|
+
let context = context_cache.get(canvas);
|
|
51213
|
+
|
|
51214
|
+
if (context === undefined) {
|
|
51215
|
+
context = canvas.getContext("2d");
|
|
51216
|
+
context_cache.set(canvas, context);
|
|
51217
|
+
}
|
|
51202
51218
|
|
|
51203
51219
|
const result = new Sampler2D(null, 4, width, height);
|
|
51204
51220
|
|
|
@@ -76709,6 +76725,35 @@ function computeTextureHash(t) {
|
|
|
76709
76725
|
);
|
|
76710
76726
|
}
|
|
76711
76727
|
|
|
76728
|
+
/**
|
|
76729
|
+
*
|
|
76730
|
+
* @param {HTMLCanvasElement} a
|
|
76731
|
+
* @param {HTMLCanvasElement} b
|
|
76732
|
+
* @returns {boolean}
|
|
76733
|
+
*/
|
|
76734
|
+
function computeImageCanvasEquality(a, b) {
|
|
76735
|
+
if(a === b){
|
|
76736
|
+
// shortcut
|
|
76737
|
+
return true;
|
|
76738
|
+
}
|
|
76739
|
+
|
|
76740
|
+
if (
|
|
76741
|
+
a.width !== b.width
|
|
76742
|
+
|| a.height !== b.height
|
|
76743
|
+
) {
|
|
76744
|
+
return false;
|
|
76745
|
+
}
|
|
76746
|
+
|
|
76747
|
+
const sampler_a = canvas2Sampler2D(a);
|
|
76748
|
+
const sampler_b = canvas2Sampler2D(b);
|
|
76749
|
+
|
|
76750
|
+
if(!sampler_a.equals(sampler_b)){
|
|
76751
|
+
return false;
|
|
76752
|
+
}
|
|
76753
|
+
|
|
76754
|
+
return true;
|
|
76755
|
+
}
|
|
76756
|
+
|
|
76712
76757
|
//
|
|
76713
76758
|
|
|
76714
76759
|
/**
|
|
@@ -76770,28 +76815,6 @@ function computeTextureEquality(a, b) {
|
|
|
76770
76815
|
}
|
|
76771
76816
|
|
|
76772
76817
|
|
|
76773
|
-
/**
|
|
76774
|
-
*
|
|
76775
|
-
* @param {HTMLCanvasElement} a
|
|
76776
|
-
* @param {HTMLCanvasElement} b
|
|
76777
|
-
* @returns {boolean}
|
|
76778
|
-
*/
|
|
76779
|
-
function computeImageCanvasEquality(a, b) {
|
|
76780
|
-
if (
|
|
76781
|
-
a.width !== b.width
|
|
76782
|
-
|| a.height !== b.height
|
|
76783
|
-
) {
|
|
76784
|
-
return false;
|
|
76785
|
-
}
|
|
76786
|
-
|
|
76787
|
-
if (a.toDataURL() !== b.toDataURL()) {
|
|
76788
|
-
// kinda slow, but pretty reliable, as we don't actually know what canvases hold, i.e. webgl, 2d etc.
|
|
76789
|
-
return false;
|
|
76790
|
-
}
|
|
76791
|
-
|
|
76792
|
-
return true;
|
|
76793
|
-
}
|
|
76794
|
-
|
|
76795
76818
|
/**
|
|
76796
76819
|
*
|
|
76797
76820
|
* @param {Image|ImageBitmap|HTMLCanvasElement|[]|{width:number, height:number}} a
|