@woosh/meep-engine 2.100.0 → 2.100.2

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.
Files changed (58) hide show
  1. package/build/meep.cjs +574 -19
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +574 -19
  4. package/package.json +1 -1
  5. package/src/core/color/Color.d.ts.map +1 -1
  6. package/src/core/color/Color.js +39 -8
  7. package/src/core/color/oklab/Okhsv.spec.d.ts +2 -0
  8. package/src/core/color/oklab/Okhsv.spec.d.ts.map +1 -0
  9. package/src/core/color/oklab/Okhsv.spec.js +17 -0
  10. package/src/core/color/oklab/XYZ.spec.js +2 -2
  11. package/src/core/color/oklab/compute_max_saturation.d.ts +11 -0
  12. package/src/core/color/oklab/compute_max_saturation.d.ts.map +1 -0
  13. package/src/core/color/oklab/compute_max_saturation.js +84 -0
  14. package/src/core/color/oklab/find_cusp.d.ts +10 -0
  15. package/src/core/color/oklab/find_cusp.d.ts.map +1 -0
  16. package/src/core/color/oklab/find_cusp.js +27 -0
  17. package/src/core/color/oklab/find_gamut_intersection.d.ts +15 -0
  18. package/src/core/color/oklab/find_gamut_intersection.d.ts.map +1 -0
  19. package/src/core/color/oklab/find_gamut_intersection.js +101 -0
  20. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts +9 -0
  21. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts.map +1 -0
  22. package/src/core/color/oklab/linear_srgb_to_okhsv.js +74 -0
  23. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts +9 -0
  24. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts.map +1 -0
  25. package/src/core/color/oklab/linear_srgb_to_oklab.js +20 -0
  26. package/src/core/color/oklab/okhsv_to_linear_srgb.d.ts +9 -0
  27. package/src/core/color/oklab/okhsv_to_linear_srgb.d.ts.map +1 -0
  28. package/src/core/color/oklab/okhsv_to_linear_srgb.js +59 -0
  29. package/src/core/color/oklab/oklab_to_linear_srgb.d.ts +10 -0
  30. package/src/core/color/oklab/oklab_to_linear_srgb.d.ts.map +1 -0
  31. package/src/core/color/oklab/oklab_to_linear_srgb.js +21 -0
  32. package/src/core/color/oklab/oklab_to_xyz.d.ts +5 -2
  33. package/src/core/color/oklab/oklab_to_xyz.d.ts.map +1 -1
  34. package/src/core/color/oklab/oklab_to_xyz.js +5 -5
  35. package/src/core/color/oklab/oklab_to_xyz.spec.js +4 -4
  36. package/src/core/color/oklab/toe.d.ts +13 -0
  37. package/src/core/color/oklab/toe.d.ts.map +1 -0
  38. package/src/core/color/oklab/toe.js +22 -0
  39. package/src/core/color/oklab/xyz_to_oklab.d.ts +5 -2
  40. package/src/core/color/oklab/xyz_to_oklab.d.ts.map +1 -1
  41. package/src/core/color/oklab/xyz_to_oklab.js +5 -5
  42. package/src/core/color/oklab/xyz_to_oklab.spec.js +4 -4
  43. package/src/engine/animation/async/prototypeAsyncAnimation.d.ts +2 -0
  44. package/src/engine/animation/async/prototypeAsyncAnimation.d.ts.map +1 -0
  45. package/src/engine/animation/async/prototypeAsyncAnimation.js +344 -0
  46. package/src/engine/asset/AssetManager.d.ts.map +1 -1
  47. package/src/engine/asset/AssetManager.js +17 -0
  48. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  49. package/src/engine/asset/loaders/ArrayBufferLoader.js +22 -2
  50. package/src/engine/ecs/Entity.d.ts.map +1 -1
  51. package/src/engine/ecs/Entity.js +1 -0
  52. package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
  53. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +3 -3
  54. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  55. package/src/engine/input/ecs/systems/InputControllerSystem.js +4 -8
  56. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts +46 -0
  57. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts.map +1 -0
  58. package/src/engine/intelligence/behavior/util/RandomDelayBehavior.js +85 -0
@@ -1 +1 @@
1
- {"version":3,"file":"oklab_to_xyz.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/oklab_to_xyz.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QA0BlB"}
1
+ {"version":3,"file":"oklab_to_xyz.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/oklab_to_xyz.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,qCALW,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,QAuBhB"}
@@ -2,13 +2,13 @@
2
2
  *
3
3
  * Converts Oklab color space to CIE XYZ.
4
4
  * Oklab as defined by Björn Ottosson
5
- * @param {number[]} input Oklab
5
+ * @copyright "Company Named Limited" 2023
6
6
  * @param {number[]} output XYZ
7
+ * @param {number} L
8
+ * @param {number} a
9
+ * @param {number} b
7
10
  */
8
- export function oklab_to_xyz(input, output) {
9
- const L = input[0];
10
- const a = input[1];
11
- const b = input[2];
11
+ export function oklab_to_xyz(output, L, a, b) {
12
12
 
13
13
  // apply M2 inverse
14
14
 
@@ -4,25 +4,25 @@ test("known samples", () => {
4
4
 
5
5
  const out = [];
6
6
 
7
- oklab_to_xyz([1, 0, 0], out);
7
+ oklab_to_xyz(out, 1, 0, 0);
8
8
 
9
9
  expect(out[0]).toBeCloseTo(0.950);
10
10
  expect(out[1]).toBeCloseTo(1.000);
11
11
  expect(out[2]).toBeCloseTo(1.089);
12
12
 
13
- oklab_to_xyz([0.450, 1.236, -0.019], out);
13
+ oklab_to_xyz(out, 0.450, 1.236, -0.019);
14
14
 
15
15
  expect(out[0]).toBeCloseTo(1);
16
16
  expect(out[1]).toBeCloseTo(0);
17
17
  expect(out[2]).toBeCloseTo(0);
18
18
 
19
- oklab_to_xyz([0.922, -0.671, 0.263], out);
19
+ oklab_to_xyz(out, 0.922, -0.671, 0.263);
20
20
 
21
21
  expect(out[0]).toBeCloseTo(0);
22
22
  expect(out[1]).toBeCloseTo(1);
23
23
  expect(out[2]).toBeCloseTo(0);
24
24
 
25
- oklab_to_xyz([0.153, -1.415, -0.449], out);
25
+ oklab_to_xyz(out, 0.153, -1.415, -0.449);
26
26
 
27
27
  expect(out[0]).toBeCloseTo(0);
28
28
  expect(out[1]).toBeCloseTo(0);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * toe function for L_r
3
+ * @param {number} x
4
+ * @return {number}
5
+ */
6
+ export function toe(x: number): number;
7
+ /**
8
+ * inverse toe function for L_r
9
+ * @param {number} x
10
+ * @return {number}
11
+ */
12
+ export function toe_inv(x: number): number;
13
+ //# sourceMappingURL=toe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toe.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/toe.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,uBAHW,MAAM,GACL,MAAM,CAIjB;AAED;;;;GAIG;AACH,2BAHW,MAAM,GACL,MAAM,CAIjB"}
@@ -0,0 +1,22 @@
1
+
2
+ const k_1 = 0.206;
3
+ const k_2 = 0.03;
4
+ const k_3 = (1. + k_1) / (1. + k_2);
5
+
6
+ /**
7
+ * toe function for L_r
8
+ * @param {number} x
9
+ * @return {number}
10
+ */
11
+ export function toe(x){
12
+ return 0.5 * (k_3 * x - k_1 + Math.sqrt((k_3 * x - k_1) * (k_3 * x - k_1) + 4 * k_2 * k_3 * x));
13
+ }
14
+
15
+ /**
16
+ * inverse toe function for L_r
17
+ * @param {number} x
18
+ * @return {number}
19
+ */
20
+ export function toe_inv(x){
21
+ return (x * x + k_1 * x) / (k_3 * (x + k_2));
22
+ }
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Converts CIE XYZ color space to Oklab.
3
3
  * Oklab as defined by Björn Ottosson
4
- * @param {number[]} input XYZ
4
+ * @copyright "Company Named Limited" 2023
5
5
  * @param {number[]} output Lab
6
+ * @param {number} x
7
+ * @param {number} y
8
+ * @param {number} z
6
9
  */
7
- export function xyz_to_oklab(input: number[], output: number[]): void;
10
+ export function xyz_to_oklab(output: number[], x: number, y: number, z: number): void;
8
11
  //# sourceMappingURL=xyz_to_oklab.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xyz_to_oklab.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/xyz_to_oklab.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QAwBlB"}
1
+ {"version":3,"file":"xyz_to_oklab.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/xyz_to_oklab.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qCALW,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,QAqBhB"}
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Converts CIE XYZ color space to Oklab.
3
3
  * Oklab as defined by Björn Ottosson
4
- * @param {number[]} input XYZ
4
+ * @copyright "Company Named Limited" 2023
5
5
  * @param {number[]} output Lab
6
+ * @param {number} x
7
+ * @param {number} y
8
+ * @param {number} z
6
9
  */
7
- export function xyz_to_oklab(input, output) {
8
- const x = input[0];
9
- const y = input[1];
10
- const z = input[2];
10
+ export function xyz_to_oklab(output, x, y, z) {
11
11
 
12
12
  // M1 * (X Y Z)
13
13
  const l = 0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z;
@@ -4,25 +4,25 @@ test("known samples", () => {
4
4
 
5
5
  const out = [];
6
6
 
7
- xyz_to_oklab([0.950, 1.000, 1.089], out);
7
+ xyz_to_oklab(out, 0.950, 1.000, 1.089);
8
8
 
9
9
  expect(out[0]).toBeCloseTo(1);
10
10
  expect(out[1]).toBeCloseTo(0);
11
11
  expect(out[2]).toBeCloseTo(0);
12
12
 
13
- xyz_to_oklab([1, 0, 0], out);
13
+ xyz_to_oklab(out, 1, 0, 0);
14
14
 
15
15
  expect(out[0]).toBeCloseTo(0.450);
16
16
  expect(out[1]).toBeCloseTo(1.236);
17
17
  expect(out[2]).toBeCloseTo(-0.019);
18
18
 
19
- xyz_to_oklab([0, 1, 0], out);
19
+ xyz_to_oklab(out, 0, 1, 0);
20
20
 
21
21
  expect(out[0]).toBeCloseTo(0.922);
22
22
  expect(out[1]).toBeCloseTo(-0.671);
23
23
  expect(out[2]).toBeCloseTo(0.263);
24
24
 
25
- xyz_to_oklab([0, 0, 1], out);
25
+ xyz_to_oklab(out, 0, 0, 1);
26
26
 
27
27
  expect(out[0]).toBeCloseTo(0.153);
28
28
  expect(out[1]).toBeCloseTo(-1.415);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototypeAsyncAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototypeAsyncAnimation.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/async/prototypeAsyncAnimation.js"],"names":[],"mappings":""}
@@ -0,0 +1,344 @@
1
+ import { GUI } from "dat.gui";
2
+ import { MeshBasicMaterial, MeshStandardMaterial, OctahedronBufferGeometry } from "three";
3
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
4
+ import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
5
+ import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
6
+ import { Color } from "../../../core/color/Color.js";
7
+ import { inverseLerp } from "../../../core/math/inverseLerp.js";
8
+ import { lerp } from "../../../core/math/lerp.js";
9
+ import { max2 } from "../../../core/math/max2.js";
10
+ import { min2 } from "../../../core/math/min2.js";
11
+ import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
12
+ import { seededRandom } from "../../../core/math/random/seededRandom.js";
13
+ import Clock from "../../Clock.js";
14
+ import Entity from "../../ecs/Entity.js";
15
+ import { Transform } from "../../ecs/transform/Transform.js";
16
+ import { EngineHarness } from "../../EngineHarness.js";
17
+ import { ShadedGeometry } from "../../graphics/ecs/mesh-v2/ShadedGeometry.js";
18
+ import { ShadedGeometrySystem } from "../../graphics/ecs/mesh-v2/ShadedGeometrySystem.js";
19
+ import Trail2D from "../../graphics/ecs/trail2d/Trail2D.js";
20
+ import Trail2DSystem from "../../graphics/ecs/trail2d/Trail2DSystem.js";
21
+ import {
22
+ RGBA_LUT_HEATMAP_IR
23
+ } from "../../graphics/particles/particular/engine/parameter/sample/RGBA_LUT_HEATMAP_IR.js";
24
+ import { SequenceBehavior } from "../../intelligence/behavior/composite/SequenceBehavior.js";
25
+ import { RepeatBehavior } from "../../intelligence/behavior/decorator/RepeatBehavior.js";
26
+ import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
27
+ import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
28
+ import { ActionBehavior } from "../../intelligence/behavior/primitive/ActionBehavior.js";
29
+ import { RandomDelayBehavior } from "../../intelligence/behavior/util/RandomDelayBehavior.js";
30
+
31
+ const harness = new EngineHarness();
32
+
33
+ /**
34
+ *
35
+ * @param {RowFirstTable} table
36
+ * @param {number} time
37
+ * @return {number}
38
+ */
39
+ function findSampleIndex(table, time) {
40
+ let minIndex = 0;
41
+ let maxIndex = table.length - 1;
42
+
43
+ while (minIndex <= maxIndex) {
44
+
45
+ const pivotIndex = (minIndex + maxIndex) >> 1;
46
+
47
+ const cmp = time - table.readCellValue(pivotIndex, 0);
48
+
49
+ if (cmp > 0) {
50
+ minIndex = pivotIndex + 1;
51
+ } else if (cmp < 0) {
52
+ maxIndex = pivotIndex - 1;
53
+ } else {
54
+ //set low boundary for next step based on assumption that upper bound is higher than lower bound
55
+ return pivotIndex;
56
+ }
57
+ }
58
+
59
+ return min2(minIndex, maxIndex);
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @param {EntityComponentDataset} ecd
65
+ * @param {RowFirstTable} table
66
+ * @param {number} [count]
67
+ */
68
+ function makeGhostMarkers({
69
+ ecd,
70
+ table,
71
+ count = 5
72
+ }) {
73
+
74
+
75
+ const g = new OctahedronBufferGeometry(1, 3);
76
+
77
+ /**
78
+ *
79
+ * @type {Entity[]}
80
+ */
81
+ const entities = [];
82
+
83
+ for (let i = 0; i < count; i++) {
84
+
85
+ const color = new Color();
86
+
87
+ const sample = [];
88
+
89
+ RGBA_LUT_HEATMAP_IR.sample(i / (count - 1), sample);
90
+
91
+ color.setRGBUint8(...sample);
92
+
93
+ const transform = new Transform();
94
+
95
+ const entity = new Entity();
96
+
97
+ entities.push(entity);
98
+
99
+ entity
100
+ .add(transform)
101
+ .add(ShadedGeometry.from(g, new MeshBasicMaterial({
102
+ wireframe: true,
103
+ color: color.toUint()
104
+ })))
105
+ .build(ecd);
106
+ }
107
+
108
+ return {
109
+ set time(time) {
110
+
111
+ const ref_index = findSampleIndex(table, time);
112
+
113
+ const start_index = max2(0, ref_index - Math.floor(count / 2));
114
+ const limit_index = min2(table.length - 1, ref_index + Math.ceil(count / 2));
115
+
116
+ for (let i = 0; i < count; i++) {
117
+
118
+ const entity = entities[i];
119
+
120
+ const sample_index = ref_index - Math.floor(count / 2) + i;
121
+
122
+ const out_of_bound_marker = sample_index < start_index || sample_index > limit_index;
123
+
124
+ if (out_of_bound_marker) {
125
+ if (entity.isBuilt) {
126
+ entity.destroy();
127
+ }
128
+ } else {
129
+ if (!entity.isBuilt) {
130
+ entity.build(ecd);
131
+ }
132
+ }
133
+
134
+ if (out_of_bound_marker) {
135
+ continue;
136
+ }
137
+
138
+ const transform = entity.getComponentSafe(Transform);
139
+
140
+ transform.position.set(
141
+ table.readCellValue(sample_index, 1),
142
+ table.readCellValue(sample_index, 2),
143
+ table.readCellValue(sample_index, 3)
144
+ );
145
+
146
+ }
147
+ }
148
+ };
149
+ }
150
+
151
+ /**
152
+ *
153
+ * @param {Engine} engine
154
+ * @return {Promise<void>}
155
+ */
156
+ async function main(engine) {
157
+ await EngineHarness.buildBasics({
158
+ engine
159
+ });
160
+
161
+ const table = new RowFirstTable(
162
+ RowFirstTableSpec.get([
163
+ BinaryDataType.Float64, // time
164
+ BinaryDataType.Float32, // x
165
+ BinaryDataType.Float32, //y
166
+ BinaryDataType.Float32 //z
167
+ ])
168
+ );
169
+
170
+ const random = seededRandom(42);
171
+
172
+ table.addRow([
173
+ 0, 0, 1, 0
174
+ ]);
175
+
176
+ const sample = [];
177
+
178
+ const sim_clock = new Clock();
179
+ sim_clock.start();
180
+
181
+ function addSample() {
182
+
183
+ const time_delta = sim_clock.getDelta();
184
+
185
+ // get last row
186
+ const row_count = table.length;
187
+
188
+ table.getRow(row_count - 1, sample);
189
+
190
+ const speed = 7;
191
+
192
+ const displacement = speed * time_delta;
193
+
194
+ const direction = randomFloatBetween(random, -Math.PI, Math.PI);
195
+
196
+ const displacement_x = displacement * Math.cos(direction);
197
+ const displacement_y = displacement * Math.sin(direction);
198
+
199
+ const new_x = sample[1] + displacement_x;
200
+ const new_z = sample[3] + displacement_y;
201
+
202
+ table.addRow([
203
+ sample[0] + time_delta,
204
+ new_x,
205
+ 1,
206
+ new_z,
207
+
208
+ ]);
209
+ }
210
+
211
+
212
+ const ecd = engine.entityManager.dataset;
213
+
214
+ // simulate data arriving from the network
215
+ const sample_delay = RandomDelayBehavior.from(0.5, 1);
216
+ new Entity()
217
+ .add(BehaviorComponent.fromOne(RepeatBehavior.from(
218
+ SequenceBehavior.from([
219
+ sample_delay,
220
+ new ActionBehavior(addSample)
221
+ ])
222
+ )))
223
+ .build(ecd);
224
+
225
+ const sim_parameters = {
226
+ playing: true,
227
+ play_time: -1,
228
+ get latest_data_time() {
229
+ return table.readCellValue(table.length - 1, 0);
230
+ },
231
+ get behind_latest() {
232
+ return table.readCellValue(table.length - 1, 0) - this.play_time;
233
+ },
234
+ set behind_latest(v) {
235
+
236
+ const current_delay = table.readCellValue(table.length - 1, 0) - this.play_time;
237
+
238
+ const delta = v - current_delay;
239
+
240
+ this.play_time += delta;
241
+ }
242
+ };
243
+
244
+
245
+ // simulate agent moving through space
246
+ const subject = new Entity();
247
+
248
+ subject
249
+ .add(Transform.fromJSON({
250
+ position: 0
251
+ }))
252
+ .add(Trail2D.fromJSON({
253
+ textureURL: "data/textures/trail/Circle_04.png",
254
+ width: 0.2
255
+ }))
256
+ .add(ShadedGeometry.from(new OctahedronBufferGeometry(1, 5), new MeshStandardMaterial()))
257
+ .add(BehaviorComponent.fromOne(RepeatBehavior.from(
258
+ new ActionBehavior((delta) => {
259
+ if (sim_parameters.playing) {
260
+ sim_parameters.play_time += delta;
261
+ }
262
+
263
+
264
+ // seek to the right sample
265
+ const sample_index = max2(0, findSampleIndex(table, sim_parameters.play_time));
266
+ const next_sample_index = min2(table.length - 1, sample_index + 1);
267
+
268
+ const prev = table.readCellValue(sample_index, 0);
269
+ const next = table.readCellValue(next_sample_index, 0);
270
+
271
+ const normalized_offset = inverseLerp(prev, next, sim_parameters.play_time);
272
+
273
+ const transform = subject.getComponentSafe(Transform);
274
+
275
+ const x0 = table.readCellValue(sample_index, 1);
276
+ const x1 = table.readCellValue(next_sample_index, 1);
277
+
278
+ const y0 = table.readCellValue(sample_index, 2);
279
+ const y1 = table.readCellValue(next_sample_index, 2);
280
+
281
+ const z0 = table.readCellValue(sample_index, 3);
282
+ const z1 = table.readCellValue(next_sample_index, 3);
283
+
284
+ transform.position.set(
285
+ lerp(x0, x1, normalized_offset),
286
+ lerp(y0, y1, normalized_offset),
287
+ lerp(z0, z1, normalized_offset),
288
+ );
289
+ })
290
+ )))
291
+ .build(ecd);
292
+
293
+ const markers = makeGhostMarkers({
294
+ ecd, table, count: 5
295
+ });
296
+
297
+ engine.ticker.onTick.add(() => markers.time = sim_parameters.play_time);
298
+
299
+ const gui = new GUI();
300
+
301
+ const gui_samples = gui.addFolder("samples");
302
+ gui_samples.add(sample_delay.limits, 'min').name("min_delay").step(0.01)
303
+ gui_samples.add(sample_delay.limits, 'max').name("max_delay").step(0.01)
304
+
305
+ for (const k in sim_parameters) {
306
+
307
+ const control = gui.add(sim_parameters, k);
308
+
309
+ if (typeof sim_parameters[k] === "number") {
310
+ control.step(0.01);
311
+ }
312
+
313
+ let last_value = sim_parameters[k];
314
+
315
+ engine.ticker.onTick.add(() => {
316
+ let should_update = true;
317
+
318
+ const current_value = sim_parameters[k];
319
+ if (last_value === current_value) {
320
+ should_update = false;
321
+ } else {
322
+ last_value = current_value;
323
+ }
324
+
325
+
326
+ if (should_update) {
327
+ control.updateDisplay();
328
+ }
329
+ })
330
+ }
331
+
332
+ gui.open();
333
+
334
+ }
335
+
336
+ harness.initialize({
337
+ configuration(config, engine) {
338
+ config.addManySystems(
339
+ new BehaviorSystem(engine),
340
+ new ShadedGeometrySystem(engine),
341
+ new Trail2DSystem(engine)
342
+ )
343
+ }
344
+ }).then(main);
@@ -1 +1 @@
1
- {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IAsQD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BAv1B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
1
+ {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IAsQD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,kCAEJ,QAAQ,OAAO,CAAC,CAU5B;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BAx2B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
@@ -720,6 +720,23 @@ export class AssetManager {
720
720
  return true;
721
721
  }
722
722
 
723
+ /**
724
+ * Will register loader only if none exists for this type
725
+ * @template T
726
+ * @param {string} type
727
+ * @param {AssetLoader<T>} loader
728
+ * @returns {Promise<boolean>} true if registered , false otherwise
729
+ */
730
+ async tryRegisterLoader(type, loader) {
731
+ if (this.hasLoaderForType(type)) {
732
+ return false;
733
+ }
734
+
735
+ await this.registerLoader(type, loader);
736
+
737
+ return true;
738
+ }
739
+
723
740
  /**
724
741
  * @template T
725
742
  * @param {string} type
@@ -1 +1 @@
1
- {"version":3,"file":"ArrayBufferLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/ArrayBufferLoader.js"],"names":[],"mappings":"AAMA;IACI;;;OAGG;IACH,iCAFW,MAAM,GAAC,KAAK,GAAC,MAAM,EAa7B;IANG;;;;OAIG;IACH,yBAAsC;IAG1C;;;qCA0GC;CACJ;4BA/H2B,kBAAkB;qBAJzB,gCAAgC"}
1
+ {"version":3,"file":"ArrayBufferLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/ArrayBufferLoader.js"],"names":[],"mappings":"AAMA;IACI;;;OAGG;IACH,iCAFW,MAAM,GAAC,KAAK,GAAC,MAAM,EAa7B;IANG;;;;OAIG;IACH,yBAAsC;IAG1C;;;qCA8HC;CACJ;4BAnJ2B,kBAAkB;qBAJzB,gCAAgC"}
@@ -87,13 +87,17 @@ export class ArrayBufferLoader extends AssetLoader {
87
87
 
88
88
  }
89
89
 
90
+ /**
91
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
92
+ */
90
93
  const reader = response.body.getReader();
94
+
91
95
  const contentLength = response.headers.get('Content-Length');
92
96
  const total = contentLength ? parseInt(contentLength) : 0;
93
97
  let loaded = 0;
94
98
 
95
99
  // periodically read data into the new stream tracking while download progress
96
- const stream = new ReadableStream({
100
+ const stream_prototype = {
97
101
  type: "bytes",
98
102
  start(controller) {
99
103
 
@@ -122,7 +126,23 @@ export class ArrayBufferLoader extends AssetLoader {
122
126
 
123
127
  }
124
128
 
125
- });
129
+ };
130
+
131
+ /**
132
+ * @type {ReadableStream}
133
+ */
134
+ let stream;
135
+
136
+ try {
137
+ stream = new ReadableStream(stream_prototype);
138
+ } catch (e) {
139
+ /*
140
+ Workaround for Safari bug: "TypeError: ReadableByteStreamController is not implemented"
141
+ By not wrapping the response we lose the ability to track progress, but that's not a critical issue in most cases
142
+ */
143
+ console.warn(e);
144
+ return response;
145
+ }
126
146
 
127
147
  return new Response(stream);
128
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IAmYI;;;;;OAKG;IACH,+BAJW,MAAM,oCAEJ,MAAM,CAelB;IApZD;;;OAGG;IACH,IAFU,MAAM,CAER;IAER;;;;OAIG;IACH,YAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,2BAAgB;IAQhB;;;OAGG;IACH,gCAAe;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;OAGG;IACH,gBAAgB;IAEhB;;OAEG;IACH;;MAEE;IAUF;;;OAGG;IACH,eAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,WAAW,GAChB,OAAO,CAMnB;IAED;;;OAGG;IACH,gBAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;OAGG;IACH,uBAEC;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,8BAFa,MAAM,CAiBlB;IAED;;;;OAIG;IACH,+BAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,0CAYC;IAED;;;;OAIG;IACH,qCAQC;IAED;;;;OAIG;IACH,kCAFa,MAAE,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,qBAShB;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAiBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,sCAGJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,sCAGJ,MAAM,CAyBlB;IAED;;;OAGG;IACH,WAFa,OAAO,CAwBnB;IAED;;;;OAIG;IACH,+CAqDC;IAwBL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;4BAva2B,kBAAkB;mBAF3B,oCAAoC"}
1
+ {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IAoYI;;;;;OAKG;IACH,+BAJW,MAAM,oCAEJ,MAAM,CAelB;IArZD;;;OAGG;IACH,IAFU,MAAM,CAER;IAER;;;;OAIG;IACH,YAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,2BAAgB;IAQhB;;;OAGG;IACH,gCAAe;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;OAGG;IACH,gBAAgB;IAEhB;;OAEG;IACH;;MAEE;IAUF;;;OAGG;IACH,eAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,WAAW,GAChB,OAAO,CAMnB;IAED;;;OAGG;IACH,gBAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;OAGG;IACH,uBAEC;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,8BAFa,MAAM,CAiBlB;IAED;;;;OAIG;IACH,+BAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,0CAYC;IAED;;;;;OAKG;IACH,8CAQC;IAED;;;;OAIG;IACH,kCAFa,MAAE,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,qBAShB;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAiBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,sCAGJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,sCAGJ,MAAM,CAyBlB;IAED;;;OAGG;IACH,WAFa,OAAO,CAwBnB;IAED;;;;OAIG;IACH,+CAqDC;IAwBL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;4BAxa2B,kBAAkB;mBAF3B,oCAAoC"}
@@ -186,6 +186,7 @@ class Entity {
186
186
 
187
187
  /**
188
188
  * Similar to {@link #getComponent}, instead of returning null - throws an exception
189
+ * @template T
189
190
  * @param {Class<T>} klass
190
191
  * @returns {T}
191
192
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TerrainSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/TerrainSystem.js"],"names":[],"mappings":";AA8BA;IA4MI;;;;;OAKG;IACH,kEAHW,OAAO,uBAwCjB;IA9ND;;;;;OAKG;IACH,kEAeC;IA7CD,iCAAyB;IAEzB,mBAAe;IACf,mBAAe;IAEf;;;;OAIG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,aAFU,cAAY,IAAI,CAEP;IAEnB;;;OAGG;IACH,KAFU,GAAG,CAEG;IAoBZ,yBAAwB;IAExB,2BAAgC;IAGpC,kDAMC;IAED,mFA0DC;IAED,2EAIC;IAED;;;;OAIG;IACH,gBAHW,OAAO,qBAqBjB;IAED;;;;OAIG;IACH,kBAHW,OAAO,qBAKjB;IAED,6BAaC;IAED;;;;;OAKG;IACH,gCAwBC;CA+CJ;uBA3QsB,iBAAiB;oBAEpB,cAAc;oBAZd,mCAAmC"}
1
+ {"version":3,"file":"TerrainSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/TerrainSystem.js"],"names":[],"mappings":";AA+BA;IA2MI;;;;;OAKG;IACH,kEAHW,OAAO,uBAwCjB;IA7ND;;;;;OAKG;IACH,kEAeC;IA7CD,iCAAyB;IAEzB,mBAAe;IACf,mBAAe;IAEf;;;;OAIG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,aAFU,cAAY,IAAI,CAEP;IAEnB;;;OAGG;IACH,KAFU,GAAG,CAEG;IAoBZ,yBAAwB;IAExB,2BAAgC;IAGpC,kDAMC;IAED,mFAyDC;IAED,2EAIC;IAED;;;;OAIG;IACH,gBAHW,OAAO,qBAqBjB;IAED;;;;OAIG;IACH,kBAHW,OAAO,qBAKjB;IAED,6BAaC;IAED;;;;;OAKG;IACH,gCAwBC;CA+CJ;uBA1QsB,iBAAiB;oBAEpB,cAAc;oBAbd,mCAAmC"}
@@ -8,6 +8,7 @@ import { noop } from "../../../../core/function/noop.js";
8
8
  import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
9
9
  import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
10
10
  import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
11
+ import { TextureAssetLoader } from "../../../asset/loaders/texture/TextureAssetLoader.js";
11
12
  import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
12
13
  import { System } from '../../System.js';
13
14
  import { Transform } from "../../transform/Transform.js";
@@ -137,9 +138,8 @@ class TerrainSystem extends System {
137
138
 
138
139
  const am = this.assetManager;
139
140
 
140
- if (!am.hasLoaderForType('image')) {
141
- await am.registerLoader('image', new ImageRGBADataLoader());
142
- }
141
+ await am.tryRegisterLoader('image', new ImageRGBADataLoader());
142
+ await am.tryRegisterLoader('texture', new TextureAssetLoader());
143
143
 
144
144
  readyCallback();
145
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InputControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/ecs/systems/InputControllerSystem.js"],"names":[],"mappings":";AA0LA;;GAEG;AACH;IACI,0BA+BC;IA7BG,gCAAsC;IAEtC,yCAAqC;IAErC,aAAsB;IA2B1B,0EAIC;IAFG,YAAiB;IAIrB;;;;OAIG;IACH,gBAHW,eAAe,qBAOzB;IAED;;;;OAIG;IACH,kBAHW,eAAe,qBASzB;CACJ;uBAtPsB,wBAAwB;0BAErB,yCAAyC;4BADvC,kCAAkC"}
1
+ {"version":3,"file":"InputControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/ecs/systems/InputControllerSystem.js"],"names":[],"mappings":";AAsLA;;GAEG;AACH;IACI,0BA+BC;IA7BG,gCAAsC;IAEtC,yCAAqC;IAErC,aAAsB;IA2B1B,0EAIC;IAFG,YAAiB;IAIrB;;;;OAIG;IACH,gBAHW,eAAe,qBAOzB;IAED;;;;OAIG;IACH,kBAHW,eAAe,qBASzB;CACJ;uBAhPsB,wBAAwB;0BADrB,yCAAyC;4BAEvC,kCAAkC"}