@woosh/meep-engine 2.100.2 → 2.101.0
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 +109 -97
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +109 -97
- package/package.json +1 -1
- package/src/core/binary/downloadUrlAsFile.d.ts.map +1 -1
- package/src/core/binary/downloadUrlAsFile.js +3 -1
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/asset/AssetManager.js +6 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts +2 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.js +107 -99
- package/src/engine/graphics/FrameRunner.d.ts +5 -13
- package/src/engine/graphics/FrameRunner.d.ts.map +1 -1
- package/src/engine/graphics/FrameRunner.js +31 -25
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.d.ts +1 -1
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js +4 -4
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts +1 -2
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +1 -2
- package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.js +8 -0
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
1
5
|
let global_count = 0;
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
8
|
+
* Fires a given function every frame. Typical usage is to create an instance, invoke {@link #startup} and once no longer required - invoke {@link #shutdown}
|
|
9
|
+
* Wraps {@link requestAnimationFrame}
|
|
5
10
|
*/
|
|
6
11
|
export class FrameRunner {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {boolean}
|
|
15
|
+
*/
|
|
16
|
+
#running = false;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
#animationFrameId = -1;
|
|
22
|
+
|
|
7
23
|
/**
|
|
8
24
|
*
|
|
9
25
|
* @param {function} action
|
|
@@ -14,66 +30,56 @@ export class FrameRunner {
|
|
|
14
30
|
* @type {Function}
|
|
15
31
|
*/
|
|
16
32
|
this.action = action;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @type {boolean}
|
|
20
|
-
*/
|
|
21
|
-
this.running = false;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {number}
|
|
25
|
-
*/
|
|
26
|
-
this.animationFrameId = -1;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
36
|
+
* Begins animation loop. Does nothing and returns false if already running.
|
|
31
37
|
* @returns {boolean}
|
|
32
38
|
*/
|
|
33
39
|
startup() {
|
|
34
|
-
if (this
|
|
40
|
+
if (this.#running) {
|
|
35
41
|
return false;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
console.warn(`FrameFunner.started[${global_count}]`);
|
|
44
|
+
// console.warn(`FrameFunner.started[${global_count}]`);
|
|
39
45
|
|
|
40
46
|
global_count++;
|
|
41
47
|
|
|
42
|
-
this
|
|
48
|
+
this.#running = true;
|
|
43
49
|
|
|
44
50
|
const cycle = () => {
|
|
45
|
-
if (!this
|
|
51
|
+
if (!this.#running) {
|
|
46
52
|
//not supposed to be running, bail
|
|
47
53
|
return;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
this.action();
|
|
51
57
|
|
|
52
|
-
this
|
|
58
|
+
this.#animationFrameId = requestAnimationFrame(cycle);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
this
|
|
61
|
+
this.#animationFrameId = requestAnimationFrame(cycle);
|
|
56
62
|
|
|
57
63
|
return true;
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
/**
|
|
61
|
-
*
|
|
67
|
+
* Stops animation loop. Does nothing and returns false if not currently running.
|
|
62
68
|
* @returns {boolean}
|
|
63
69
|
*/
|
|
64
70
|
shutdown() {
|
|
65
|
-
if (!this
|
|
71
|
+
if (!this.#running) {
|
|
66
72
|
return false;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
global_count--;
|
|
70
76
|
|
|
71
|
-
console.warn(`FrameFunner.stopped[${global_count}]`);
|
|
77
|
+
// console.warn(`FrameFunner.stopped[${global_count}]`);
|
|
72
78
|
|
|
73
|
-
this
|
|
74
|
-
cancelAnimationFrame(this
|
|
79
|
+
this.#running = false;
|
|
80
|
+
cancelAnimationFrame(this.#animationFrameId);
|
|
75
81
|
|
|
76
|
-
this
|
|
82
|
+
this.#animationFrameId = -1;
|
|
77
83
|
|
|
78
84
|
return true;
|
|
79
85
|
}
|
|
@@ -83,6 +89,6 @@ export class FrameRunner {
|
|
|
83
89
|
* @returns {boolean}
|
|
84
90
|
*/
|
|
85
91
|
isRunning() {
|
|
86
|
-
return this
|
|
92
|
+
return this.#running;
|
|
87
93
|
}
|
|
88
94
|
}
|
|
@@ -22,7 +22,7 @@ export class HarmonicDiffusionGrid {
|
|
|
22
22
|
*/
|
|
23
23
|
height: number;
|
|
24
24
|
/**
|
|
25
|
-
* Maps which indices are assigned with values
|
|
25
|
+
* Maps which indices are assigned with values. Assigned cells retain their original values
|
|
26
26
|
* @type {BitSet}
|
|
27
27
|
*/
|
|
28
28
|
assignment: BitSet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HarmonicDiffusionGrid.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js"],"names":[],"mappings":"AAGA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,SAClC,MAAM,UACN,MAAM,EA6BhB;IArBG;;;OAGG;IACH,MAFU,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,CAE5B;IAChB;;;OAGG;IACH,OAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,YAFU,MAAM,CAEc;IAGlC;;OAEG;IACH,cAGC;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,SACN,MAAM,QAyBhB;IAED;;OAEG;IACH,aA8DC;CACJ;
|
|
1
|
+
{"version":3,"file":"HarmonicDiffusionGrid.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js"],"names":[],"mappings":"AAGA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,SAClC,MAAM,UACN,MAAM,EA6BhB;IArBG;;;OAGG;IACH,MAFU,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,CAE5B;IAChB;;;OAGG;IACH,OAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,YAFU,MAAM,CAEc;IAGlC;;OAEG;IACH,cAGC;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,SACN,MAAM,QAyBhB;IAED;;OAEG;IACH,aA8DC;CACJ;uBA/IsB,mCAAmC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
2
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
3
3
|
|
|
4
4
|
export class HarmonicDiffusionGrid {
|
|
5
5
|
/**
|
|
@@ -9,8 +9,8 @@ export class HarmonicDiffusionGrid {
|
|
|
9
9
|
* @param {number} height
|
|
10
10
|
*/
|
|
11
11
|
constructor(data, width, height) {
|
|
12
|
-
assert.
|
|
13
|
-
assert.
|
|
12
|
+
assert.isNonNegativeInteger(width, 'width');
|
|
13
|
+
assert.isNonNegativeInteger(height, 'height');
|
|
14
14
|
|
|
15
15
|
assert.equal(data.length, width * height, `data.length(=${data.length}) is not equal to product of width(=${width})*height(=${height})`);
|
|
16
16
|
|
|
@@ -31,7 +31,7 @@ export class HarmonicDiffusionGrid {
|
|
|
31
31
|
this.height = height;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Maps which indices are assigned with values
|
|
34
|
+
* Maps which indices are assigned with values. Assigned cells retain their original values
|
|
35
35
|
* @type {BitSet}
|
|
36
36
|
*/
|
|
37
37
|
this.assignment = new BitSet();
|
|
@@ -5,9 +5,8 @@ export default convertSampler2D2Canvas;
|
|
|
5
5
|
* @param {Number} [scale]
|
|
6
6
|
* @param {Number} [offset]
|
|
7
7
|
* @param {HTMLCanvasElement} [canvas] if no canvas is supplied, a new one will be created
|
|
8
|
-
* @param {function(index:int, array:ArrayLike<number>, x:int, y:int)} [fillDD] allows you to supply mapping function, if none is given - one will be created from sampler
|
|
9
8
|
* @returns {HTMLCanvasElement} canvas
|
|
10
9
|
*/
|
|
11
|
-
declare function convertSampler2D2Canvas(sampler: Sampler2D, scale?: number, offset?: number, canvas?: HTMLCanvasElement
|
|
10
|
+
declare function convertSampler2D2Canvas(sampler: Sampler2D, scale?: number, offset?: number, canvas?: HTMLCanvasElement): HTMLCanvasElement;
|
|
12
11
|
import { Sampler2D } from "./Sampler2D.js";
|
|
13
12
|
//# sourceMappingURL=Sampler2D2Canvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sampler2D2Canvas.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js"],"names":[],"mappings":";AAQA
|
|
1
|
+
{"version":3,"file":"Sampler2D2Canvas.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js"],"names":[],"mappings":";AAQA;;;;;;;GAOG;AACH,kDANW,SAAS,4CAGT,iBAAiB,GACf,iBAAiB,CA2E7B;0BApFyB,gBAAgB"}
|
|
@@ -12,10 +12,9 @@ import { sampler2d_write_to_canvas_raw } from "./sampler2d_write_to_canvas_raw.j
|
|
|
12
12
|
* @param {Number} [scale]
|
|
13
13
|
* @param {Number} [offset]
|
|
14
14
|
* @param {HTMLCanvasElement} [canvas] if no canvas is supplied, a new one will be created
|
|
15
|
-
* @param {function(index:int, array:ArrayLike<number>, x:int, y:int)} [fillDD] allows you to supply mapping function, if none is given - one will be created from sampler
|
|
16
15
|
* @returns {HTMLCanvasElement} canvas
|
|
17
16
|
*/
|
|
18
|
-
function convertSampler2D2Canvas(sampler, scale = 255, offset = 0, canvas
|
|
17
|
+
function convertSampler2D2Canvas(sampler, scale = 255, offset = 0, canvas) {
|
|
19
18
|
const source_data = sampler.data;
|
|
20
19
|
|
|
21
20
|
//generate canvas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler2d_to_uint8_RGBA.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.js"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"sampler2d_to_uint8_RGBA.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.js"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,mFA6DC"}
|
|
@@ -65,6 +65,8 @@ export function sampler2d_to_uint8_RGBA(output, input) {
|
|
|
65
65
|
|
|
66
66
|
if (source_item_size === 1) {
|
|
67
67
|
|
|
68
|
+
// grayscale
|
|
69
|
+
|
|
68
70
|
sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
|
|
69
71
|
sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
|
|
70
72
|
sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
|
|
@@ -73,6 +75,8 @@ export function sampler2d_to_uint8_RGBA(output, input) {
|
|
|
73
75
|
|
|
74
76
|
} else if (source_item_size === 2) {
|
|
75
77
|
|
|
78
|
+
// grayscale with alpha
|
|
79
|
+
|
|
76
80
|
sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
|
|
77
81
|
sampler2d_channel_linear_transform(output, input, 1, 0, gradient, intercept);
|
|
78
82
|
sampler2d_channel_linear_transform(output, input, 2, 0, gradient, intercept);
|
|
@@ -80,6 +84,8 @@ export function sampler2d_to_uint8_RGBA(output, input) {
|
|
|
80
84
|
|
|
81
85
|
} else if (source_item_size === 3) {
|
|
82
86
|
|
|
87
|
+
// RGB
|
|
88
|
+
|
|
83
89
|
sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
|
|
84
90
|
sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
|
|
85
91
|
sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
|
|
@@ -88,6 +94,8 @@ export function sampler2d_to_uint8_RGBA(output, input) {
|
|
|
88
94
|
|
|
89
95
|
} else if (source_item_size === 4) {
|
|
90
96
|
|
|
97
|
+
// RGBA
|
|
98
|
+
|
|
91
99
|
sampler2d_channel_linear_transform(output, input, 0, 0, gradient, intercept);
|
|
92
100
|
sampler2d_channel_linear_transform(output, input, 1, 1, gradient, intercept);
|
|
93
101
|
sampler2d_channel_linear_transform(output, input, 2, 2, gradient, intercept);
|