@woosh/meep-engine 2.117.12 → 2.117.14
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 +64 -41
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +64 -41
- package/package.json +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 +4 -5
- package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/Canvas2Sampler2D.js +17 -21
- package/src/engine/graphics/texture/canvasDataToSampler.d.ts +7 -0
- package/src/engine/graphics/texture/canvasDataToSampler.d.ts.map +1 -0
- package/src/engine/graphics/texture/canvasDataToSampler.js +19 -0
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +2 -1
package/build/meep.cjs
CHANGED
|
@@ -51194,34 +51194,34 @@ 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
|
-
|
|
51202
|
-
|
|
51203
|
-
const result = new Sampler2D(null, 4, width, height);
|
|
51204
|
-
|
|
51205
|
-
canvasDataToSampler(result, context);
|
|
51206
|
-
|
|
51207
|
-
return result;
|
|
51208
|
-
|
|
51209
|
-
}
|
|
51212
|
+
let context = context_cache.get(canvas);
|
|
51210
51213
|
|
|
51211
|
-
|
|
51212
|
-
|
|
51213
|
-
|
|
51214
|
-
|
|
51215
|
-
*/
|
|
51216
|
-
function canvasDataToSampler(target, ctx) {
|
|
51217
|
-
const width = target.width;
|
|
51218
|
-
const height = target.height;
|
|
51214
|
+
if (context === undefined) {
|
|
51215
|
+
context = canvas.getContext("2d");
|
|
51216
|
+
context_cache.set(canvas, context);
|
|
51217
|
+
}
|
|
51219
51218
|
|
|
51220
|
-
const imageData =
|
|
51219
|
+
const imageData = context.getImageData(0, 0, width, height);
|
|
51221
51220
|
|
|
51222
51221
|
const data = imageData.data;
|
|
51223
51222
|
|
|
51224
|
-
|
|
51223
|
+
return new Sampler2D(data, 4, width, height);
|
|
51224
|
+
|
|
51225
51225
|
}
|
|
51226
51226
|
|
|
51227
51227
|
/**
|
|
@@ -67689,6 +67689,22 @@ const CopyShader = {
|
|
|
67689
67689
|
|
|
67690
67690
|
};
|
|
67691
67691
|
|
|
67692
|
+
/**
|
|
67693
|
+
*
|
|
67694
|
+
* @param {Sampler2D} target
|
|
67695
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
67696
|
+
*/
|
|
67697
|
+
function canvasDataToSampler(target, ctx) {
|
|
67698
|
+
const width = target.width;
|
|
67699
|
+
const height = target.height;
|
|
67700
|
+
|
|
67701
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
67702
|
+
|
|
67703
|
+
const data = imageData.data;
|
|
67704
|
+
|
|
67705
|
+
target.data = data;
|
|
67706
|
+
}
|
|
67707
|
+
|
|
67692
67708
|
/**
|
|
67693
67709
|
* WebGL constant, declared explicitly to avoid issues with later THREE.js versions where it is absent
|
|
67694
67710
|
* @type {number}
|
|
@@ -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
|