@woosh/meep-engine 2.94.7 → 2.95.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 +44 -13
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +44 -13
- package/package.json +1 -1
- package/src/core/collection/array/array_deduplicate.d.ts +8 -0
- package/src/core/collection/array/array_deduplicate.d.ts.map +1 -0
- package/src/core/collection/array/array_deduplicate.js +9 -0
- package/src/core/collection/array/array_deduplicate.spec.d.ts +2 -0
- package/src/core/collection/array/array_deduplicate.spec.d.ts.map +1 -0
- package/src/core/collection/array/array_deduplicate.spec.js +11 -0
- package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstance.js +37 -17
- package/src/engine/simulation/Ticker.d.ts +8 -9
- package/src/engine/simulation/Ticker.d.ts.map +1 -1
- package/src/engine/simulation/Ticker.js +43 -10
package/build/meep.module.js
CHANGED
|
@@ -95604,6 +95604,8 @@ class Ticker {
|
|
|
95604
95604
|
*/
|
|
95605
95605
|
#isRunning = false;
|
|
95606
95606
|
|
|
95607
|
+
#animationFrameHandle = -1;
|
|
95608
|
+
#timeoutHandle = -1;
|
|
95607
95609
|
|
|
95608
95610
|
/**
|
|
95609
95611
|
* Dispatches time delta in seconds since last tick
|
|
@@ -95633,6 +95635,7 @@ class Ticker {
|
|
|
95633
95635
|
* @param {*} [thisArg]
|
|
95634
95636
|
*/
|
|
95635
95637
|
subscribe(callback, thisArg) {
|
|
95638
|
+
|
|
95636
95639
|
this.onTick.add(callback, thisArg);
|
|
95637
95640
|
}
|
|
95638
95641
|
|
|
@@ -95642,17 +95645,23 @@ class Ticker {
|
|
|
95642
95645
|
* @param {*} [thisArg]
|
|
95643
95646
|
*/
|
|
95644
95647
|
unsubscribe(callback, thisArg) {
|
|
95648
|
+
|
|
95645
95649
|
this.onTick.remove(callback, thisArg);
|
|
95646
95650
|
}
|
|
95647
95651
|
|
|
95652
|
+
#isUpdateLoopActive() {
|
|
95653
|
+
return this.#timeoutHandle !== -1 && this.#animationFrameHandle !== -1;
|
|
95654
|
+
}
|
|
95655
|
+
|
|
95648
95656
|
/**
|
|
95649
95657
|
*
|
|
95650
95658
|
* @param {number} [maxTimeout]
|
|
95651
95659
|
*/
|
|
95652
95660
|
start({ maxTimeout = 100 } = {}) {
|
|
95653
95661
|
|
|
95654
|
-
|
|
95655
|
-
|
|
95662
|
+
if (this.#isUpdateLoopActive()) {
|
|
95663
|
+
throw new Error("Already running");
|
|
95664
|
+
}
|
|
95656
95665
|
|
|
95657
95666
|
this.#isRunning = true;
|
|
95658
95667
|
|
|
@@ -95666,23 +95675,25 @@ class Ticker {
|
|
|
95666
95675
|
this.onTick.send1(delta);
|
|
95667
95676
|
};
|
|
95668
95677
|
|
|
95669
|
-
|
|
95670
|
-
cancelAnimationFrame(
|
|
95678
|
+
const timeoutCallback = () => {
|
|
95679
|
+
cancelAnimationFrame(this.#animationFrameHandle);
|
|
95671
95680
|
animate();
|
|
95672
|
-
}
|
|
95681
|
+
};
|
|
95673
95682
|
|
|
95674
|
-
|
|
95675
|
-
clearTimeout(
|
|
95683
|
+
const animationFrameCallback = () => {
|
|
95684
|
+
clearTimeout(this.#timeoutHandle);
|
|
95676
95685
|
|
|
95677
95686
|
//push tick beyond animation frame stack allowing draw to happen
|
|
95678
|
-
setTimeout(animate, 0);
|
|
95679
|
-
}
|
|
95687
|
+
this.#timeoutHandle = setTimeout(animate, 0);
|
|
95688
|
+
};
|
|
95689
|
+
|
|
95690
|
+
const animate = () => {
|
|
95691
|
+
this.#animationFrameHandle = requestAnimationFrame(animationFrameCallback);
|
|
95680
95692
|
|
|
95681
|
-
function animate() {
|
|
95682
|
-
animationFrame = requestAnimationFrame(animationFrameCallback);
|
|
95683
95693
|
update();
|
|
95684
|
-
|
|
95685
|
-
|
|
95694
|
+
|
|
95695
|
+
this.#timeoutHandle = setTimeout(timeoutCallback, maxTimeout);
|
|
95696
|
+
};
|
|
95686
95697
|
|
|
95687
95698
|
this.clock.getDelta(); //purge delta
|
|
95688
95699
|
this.clock.start();
|
|
@@ -95691,12 +95702,32 @@ class Ticker {
|
|
|
95691
95702
|
}
|
|
95692
95703
|
|
|
95693
95704
|
pause() {
|
|
95705
|
+
|
|
95706
|
+
if (!this.#isUpdateLoopActive()) {
|
|
95707
|
+
throw new Error("Not currently running");
|
|
95708
|
+
}
|
|
95709
|
+
|
|
95694
95710
|
this.#isRunning = false;
|
|
95695
95711
|
}
|
|
95696
95712
|
|
|
95697
95713
|
resume() {
|
|
95714
|
+
|
|
95715
|
+
if (!this.#isUpdateLoopActive()) {
|
|
95716
|
+
throw new Error("Not currently running");
|
|
95717
|
+
}
|
|
95718
|
+
|
|
95719
|
+
|
|
95698
95720
|
this.#isRunning = true;
|
|
95699
95721
|
}
|
|
95722
|
+
|
|
95723
|
+
stop() {
|
|
95724
|
+
clearTimeout(this.#timeoutHandle);
|
|
95725
|
+
cancelAnimationFrame(this.#animationFrameHandle);
|
|
95726
|
+
this.#isRunning = false;
|
|
95727
|
+
|
|
95728
|
+
this.#timeoutHandle = -1;
|
|
95729
|
+
this.#animationFrameHandle = -1;
|
|
95730
|
+
}
|
|
95700
95731
|
}
|
|
95701
95732
|
|
|
95702
95733
|
/**
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_deduplicate.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_deduplicate.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_deduplicate.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_deduplicate.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { array_deduplicate } from "./array_deduplicate.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
expect(array_deduplicate([])).toEqual([]);
|
|
5
|
+
expect(array_deduplicate([1])).toEqual([1]);
|
|
6
|
+
expect(array_deduplicate([1, 2])).toEqual([1, 2]);
|
|
7
|
+
expect(array_deduplicate([1, 2, 2])).toEqual([1, 2]);
|
|
8
|
+
expect(array_deduplicate([1, 2, 1])).toEqual([1, 2]);
|
|
9
|
+
expect(array_deduplicate([1, 1, 2])).toEqual([1, 2]);
|
|
10
|
+
expect(array_deduplicate([1, 2])).toEqual([1, 2]);
|
|
11
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;IAEI;;;OAGG;IACH,IAFU,MAAM,CAEE;IAElB;;;OAGG;IACH,6BAAmB;IAEnB;;;OAGG;IACH,WAFU,yBAAyB,EAAE,CAEtB;IAEf;;;OAGG;IACH,gBAAgB;IAEhB;;;OAGG;IACH,qBAAmB;IAEnB;;;OAGG;IACH,aAFU,gBAAgB,CAED;IAEzB;;;;;;OAMG;IACH,wBAFU,MAAM,CAEE;IAElB;;OAEG;IACH;QACI;;;WAGG;mCADO,OAAO,MAAM,WAAO;QAG9B;;;WAGG;iCADO,OAAO,MAAM,MAAI;QAG3B;;;WAGG;mCADO,OAAO,MAAM,MAAI;
|
|
1
|
+
{"version":3,"file":"NodeInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/node/NodeInstance.js"],"names":[],"mappings":"AAcA;IAEI;;;OAGG;IACH,IAFU,MAAM,CAEE;IAElB;;;OAGG;IACH,6BAAmB;IAEnB;;;OAGG;IACH,WAFU,yBAAyB,EAAE,CAEtB;IAEf;;;OAGG;IACH,gBAAgB;IAEhB;;;OAGG;IACH,qBAAmB;IAEnB;;;OAGG;IACH,aAFU,gBAAgB,CAED;IAEzB;;;;;;OAMG;IACH,wBAFU,MAAM,CAEE;IAElB;;OAEG;IACH;QACI;;;WAGG;mCADO,OAAO,MAAM,WAAO;QAG9B;;;WAGG;iCADO,OAAO,MAAM,MAAI;QAG3B;;;WAGG;mCADO,OAAO,MAAM,MAAI;QAI3B;;;;WAIG;qCADO,wCAAwC;MAGpD;IAEF;;;;;;OAMG;IACH,yBALW,MAAM,aACN,aAAa,UACb,YAAY,GACV,MAAM,CAsBlB;IAED;;;OAGG;IACH,gDAEC;IAED;;;OAGG;IACH,+CAEC;IAGD;;;OAGG;IACH,mCAEC;IAED;;;;OAIG;IACH,kCAEC;IAED;;;;OAIG;IACH,mBAHW,MAAM,oBAKhB;IAED;;;;OAIG;IACH,mBAHW,MAAM,OAKhB;IAED;;;;OAIG;IACH,yBAHW,MAAM,KAOhB;IAED;;;;OAIG;IACH,2BAHW,MAAM,oBAmChB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,OAAO,CAkBnB;IAED;;;OAGG;IACH,uCAQC;IAED,wBAIC;IAED;;;OAGG;IACH,mDAqCC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,yBAAyB,GAAC,SAAS,CAe/C;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,YAAY,GACV,OAAO,CAQnB;IAED,mBAEC;IAIL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CAPpC;0CArVyC,gCAAgC;iBAHzD,kCAAkC;mBAChC,kCAAkC;8BAGvB,oBAAoB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {assert} from "../../../assert.js";
|
|
2
|
-
import {isArrayEqual} from "../../../collection/array/isArrayEqual.js";
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
import { isArrayEqual } from "../../../collection/array/isArrayEqual.js";
|
|
3
3
|
import List from "../../../collection/list/List.js";
|
|
4
4
|
import Signal from "../../../events/signal/Signal.js";
|
|
5
|
-
import {objectDeepEquals} from "../../object/objectDeepEquals.js";
|
|
6
|
-
import {NodeInstancePortReference} from "./NodeInstancePortReference.js";
|
|
7
|
-
import {PortDirection} from "./PortDirection.js";
|
|
5
|
+
import { objectDeepEquals } from "../../object/objectDeepEquals.js";
|
|
6
|
+
import { NodeInstancePortReference } from "./NodeInstancePortReference.js";
|
|
7
|
+
import { PortDirection } from "./PortDirection.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -78,6 +78,13 @@ export class NodeInstance {
|
|
|
78
78
|
* @type {Signal<string, *>}
|
|
79
79
|
*/
|
|
80
80
|
parameterRemoved: new Signal(),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* fires: (newDescription:NodeDescription, oldDescription:NodeDescription|null)
|
|
84
|
+
* @readonly
|
|
85
|
+
* @type {Signal<NodeDescription, NodeDescription>}
|
|
86
|
+
*/
|
|
87
|
+
descriptionChanged: new Signal()
|
|
81
88
|
};
|
|
82
89
|
|
|
83
90
|
/**
|
|
@@ -256,32 +263,45 @@ export class NodeInstance {
|
|
|
256
263
|
|
|
257
264
|
/**
|
|
258
265
|
*
|
|
259
|
-
* @param {NodeDescription}
|
|
266
|
+
* @param {NodeDescription} description
|
|
260
267
|
*/
|
|
261
|
-
setDescription(
|
|
262
|
-
|
|
268
|
+
setDescription(description) {
|
|
269
|
+
assert.defined(description, 'description');
|
|
270
|
+
assert.isObject(description, 'description');
|
|
271
|
+
assert.equal(description.isNodeDescription, true, 'description.isNodeDescription !== true');
|
|
272
|
+
|
|
273
|
+
if (!this.connections.isEmpty()) {
|
|
274
|
+
throw new Error("Node is has connections, can only change description for unconnected nodes");
|
|
275
|
+
}
|
|
263
276
|
|
|
264
|
-
|
|
277
|
+
const old_description = this.description;
|
|
278
|
+
|
|
279
|
+
this.description = description;
|
|
280
|
+
|
|
281
|
+
description.configureNode(this);
|
|
265
282
|
|
|
266
283
|
//generate endpoints
|
|
267
|
-
this.endpoints =
|
|
268
|
-
|
|
284
|
+
this.endpoints = description.getPorts()
|
|
285
|
+
.map((port, port_index) => {
|
|
286
|
+
const endpoint = new NodeInstancePortReference();
|
|
269
287
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
288
|
+
endpoint.id = port_index;
|
|
289
|
+
endpoint.port = port;
|
|
290
|
+
endpoint.instance = this;
|
|
273
291
|
|
|
274
|
-
|
|
275
|
-
|
|
292
|
+
return endpoint;
|
|
293
|
+
});
|
|
276
294
|
|
|
277
295
|
//clear parameters
|
|
278
296
|
this.clearParameters();
|
|
279
297
|
|
|
280
298
|
// TODO address parameters in NodeDescription as well
|
|
281
299
|
//populate parameter defaults
|
|
282
|
-
|
|
300
|
+
description.parameters.forEach(pd => {
|
|
283
301
|
this.parameters[pd.id] = pd.defaultValue;
|
|
284
302
|
});
|
|
303
|
+
|
|
304
|
+
this.on.descriptionChanged.send2(description, old_description);
|
|
285
305
|
}
|
|
286
306
|
|
|
287
307
|
/**
|
|
@@ -3,13 +3,12 @@ import Signal from "../../core/events/signal/Signal";
|
|
|
3
3
|
export default class Ticker {
|
|
4
4
|
readonly onTick: Signal<number>
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
unsubscribe(f: (timeDelta: number) => any, thisArg?: any): void
|
|
6
|
+
start(): void
|
|
7
|
+
|
|
8
|
+
stop(): void
|
|
9
|
+
|
|
10
|
+
pause(): void
|
|
11
|
+
|
|
12
|
+
resume(): void
|
|
13
|
+
|
|
15
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ticker.d.ts","sourceRoot":"","sources":["../../../../src/engine/simulation/Ticker.js"],"names":[],"mappings":";AAOA;;;;GAIG;AACH;IACI;;;OAGG;IACH,gBAFU,KAAK,CAEK;
|
|
1
|
+
{"version":3,"file":"Ticker.d.ts","sourceRoot":"","sources":["../../../../src/engine/simulation/Ticker.js"],"names":[],"mappings":";AAOA;;;;GAIG;AACH;IACI;;;OAGG;IACH,gBAFU,KAAK,CAEK;IAWpB;;;;OAIG;IACH,iBAFU,OAAO,MAAM,CAAC,CAEF;IAEtB;;OAEG;IACH,sBAEC;IAUD;;;;OAIG;IACH,mDAIC;IAED;;;;OAIG;IACH,qDAIC;IAMD;;;OAGG;IACH,uBAFW,MAAM,QA8ChB;IAED,cAOC;IAED,eAQC;IAED,aAOC;;CACJ;kBApJiB,aAAa;mBADZ,oCAAoC"}
|
|
@@ -23,6 +23,8 @@ class Ticker {
|
|
|
23
23
|
*/
|
|
24
24
|
#isRunning = false;
|
|
25
25
|
|
|
26
|
+
#animationFrameHandle = -1;
|
|
27
|
+
#timeoutHandle = -1;
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Dispatches time delta in seconds since last tick
|
|
@@ -52,6 +54,8 @@ class Ticker {
|
|
|
52
54
|
* @param {*} [thisArg]
|
|
53
55
|
*/
|
|
54
56
|
subscribe(callback, thisArg) {
|
|
57
|
+
console.warn('deprecated use onTick signal directly instead');
|
|
58
|
+
|
|
55
59
|
this.onTick.add(callback, thisArg);
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -61,9 +65,15 @@ class Ticker {
|
|
|
61
65
|
* @param {*} [thisArg]
|
|
62
66
|
*/
|
|
63
67
|
unsubscribe(callback, thisArg) {
|
|
68
|
+
console.warn('deprecated use onTick signal directly instead');
|
|
69
|
+
|
|
64
70
|
this.onTick.remove(callback, thisArg);
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
#isUpdateLoopActive() {
|
|
74
|
+
return this.#timeoutHandle !== -1 && this.#animationFrameHandle !== -1;
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
/**
|
|
68
78
|
*
|
|
69
79
|
* @param {number} [maxTimeout]
|
|
@@ -72,8 +82,9 @@ class Ticker {
|
|
|
72
82
|
assert.isNumber(maxTimeout, 'maxTimeout');
|
|
73
83
|
assert.greaterThan(maxTimeout, 0);
|
|
74
84
|
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
if (this.#isUpdateLoopActive()) {
|
|
86
|
+
throw new Error("Already running");
|
|
87
|
+
}
|
|
77
88
|
|
|
78
89
|
this.#isRunning = true;
|
|
79
90
|
|
|
@@ -87,22 +98,24 @@ class Ticker {
|
|
|
87
98
|
this.onTick.send1(delta);
|
|
88
99
|
}
|
|
89
100
|
|
|
90
|
-
|
|
91
|
-
cancelAnimationFrame(
|
|
101
|
+
const timeoutCallback = () => {
|
|
102
|
+
cancelAnimationFrame(this.#animationFrameHandle);
|
|
92
103
|
animate();
|
|
93
104
|
}
|
|
94
105
|
|
|
95
|
-
|
|
96
|
-
clearTimeout(
|
|
106
|
+
const animationFrameCallback = () => {
|
|
107
|
+
clearTimeout(this.#timeoutHandle);
|
|
97
108
|
|
|
98
109
|
//push tick beyond animation frame stack allowing draw to happen
|
|
99
|
-
setTimeout(animate, 0);
|
|
110
|
+
this.#timeoutHandle = setTimeout(animate, 0);
|
|
100
111
|
}
|
|
101
112
|
|
|
102
|
-
|
|
103
|
-
|
|
113
|
+
const animate = () => {
|
|
114
|
+
this.#animationFrameHandle = requestAnimationFrame(animationFrameCallback);
|
|
115
|
+
|
|
104
116
|
update();
|
|
105
|
-
|
|
117
|
+
|
|
118
|
+
this.#timeoutHandle = setTimeout(timeoutCallback, maxTimeout);
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
this.clock.getDelta(); //purge delta
|
|
@@ -112,12 +125,32 @@ class Ticker {
|
|
|
112
125
|
}
|
|
113
126
|
|
|
114
127
|
pause() {
|
|
128
|
+
|
|
129
|
+
if (!this.#isUpdateLoopActive()) {
|
|
130
|
+
throw new Error("Not currently running");
|
|
131
|
+
}
|
|
132
|
+
|
|
115
133
|
this.#isRunning = false;
|
|
116
134
|
}
|
|
117
135
|
|
|
118
136
|
resume() {
|
|
137
|
+
|
|
138
|
+
if (!this.#isUpdateLoopActive()) {
|
|
139
|
+
throw new Error("Not currently running");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
119
143
|
this.#isRunning = true;
|
|
120
144
|
}
|
|
145
|
+
|
|
146
|
+
stop() {
|
|
147
|
+
clearTimeout(this.#timeoutHandle);
|
|
148
|
+
cancelAnimationFrame(this.#animationFrameHandle);
|
|
149
|
+
this.#isRunning = false;
|
|
150
|
+
|
|
151
|
+
this.#timeoutHandle = -1;
|
|
152
|
+
this.#animationFrameHandle = -1;
|
|
153
|
+
}
|
|
121
154
|
}
|
|
122
155
|
|
|
123
156
|
export default Ticker;
|