@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.module.js
CHANGED
|
@@ -51192,34 +51192,34 @@ class ObservedString extends String {
|
|
|
51192
51192
|
*/
|
|
51193
51193
|
ObservedString.prototype.isObservedString = true;
|
|
51194
51194
|
|
|
51195
|
+
/**
|
|
51196
|
+
*
|
|
51197
|
+
* @type {WeakMap<HTMLCanvasElement, CanvasRenderingContext2D>}
|
|
51198
|
+
*/
|
|
51199
|
+
const context_cache = new WeakMap();
|
|
51200
|
+
|
|
51201
|
+
/**
|
|
51202
|
+
*
|
|
51203
|
+
* @param {HTMLCanvasElement} canvas
|
|
51204
|
+
* @returns {Sampler2D}
|
|
51205
|
+
*/
|
|
51195
51206
|
function canvas2Sampler2D(canvas) {
|
|
51196
51207
|
const width = canvas.width;
|
|
51197
51208
|
const height = canvas.height;
|
|
51198
51209
|
|
|
51199
|
-
|
|
51200
|
-
|
|
51201
|
-
const result = new Sampler2D(null, 4, width, height);
|
|
51202
|
-
|
|
51203
|
-
canvasDataToSampler(result, context);
|
|
51204
|
-
|
|
51205
|
-
return result;
|
|
51206
|
-
|
|
51207
|
-
}
|
|
51210
|
+
let context = context_cache.get(canvas);
|
|
51208
51211
|
|
|
51209
|
-
|
|
51210
|
-
|
|
51211
|
-
|
|
51212
|
-
|
|
51213
|
-
*/
|
|
51214
|
-
function canvasDataToSampler(target, ctx) {
|
|
51215
|
-
const width = target.width;
|
|
51216
|
-
const height = target.height;
|
|
51212
|
+
if (context === undefined) {
|
|
51213
|
+
context = canvas.getContext("2d");
|
|
51214
|
+
context_cache.set(canvas, context);
|
|
51215
|
+
}
|
|
51217
51216
|
|
|
51218
|
-
const imageData =
|
|
51217
|
+
const imageData = context.getImageData(0, 0, width, height);
|
|
51219
51218
|
|
|
51220
51219
|
const data = imageData.data;
|
|
51221
51220
|
|
|
51222
|
-
|
|
51221
|
+
return new Sampler2D(data, 4, width, height);
|
|
51222
|
+
|
|
51223
51223
|
}
|
|
51224
51224
|
|
|
51225
51225
|
/**
|
|
@@ -67687,6 +67687,22 @@ const CopyShader = {
|
|
|
67687
67687
|
|
|
67688
67688
|
};
|
|
67689
67689
|
|
|
67690
|
+
/**
|
|
67691
|
+
*
|
|
67692
|
+
* @param {Sampler2D} target
|
|
67693
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
67694
|
+
*/
|
|
67695
|
+
function canvasDataToSampler(target, ctx) {
|
|
67696
|
+
const width = target.width;
|
|
67697
|
+
const height = target.height;
|
|
67698
|
+
|
|
67699
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
67700
|
+
|
|
67701
|
+
const data = imageData.data;
|
|
67702
|
+
|
|
67703
|
+
target.data = data;
|
|
67704
|
+
}
|
|
67705
|
+
|
|
67690
67706
|
/**
|
|
67691
67707
|
* WebGL constant, declared explicitly to avoid issues with later THREE.js versions where it is absent
|
|
67692
67708
|
* @type {number}
|
|
@@ -76707,6 +76723,35 @@ function computeTextureHash(t) {
|
|
|
76707
76723
|
);
|
|
76708
76724
|
}
|
|
76709
76725
|
|
|
76726
|
+
/**
|
|
76727
|
+
*
|
|
76728
|
+
* @param {HTMLCanvasElement} a
|
|
76729
|
+
* @param {HTMLCanvasElement} b
|
|
76730
|
+
* @returns {boolean}
|
|
76731
|
+
*/
|
|
76732
|
+
function computeImageCanvasEquality(a, b) {
|
|
76733
|
+
if(a === b){
|
|
76734
|
+
// shortcut
|
|
76735
|
+
return true;
|
|
76736
|
+
}
|
|
76737
|
+
|
|
76738
|
+
if (
|
|
76739
|
+
a.width !== b.width
|
|
76740
|
+
|| a.height !== b.height
|
|
76741
|
+
) {
|
|
76742
|
+
return false;
|
|
76743
|
+
}
|
|
76744
|
+
|
|
76745
|
+
const sampler_a = canvas2Sampler2D(a);
|
|
76746
|
+
const sampler_b = canvas2Sampler2D(b);
|
|
76747
|
+
|
|
76748
|
+
if(!sampler_a.equals(sampler_b)){
|
|
76749
|
+
return false;
|
|
76750
|
+
}
|
|
76751
|
+
|
|
76752
|
+
return true;
|
|
76753
|
+
}
|
|
76754
|
+
|
|
76710
76755
|
//
|
|
76711
76756
|
|
|
76712
76757
|
/**
|
|
@@ -76768,28 +76813,6 @@ function computeTextureEquality(a, b) {
|
|
|
76768
76813
|
}
|
|
76769
76814
|
|
|
76770
76815
|
|
|
76771
|
-
/**
|
|
76772
|
-
*
|
|
76773
|
-
* @param {HTMLCanvasElement} a
|
|
76774
|
-
* @param {HTMLCanvasElement} b
|
|
76775
|
-
* @returns {boolean}
|
|
76776
|
-
*/
|
|
76777
|
-
function computeImageCanvasEquality(a, b) {
|
|
76778
|
-
if (
|
|
76779
|
-
a.width !== b.width
|
|
76780
|
-
|| a.height !== b.height
|
|
76781
|
-
) {
|
|
76782
|
-
return false;
|
|
76783
|
-
}
|
|
76784
|
-
|
|
76785
|
-
if (a.toDataURL() !== b.toDataURL()) {
|
|
76786
|
-
// kinda slow, but pretty reliable, as we don't actually know what canvases hold, i.e. webgl, 2d etc.
|
|
76787
|
-
return false;
|
|
76788
|
-
}
|
|
76789
|
-
|
|
76790
|
-
return true;
|
|
76791
|
-
}
|
|
76792
|
-
|
|
76793
76816
|
/**
|
|
76794
76817
|
*
|
|
76795
76818
|
* @param {Image|ImageBitmap|HTMLCanvasElement|[]|{width:number, height:number}} a
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,WAAW,GAAC,iBAAiB,GAAC,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACpE,8DAAM,WAAW,GAAC,iBAAiB,GAAC,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GAClE,OAAO,CAmEnB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
|
|
2
2
|
import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
|
|
3
|
+
import { computeImageCanvasEquality } from "../../../graphics/canvas/computeImageCanvasEquality.js";
|
|
3
4
|
import { isImageBitmap } from "../../../graphics/texture/isImageBitmap.js";
|
|
4
5
|
import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
|
|
5
6
|
|
|
@@ -64,28 +65,6 @@ export function computeTextureEquality(a, b) {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* @param {HTMLCanvasElement} a
|
|
70
|
-
* @param {HTMLCanvasElement} b
|
|
71
|
-
* @returns {boolean}
|
|
72
|
-
*/
|
|
73
|
-
function computeImageCanvasEquality(a, b) {
|
|
74
|
-
if (
|
|
75
|
-
a.width !== b.width
|
|
76
|
-
|| a.height !== b.height
|
|
77
|
-
) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (a.toDataURL() !== b.toDataURL()) {
|
|
82
|
-
// kinda slow, but pretty reliable, as we don't actually know what canvases hold, i.e. webgl, 2d etc.
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
68
|
/**
|
|
90
69
|
*
|
|
91
70
|
* @param {Image|ImageBitmap|HTMLCanvasElement|[]|{width:number, height:number}} a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeImageCanvasEquality.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/canvas/computeImageCanvasEquality.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,8CAJW,iBAAiB,KACjB,iBAAiB,GACf,OAAO,CAuBnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import canvas2Sampler2D from "../texture/Canvas2Sampler2D.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {HTMLCanvasElement} a
|
|
7
|
+
* @param {HTMLCanvasElement} b
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function computeImageCanvasEquality(a, b) {
|
|
11
|
+
if(a === b){
|
|
12
|
+
// shortcut
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
a.width !== b.width
|
|
18
|
+
|| a.height !== b.height
|
|
19
|
+
) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const sampler_a = canvas2Sampler2D(a);
|
|
24
|
+
const sampler_b = canvas2Sampler2D(b);
|
|
25
|
+
|
|
26
|
+
if(!sampler_a.equals(sampler_b)){
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
export default canvas2Sampler2D;
|
|
1
2
|
/**
|
|
2
3
|
*
|
|
3
|
-
* @param {
|
|
4
|
-
* @
|
|
4
|
+
* @param {HTMLCanvasElement} canvas
|
|
5
|
+
* @returns {Sampler2D}
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
export default canvas2Sampler2D;
|
|
7
|
+
declare function canvas2Sampler2D(canvas: HTMLCanvasElement): Sampler2D;
|
|
8
8
|
import { Sampler2D } from './sampler/Sampler2D.js';
|
|
9
|
-
declare function canvas2Sampler2D(canvas: any): Sampler2D;
|
|
10
9
|
//# sourceMappingURL=Canvas2Sampler2D.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas2Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/Canvas2Sampler2D.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Canvas2Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/Canvas2Sampler2D.js"],"names":[],"mappings":";AAQA;;;;GAIG;AACH,0CAHW,iBAAiB,GACf,SAAS,CAmBrB;0BA9ByB,wBAAwB"}
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import { assert } from "../../../core/assert.js";
|
|
2
1
|
import { Sampler2D } from './sampler/Sampler2D.js';
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @type {WeakMap<HTMLCanvasElement, CanvasRenderingContext2D>}
|
|
6
|
+
*/
|
|
7
|
+
const context_cache = new WeakMap();
|
|
4
8
|
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {HTMLCanvasElement} canvas
|
|
12
|
+
* @returns {Sampler2D}
|
|
13
|
+
*/
|
|
5
14
|
function canvas2Sampler2D(canvas) {
|
|
6
15
|
const width = canvas.width;
|
|
7
16
|
const height = canvas.height;
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const result = new Sampler2D(null, 4, width, height);
|
|
18
|
+
let context = context_cache.get(canvas);
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {Sampler2D} target
|
|
22
|
-
* @param {CanvasRenderingContext2D} ctx
|
|
23
|
-
*/
|
|
24
|
-
export function canvasDataToSampler(target, ctx) {
|
|
25
|
-
const width = target.width;
|
|
26
|
-
const height = target.height;
|
|
20
|
+
if (context === undefined) {
|
|
21
|
+
context = canvas.getContext("2d");
|
|
22
|
+
context_cache.set(canvas, context);
|
|
23
|
+
}
|
|
27
24
|
|
|
28
|
-
const imageData =
|
|
25
|
+
const imageData = context.getImageData(0, 0, width, height);
|
|
29
26
|
|
|
30
27
|
const data = imageData.data;
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
return new Sampler2D(data, 4, width, height);
|
|
33
30
|
|
|
34
|
-
target.data = data;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
export default canvas2Sampler2D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvasDataToSampler.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/canvasDataToSampler.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,4DAFW,wBAAwB,QAalC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Sampler2D} target
|
|
6
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
7
|
+
*/
|
|
8
|
+
export function canvasDataToSampler(target, ctx) {
|
|
9
|
+
const width = target.width;
|
|
10
|
+
const height = target.height;
|
|
11
|
+
|
|
12
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
13
|
+
|
|
14
|
+
const data = imageData.data;
|
|
15
|
+
|
|
16
|
+
assert.equal(data.length, target.height * target.width * target.itemSize);
|
|
17
|
+
|
|
18
|
+
target.data = data;
|
|
19
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertTexture2Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertTexture2Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js"],"names":[],"mappings":"AAwEA;;;;;;;GAOG;AACH,mEALW,MAAM,WACN,MAAM,UACN,OAAO,GACN,SAAS,CAyFpB;0BA9JyB,gBAAgB"}
|
|
@@ -3,7 +3,8 @@ import ImageFilter from "../../filter/ImageFilter.js";
|
|
|
3
3
|
import { sampler2d_flipY_in_place } from "../../filter/sampler2d_flipY_in_place.js";
|
|
4
4
|
import CopyShader from "../../postprocess/threejs/shaders/CopyShader.js";
|
|
5
5
|
import { WebGLRendererPool } from "../../render/RendererPool.js";
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import { canvasDataToSampler } from "../canvasDataToSampler.js";
|
|
7
8
|
import { formatToChannelCount } from "../formatToChannelCount.js";
|
|
8
9
|
import { sampler2d_scale } from "./resize/sampler2d_scale.js";
|
|
9
10
|
import { Sampler2D } from "./Sampler2D.js";
|