@woosh/meep-engine 2.127.1 → 2.128.1

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 (84) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/packing/miniball/Miniball.d.ts +12 -10
  3. package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
  4. package/src/core/geom/packing/miniball/Miniball.js +76 -54
  5. package/src/engine/Clock.d.ts +2 -1
  6. package/src/engine/Clock.d.ts.map +1 -1
  7. package/src/engine/Clock.js +1 -0
  8. package/src/engine/ecs/Entity.d.ts.map +1 -1
  9. package/src/engine/ecs/Entity.js +14 -5
  10. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  11. package/src/engine/ecs/EntityComponentDataset.js +48 -2
  12. package/src/engine/ecs/EntityManager.d.ts +5 -6
  13. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  14. package/src/engine/ecs/EntityManager.js +85 -39
  15. package/src/engine/ecs/EntityReference.d.ts.map +1 -1
  16. package/src/engine/ecs/EntityReference.js +2 -0
  17. package/src/engine/ecs/System.d.ts +2 -2
  18. package/src/engine/ecs/System.d.ts.map +1 -1
  19. package/src/engine/ecs/System.js +44 -47
  20. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.d.ts +1 -1
  21. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.d.ts.map +1 -1
  22. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -4
  23. package/src/engine/ecs/fow/FogOfWarSystem.d.ts +2 -4
  24. package/src/engine/ecs/fow/FogOfWarSystem.d.ts.map +1 -1
  25. package/src/engine/ecs/fow/FogOfWarSystem.js +15 -21
  26. package/src/engine/ecs/gui/GUIElementSystem.d.ts.map +1 -1
  27. package/src/engine/ecs/gui/GUIElementSystem.js +7 -18
  28. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.d.ts.map +1 -1
  29. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +3 -10
  30. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts +2 -2
  31. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts.map +1 -1
  32. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +2 -6
  33. package/src/engine/ecs/renderable/RenderSystem.d.ts.map +1 -1
  34. package/src/engine/ecs/renderable/RenderSystem.js +3 -7
  35. package/src/engine/ecs/speaker/VoiceSystem.d.ts +1 -1
  36. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  37. package/src/engine/ecs/speaker/VoiceSystem.js +2 -4
  38. package/src/engine/ecs/{validateSystem.d.ts → system_validate_class.d.ts} +2 -2
  39. package/src/engine/ecs/system_validate_class.d.ts.map +1 -0
  40. package/src/engine/ecs/{validateSystem.js → system_validate_class.js} +12 -3
  41. package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
  42. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -5
  43. package/src/engine/ecs/tooltip/TooltipComponentSystem.d.ts +2 -2
  44. package/src/engine/ecs/tooltip/TooltipComponentSystem.d.ts.map +1 -1
  45. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +10 -12
  46. package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +1 -1
  47. package/src/engine/graphics/ecs/camera/CameraSystem.js +5 -8
  48. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts.map +1 -1
  49. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -6
  50. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts.map +1 -1
  51. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.js +14 -27
  52. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  53. package/src/engine/graphics/ecs/light/LightSystem.js +2 -6
  54. package/src/engine/graphics/ecs/mesh/MeshSystem.d.ts.map +1 -1
  55. package/src/engine/graphics/ecs/mesh/MeshSystem.js +2 -6
  56. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
  57. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -5
  58. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts.map +1 -1
  59. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +1 -2
  60. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/path/PathDisplaySystem.js +13 -17
  62. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts.map +1 -1
  63. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +2 -6
  64. package/src/engine/graphics/ecs/water/WaterSystem.d.ts +2 -2
  65. package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
  66. package/src/engine/graphics/ecs/water/WaterSystem.js +5 -11
  67. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts.map +1 -1
  68. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +2 -6
  69. package/src/engine/graphics/render/frame_graph/RenderGraph.d.ts +2 -1
  70. package/src/engine/graphics/render/frame_graph/RenderGraph.d.ts.map +1 -1
  71. package/src/engine/graphics/render/frame_graph/RenderGraph.js +2 -1
  72. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts +1 -0
  73. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts.map +1 -1
  74. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.js +3 -0
  75. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  76. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -2
  77. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts +2 -2
  78. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts.map +1 -1
  79. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.js +3 -5
  80. package/src/engine/scene/SceneManager.js +3 -3
  81. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +2 -2
  82. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
  83. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +2 -6
  84. package/src/engine/ecs/validateSystem.d.ts.map +0 -1
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.127.1",
8
+ "version": "2.128.1",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Computes the miniball of the given point set.
3
3
  *
4
+ * Based on paper "Fast Smallest-Enclosing-Ball Computation in High Dimensions" by "Kaspar Fischer" et. al.
4
5
  * @copyright Company Named Limited (c) 2025
5
6
  */
6
7
  export class Miniball {
@@ -152,16 +153,17 @@ export class Miniball {
152
153
  *
153
154
  * Iteratively, we compute the point in support that is closest to the current center and then
154
155
  * walk towards this target as far as we can, i.e., we move until some new point touches the
155
- * boundary of the ball and must thus be inserted into support. In each of these two alternating
156
- * phases, we always have to check whether some point must be dropped from support, which is the
157
- * case when the center lies in <i>aff(support)</i>. If such an attempt to drop fails, we are
158
- * done; because then the center lies even <i>conv(support)</i>.
156
+ * boundary of the ball and must thus be inserted into support.
157
+ *
158
+ * In each of these two alternating phases, we always have to check whether some point must be dropped from support,
159
+ * which is the case when the center lies in <i>aff(support)</i>.
160
+ * If such an attempt to drop fails, we are done; because then the center lies even <i>conv(support)</i>.
159
161
  * @private
160
162
  */
161
163
  private compute;
162
164
  /**
163
165
  * If center doesn't already lie in <i>conv(support)</i> and is thus not optimal yet,
164
- * {@link #successfulDrop()} elects a suitable point <i>k</i> to be removed from the support and
166
+ * {@link successfulDrop()} elects a suitable point <i>k</i> to be removed from the support and
165
167
  * returns true. If the center lies in the convex hull, however, false is returned (and the
166
168
  * support remains unaltered).
167
169
  *
@@ -171,16 +173,16 @@ export class Miniball {
171
173
  successfulDrop(): boolean;
172
174
  /**
173
175
  * Given the center of the current enclosing ball and the walking direction `centerToAff`,
174
- * determine how much we can walk into this direction without losing a point from <i>S</i>. The
175
- * (positive) factor by which we can walk along `centerToAff` is returned. Further,
176
- * `stopper` is set to the index of the most restricting point and to -1 if no such point
177
- * was found.
176
+ * determine how much we can walk into this direction without losing a point from <i>S</i>.
177
+ *
178
+ * The (positive) factor by which we can walk along `centerToAff` is returned.
179
+ * Further, `stopper` is set to the index of the most restricting point and to -1 if no such point was found.
178
180
  * @return {number}
179
181
  * @private
180
182
  */
181
183
  private findStopFraction;
182
184
  /**
183
- * Outputs information about the miniball
185
+ * Outputs information about the Miniball
184
186
  * @return {string}
185
187
  */
186
188
  toString(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"Miniball.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/Miniball.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH;IACI;;;;;OAKG;IACH,8BAkGC;IA/FG;;;OAGG;IACH,WAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,WAFU,MAAM,CAEE;IAClB;;;OAGG;IACH,iBAFU,MAAM,CAEQ;IACxB;;;;;;;;;;OAUG;IACH,wBAAwB;IACxB;;;;OAIG;IACH,iBAAiB;IACjB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;OAEG;IACH,YAAe;IAEf;;;;OAIG;IACH,eAA2B;IAI3B;;;OAGG;IACH,KAFU,MAAM,CAEU;IAM1B;;;;OAIG;IACH,iBAA4D;IAE5D;;;OAGG;IACH,aAFU,MAAM,EAAE,GAAC,YAAY,CAEkD;IAEjF;;;OAGG;IACH,eAFU,MAAM,EAAE,GAAC,YAAY,CAEwD;IAEvF;;;OAGG;IACH,SAFU,MAAM,EAAE,GAAC,YAAY,CAEsD;IAErF;;;;OAIG;IACH,kBAAgC;IAIpC;;;;;;;OAOG;IACH,WAFY,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,EAAE,CAInB;IAED;;;OAGG;IACH,uBAEC;IAED;;;;;;OAMG;IACH,QAJY,MAAM,CAMjB;IAED;;;;;;;;OAQG;IACH,iBAkCC;IAED;;OAEG;IACH,yBAGC;IAED;;OAEG;IACH,qBAcC;IAED;;;;;;;;;;OAUG;IACH,gBA4CC;IAED;;;;;;;;OAQG;IACH,kBAFY,OAAO,CA4BlB;IAED;;;;;;;;OAQG;IACH,yBAyDC;IAGD;;;OAGG;IACH,YAFY,MAAM,CAkBjB;CACJ;wBAnbuB,cAAc"}
1
+ {"version":3,"file":"Miniball.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/Miniball.js"],"names":[],"mappings":"AAwBA;;;;;GAKG;AACH;IA8CI;;;;;OAKG;IACH,8BA4DC;IA9GD;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,iBAFU,MAAM,CAEI;IAEpB;;;;;;;;;;OAUG;IACH,wBAAoB;IAEpB;;;;OAIG;IACH,iBAAa;IAEb;;;OAGG;IACH,SAFU,MAAM,CAEJ;IAYR;;OAEG;IACH,YAAe;IAEf;;;;OAIG;IACH,eAA2B;IAI3B;;;OAGG;IACH,KAFU,MAAM,CAEU;IAM1B;;;;OAIG;IACH,iBAA4D;IAE5D;;;OAGG;IACH,aAFU,MAAM,EAAE,GAAC,YAAY,CAEkD;IAEjF;;;OAGG;IACH,eAFU,MAAM,EAAE,GAAC,YAAY,CAEwD;IAEvF;;;OAGG;IACH,SAFU,MAAM,EAAE,GAAC,YAAY,CAEsD;IAErF;;;;OAIG;IACH,kBAAgC;IAIpC;;;;;;;OAOG;IACH,WAFY,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,UAFY,MAAM,EAAE,CAInB;IAED;;;OAGG;IACH,uBAEC;IAED;;;;;;OAMG;IACH,QAJY,MAAM,CAMjB;IAED;;;;;;;;OAQG;IACH,iBAkCC;IAED;;OAEG;IACH,yBAGC;IAED;;OAEG;IACH,qBAcC;IAED;;;;;;;;;;;OAWG;IACH,gBA4CC;IAED;;;;;;;;OAQG;IACH,kBAFY,OAAO,CA4BlB;IAED;;;;;;;;OAQG;IACH,yBA8DC;IAGD;;;OAGG;IACH,YAFY,MAAM,CA0BjB;CACJ;wBAzcuB,cAAc"}
@@ -14,10 +14,10 @@ import { Subspan } from "./Subspan.js";
14
14
  * Small number
15
15
  * @type {number}
16
16
  */
17
- const Epsilon = 1.0E-14;
17
+ const Epsilon = 1e-14;
18
18
 
19
19
  /**
20
- * Limit to how many iterations algorithm is allowed to perform, this is to cover poorly converging cases
20
+ * Limit to how many iterations the algorithm is allowed to perform, this is to cover poorly converging cases
21
21
  * @type {number}
22
22
  */
23
23
  const MAX_ITERATIONS = 10000;
@@ -25,9 +25,55 @@ const MAX_ITERATIONS = 10000;
25
25
  /**
26
26
  * Computes the miniball of the given point set.
27
27
  *
28
+ * Based on paper "Fast Smallest-Enclosing-Ball Computation in High Dimensions" by "Kaspar Fischer" et. al.
28
29
  * @copyright Company Named Limited (c) 2025
29
30
  */
30
31
  export class Miniball {
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ */
37
+ iteration = 0;
38
+
39
+ /**
40
+ *
41
+ * @type {number}
42
+ */
43
+ distToAff = 0;
44
+
45
+ /**
46
+ *
47
+ * @type {number}
48
+ */
49
+ distToAffSquare = 0;
50
+
51
+ /**
52
+ *
53
+ * The squared radius of the miniball.
54
+ *
55
+ * This is equivalent to `radius() * radius()`.
56
+ *
57
+ * Precondition: `!isEmpty()`
58
+ *
59
+ * @type {number}
60
+ * @private
61
+ */
62
+ __squaredRadius = 0;
63
+
64
+ /**
65
+ *
66
+ * @type {number}
67
+ * @private
68
+ */
69
+ __radius = 0;
70
+
71
+ /**
72
+ *
73
+ * @type {number}
74
+ */
75
+ stopper = 0;
76
+
31
77
  /**
32
78
  * Notice that the point set `points` is assumed to be immutable during the computation.
33
79
  * That is, if you add, remove, or change points in the point set, you have to create a new instance of {@link Miniball}.
@@ -37,44 +83,6 @@ export class Miniball {
37
83
  constructor(points) {
38
84
  assert.defined(points, 'points');
39
85
 
40
- /**
41
- *
42
- * @type {number}
43
- */
44
- this.iteration = 0;
45
- /**
46
- *
47
- * @type {number}
48
- */
49
- this.distToAff = 0;
50
- /**
51
- *
52
- * @type {number}
53
- */
54
- this.distToAffSquare = 0;
55
- /**
56
- *
57
- * The squared radius of the miniball.
58
- *
59
- * This is equivalent to `radius() * radius()`.
60
- *
61
- * Precondition: `!isEmpty()`
62
- *
63
- * @type {number}
64
- * @private
65
- */
66
- this.__squaredRadius = 0;
67
- /**
68
- *
69
- * @type {number}
70
- * @private
71
- */
72
- this.__radius = 0;
73
- /**
74
- *
75
- * @type {number}
76
- */
77
- this.stopper = 0;
78
86
 
79
87
  /**
80
88
  * @type {PointSet}
@@ -264,10 +272,11 @@ export class Miniball {
264
272
  *
265
273
  * Iteratively, we compute the point in support that is closest to the current center and then
266
274
  * walk towards this target as far as we can, i.e., we move until some new point touches the
267
- * boundary of the ball and must thus be inserted into support. In each of these two alternating
268
- * phases, we always have to check whether some point must be dropped from support, which is the
269
- * case when the center lies in <i>aff(support)</i>. If such an attempt to drop fails, we are
270
- * done; because then the center lies even <i>conv(support)</i>.
275
+ * boundary of the ball and must thus be inserted into support.
276
+ *
277
+ * In each of these two alternating phases, we always have to check whether some point must be dropped from support,
278
+ * which is the case when the center lies in <i>aff(support)</i>.
279
+ * If such an attempt to drop fails, we are done; because then the center lies even <i>conv(support)</i>.
271
280
  * @private
272
281
  */
273
282
  compute() {
@@ -318,7 +327,7 @@ export class Miniball {
318
327
 
319
328
  /**
320
329
  * If center doesn't already lie in <i>conv(support)</i> and is thus not optimal yet,
321
- * {@link #successfulDrop()} elects a suitable point <i>k</i> to be removed from the support and
330
+ * {@link successfulDrop()} elects a suitable point <i>k</i> to be removed from the support and
322
331
  * returns true. If the center lies in the convex hull, however, false is returned (and the
323
332
  * support remains unaltered).
324
333
  *
@@ -355,10 +364,10 @@ export class Miniball {
355
364
 
356
365
  /**
357
366
  * Given the center of the current enclosing ball and the walking direction `centerToAff`,
358
- * determine how much we can walk into this direction without losing a point from <i>S</i>. The
359
- * (positive) factor by which we can walk along `centerToAff` is returned. Further,
360
- * `stopper` is set to the index of the most restricting point and to -1 if no such point
361
- * was found.
367
+ * determine how much we can walk into this direction without losing a point from <i>S</i>.
368
+ *
369
+ * The (positive) factor by which we can walk along `centerToAff` is returned.
370
+ * Further, `stopper` is set to the index of the most restricting point and to -1 if no such point was found.
362
371
  * @return {number}
363
372
  * @private
364
373
  */
@@ -379,7 +388,11 @@ export class Miniball {
379
388
  const centerToPoint = this.centerToPoint;
380
389
  const centerToAff = this.centerToAff;
381
390
 
391
+ const distToAffSquare = this.distToAffSquare;
392
+ const squaredRadius = this.__squaredRadius;
393
+
382
394
  const size = this.__size;
395
+ const distance_error = Epsilon * this.__radius * this.distToAff;
383
396
 
384
397
  for (j = 0; j < size; ++j) {
385
398
 
@@ -388,6 +401,7 @@ export class Miniball {
388
401
  }
389
402
 
390
403
  for (i = 0; i < dim; ++i) {
404
+ // read out a single point, offset by center
391
405
  centerToPoint[i] = pointSet.coord(j, i) - center[i];
392
406
  }
393
407
 
@@ -397,7 +411,7 @@ export class Miniball {
397
411
  dirPointProd += centerToAff[i] * centerToPoint[i];
398
412
  }
399
413
 
400
- if ((this.distToAffSquare - dirPointProd) < (Epsilon * this.__radius * this.distToAff)) {
414
+ if ((distToAffSquare - dirPointProd) < distance_error) {
401
415
  continue;
402
416
  }
403
417
 
@@ -407,7 +421,7 @@ export class Miniball {
407
421
  bound += centerToPoint[i] * centerToPoint[i];
408
422
  }
409
423
 
410
- bound = (this.__squaredRadius - bound) / 2 / (this.distToAffSquare - dirPointProd);
424
+ bound = (squaredRadius - bound) / 2 / (distToAffSquare - dirPointProd);
411
425
 
412
426
  if (bound > 0 && bound < scale) {
413
427
  //if (com.dreizak.miniball.highdim.Logging.log)
@@ -423,15 +437,20 @@ export class Miniball {
423
437
 
424
438
 
425
439
  /**
426
- * Outputs information about the miniball
440
+ * Outputs information about the Miniball
427
441
  * @return {string}
428
442
  */
429
443
  toString() {
430
444
  let s = "Miniball [";
445
+
431
446
  if (this.isEmpty()) {
432
- s += ("isEmpty=true");
447
+
448
+ s += "isEmpty=true";
449
+
433
450
  } else {
434
- s += ("center=(");
451
+
452
+ s += "center=(";
453
+
435
454
  for (let i = 0; i < this.dim; ++i) {
436
455
  s += (this.__center[i]);
437
456
  if (i < this.dim - 1)
@@ -439,8 +458,11 @@ export class Miniball {
439
458
  }
440
459
 
441
460
  s += `), radius=${this.__radius}, squaredRadius=${this.__squaredRadius}`;
461
+
442
462
  }
463
+
443
464
  s += "]";
465
+
444
466
  return s;
445
467
  }
446
468
  }
@@ -31,8 +31,9 @@ declare class Clock {
31
31
  * Allows us to slow down or speed up flow of time via modifiers, see {@link Stat} for details
32
32
  * Default speed is x1, i.e. - unmodified
33
33
  * @type {Stat}
34
+ * @readonly
34
35
  */
35
- speed: Stat;
36
+ readonly speed: Stat;
36
37
  /**
37
38
  *
38
39
  * @param {number} v
@@ -1 +1 @@
1
- {"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../../../src/engine/Clock.js"],"names":[],"mappings":";AAcA;;GAEG;AACH;IAEI;;;;OAIG;IACH,0BAAsB;IAEtB;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,oBAAoB;IAGpB;;;;;OAKG;IACH,OAFU,IAAI,CAEM;IAMpB;;;OAGG;IACH,4BAEC;IAED;;;OAGG;IACH,yBAEC;IAED,cAIC;IAED,aAEC;IAED,cAIC;IAED;;;OAGG;IACH,YAFa,MAAM,CAOlB;IAED;;;OAGG;IACH,qBAFa,MAAM,CAOlB;IAED;;;;OAIG;IACH,kBAFY,MAAM,CAIjB;IAED,cAGC;CACJ;iBA9HgB,4BAA4B"}
1
+ {"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../../../src/engine/Clock.js"],"names":[],"mappings":";AAcA;;GAEG;AACH;IAEI;;;;OAIG;IACH,0BAAsB;IAEtB;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,oBAAoB;IAGpB;;;;;;OAMG;IACH,gBAHU,IAAI,CAGM;IAMpB;;;OAGG;IACH,4BAEC;IAED;;;OAGG;IACH,yBAEC;IAED,cAIC;IAED,aAEC;IAED,cAIC;IAED;;;OAGG;IACH,YAFa,MAAM,CAOlB;IAED;;;OAGG;IACH,qBAFa,MAAM,CAOlB;IAED;;;;OAIG;IACH,kBAFY,MAAM,CAIjB;IAED,cAGC;CACJ;iBA/HgB,4BAA4B"}
@@ -50,6 +50,7 @@ class Clock {
50
50
  * Allows us to slow down or speed up flow of time via modifiers, see {@link Stat} for details
51
51
  * Default speed is x1, i.e. - unmodified
52
52
  * @type {Stat}
53
+ * @readonly
53
54
  */
54
55
  speed = new Stat(1);
55
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAsbI;;;;;;;;;;;;OAYG;IACH,+BAJW,MAAM,oCAEJ,MAAM,CAqBlB;IApdD;;;;;OAKG;IACH,oBAFU,eAAe,CAES;IAGlC;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;OAIG;IACH,2BAAgB;IAShB;;;;;;OAMG;IACH,gCAAe;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;;OAIG;IACH,yBAAgB;IAEhB;;OAEG;IACH;QACI;;WAEG;;MAEL;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;;;;;;;OAOG;IACH,gCAEC;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;;;OAMG;IACH,+BAFa,MAAM,CAsBlB;IAED;;;;;OAKG;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;;;;;;OAMG;IACH,WAJa,OAAO,CA0BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,wCANa,MAAM,CA+DlB;IAqCL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;;gCAhgB+B,sBAAsB;4BAD1B,kBAAkB;mBAF3B,oCAAoC"}
1
+ {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAkcI;;;;;;;;;;;;OAYG;IACH,+BAJW,MAAM,oCAEJ,MAAM,CAmBlB;IA9dD;;;;;OAKG;IACH,oBAFU,eAAe,CAES;IAGlC;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;OAIG;IACH,2BAAgB;IAShB;;;;;;OAMG;IACH,gCAAe;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;;OAIG;IACH,yBAAgB;IAEhB;;OAEG;IACH;QACI;;WAEG;;MAEL;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;;;;;;;OAOG;IACH,gCAEC;IAED;;OAEG;IACH,4BAUC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;;;OAMG;IACH,+BAFa,MAAM,CAsBlB;IAED;;;;;OAKG;IACH,+BAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,0CAYC;IAED;;;;;OAKG;IACH,8CAQC;IAED;;;;OAIG;IACH,kCAFa,MAAE,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,qBAWhB;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAmBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,sCAGJ,MAAM,CAgBlB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,sCAGJ,MAAM,CA4BlB;IAED;;;;;;OAMG;IACH,WAJa,OAAO,CA0BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,wCANa,MAAM,CA+DlB;IAmCL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;;gCA1gB+B,sBAAsB;4BAD1B,kBAAkB;mBAD3B,oCAAoC"}
@@ -1,6 +1,5 @@
1
1
  import { assert } from "../../core/assert.js";
2
2
  import Signal from "../../core/events/signal/Signal.js";
3
- import { isDefined } from "../../core/process/matcher/isDefined.js";
4
3
  import { EntityFlags } from "./EntityFlags.js";
5
4
  import { EntityReference } from "./EntityReference.js";
6
5
  import { EventType } from "./EventType.js";
@@ -172,7 +171,9 @@ export class Entity {
172
171
  for (let i = n - 1; i >= 0; i--) {
173
172
  const component = elements[i];
174
173
 
175
- this.removeComponent(Object.getPrototypeOf(component).constructor);
174
+ const ComponentClass = Object.getPrototypeOf(component).constructor;
175
+
176
+ this.removeComponent(ComponentClass);
176
177
  }
177
178
  }
178
179
 
@@ -295,6 +296,8 @@ export class Entity {
295
296
  * @param {*} [event]
296
297
  */
297
298
  sendEvent(eventName, event) {
299
+ assert.isString(eventName, "eventName");
300
+
298
301
  if (this.getFlag(EntityFlags.Built)) {
299
302
  this.dataset.sendEvent(this.reference.id, eventName, event);
300
303
  } else {
@@ -307,6 +310,8 @@ export class Entity {
307
310
  * @param {string} eventName
308
311
  */
309
312
  promiseEvent(eventName) {
313
+ assert.isString(eventName, "eventName");
314
+
310
315
  return new Promise((resolve, reject) => {
311
316
 
312
317
  const handle_event = () => {
@@ -331,6 +336,9 @@ export class Entity {
331
336
  * @returns {Entity}
332
337
  */
333
338
  addEventListener(eventName, listener, context) {
339
+ assert.isString(eventName, "eventName");
340
+ assert.isFunction(listener, "listener");
341
+
334
342
  if (this.getFlag(EntityFlags.Built)) {
335
343
  this.dataset.addEntityEventListener(this.reference.id, eventName, listener, context);
336
344
  } else {
@@ -351,6 +359,9 @@ export class Entity {
351
359
  * @returns {Entity}
352
360
  */
353
361
  removeEventListener(eventName, listener, context) {
362
+ assert.isString(eventName, "eventName");
363
+ assert.isFunction(listener, "listener");
364
+
354
365
  if (this.getFlag(EntityFlags.Built)) {
355
366
  this.dataset.removeEntityEventListener(this.reference.id, eventName, listener, context);
356
367
  } else {
@@ -502,9 +513,7 @@ export class Entity {
502
513
 
503
514
  const r = new Entity();
504
515
 
505
- dataset.getAllComponents(entity)
506
- .filter(isDefined)
507
- .forEach(r.add, r);
516
+ dataset.readEntityComponents(r.components, 0, entity);
508
517
 
509
518
  r.setFlag(EntityFlags.Built);
510
519
 
@@ -1 +1 @@
1
- {"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAfyB,MAAM;IAiB3B;;;;OAIG;IACH,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;;;;;;OAMG;IACH,iDAsBC;IAED;;;;;OAKG;IACH,wCAgCC;IAED;;;;;OAKG;IACH,0CA2BC;IAED;;;;;;;;;OASG;IACH,kCARW,MAAM,sCAGJ,IAAI,CAuBhB;IAED;;;;;;;;;OASG;IACH,qCARW,MAAM,sCAGJ,OAAO,CAkCnB;IAED;;;;;;;;;;OAUG;IACH,+BATW,MAAM,cACN,MAAM,uCAGJ,IAAI,CAiChB;IAED;;;;;;;;;;OAUG;IACH,kCATW,MAAM,cACN,MAAM,sCAGJ,OAAO,CA2CnB;IAED;;;;;;;OAOG;IACH,sDAHa,IAAI,CAkBhB;IAED;;;;OAIG;IACH,+BAHW,MAAM,GACJ,OAAO,CAenB;IAED;;;;OAIG;IACH,SAHa,IAAI,CAShB;IAED;;;;;OAKG;IACH,YAHa,IAAI,CAehB;IAED;;;;OAIG;IACH,yCAHW,MAAM,GACJ,IAAI,wBAAkB,CAiBlC;IAED;;;;;OAKG;IACH,mBAHW,sBAAsB,6BACpB,IAAI,CA6DhB;IAED;;;;;OAKG;IACH,2EAFa,IAAI,CAgDhB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,oDAFa,IAAI,CAgBhB;IAGL;;;;;OAKG;IACH,mCAFU,OAAO,CAEwC;IAIzD;;OAEG;IACH,4BA/mBgB,UAAU,MAAM,CAAC,CA+mBoB;IAErD;;OAEG;IACH,iCAjZe,MAAM,wCAGJ,OAAO,CA8Y+B;IAtnBnD;;;OAGG;IACH,qBAFY,UAAU,MAAM,CAAC,CAY5B;CAolBJ;mBAj+DkB,oCAAoC"}
1
+ {"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAfyB,MAAM;IAiB3B;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;O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OAOG;IACH,+CAyBC;IAED;;;;;;OAMG;IACH,iDAsBC;IAED;;;;;OAKG;IACH,wCAgCC;IAED;;;;;OAKG;IACH,0CA2BC;IAED;;;;;;;;;OASG;IACH,kCARW,MAAM,sCAGJ,IAAI,CAuBhB;IAED;;;;;;;;;OASG;IACH,qCARW,MAAM,sCAGJ,OAAO,CAkCnB;IAED;;;;;;;;;;OAUG;IACH,+BATW,MAAM,cACN,MAAM,uCAGJ,IAAI,CAiChB;IAED;;;;;;;;;;OAUG;IACH,kCATW,MAAM,cACN,MAAM,sCAGJ,OAAO,CA2CnB;IAED;;;;;;;OAOG;IACH,kBANW,MAAM,QACN,MAAM,gBAEJ,IAAI,CAmBhB;IAED;;;;OAIG;IACH,+BAHW,MAAM,GACJ,OAAO,CAenB;IAED;;;;OAIG;IACH,SAHa,IAAI,CAShB;IAED;;;;;OAKG;IACH,YAHa,IAAI,CAehB;IAED;;;;OAIG;IACH,yCAHW,MAAM,GACJ,IAAI,wBAAkB,CAiBlC;IAED;;;;;OAKG;IACH,mBAHW,sBAAsB,6BACpB,IAAI,CA6DhB;IAED;;;;;OAKG;IACH,2EAFa,IAAI,CAgDhB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,oDAFa,IAAI,CAgBhB;IAGL;;;;;OAKG;IACH,mCAFU,OAAO,CAEwC;IAIzD;;OAEG;IACH,4BAhnBgB,UAAU,MAAM,CAAC,CAgnBoB;IAErD;;OAEG;IACH,iCAlZe,MAAM,wCAGJ,OAAO,CA+Y+B;IAvnBnD;;;OAGG;IACH,qBAFY,UAAU,MAAM,CAAC,CAY5B;CAqlBJ;mBA/gEkB,oCAAoC"}
@@ -476,11 +476,56 @@ export class EntityComponentDataset {
476
476
  return result;
477
477
  }
478
478
 
479
+ /**
480
+ *
481
+ * @param {[]} output
482
+ * @param {number} output_offset
483
+ * @param {number} entity_id
484
+ * @returns {number} how many components were written to the output
485
+ * @see getAllComponents
486
+ */
487
+ readEntityComponents(
488
+ output,
489
+ output_offset,
490
+ entity_id
491
+ ) {
492
+
493
+ assert.isNonNegativeInteger(entity_id, 'entity_id');
494
+ assert.ok(this.entityExists(entity_id), `Entity ${entity_id} doesn't exist`);
495
+ assert.isArray(output, "output");
496
+ assert.isNonNegativeInteger(output_offset, 'output_offset');
497
+
498
+ const componentTypeCount = this.componentTypeCount;
499
+ const occupancy_start = componentTypeCount * entity_id;
500
+ const occupancy_end = occupancy_start + componentTypeCount;
501
+
502
+ const occupancy = this.componentOccupancy;
503
+
504
+ let offset = output_offset;
505
+
506
+ for (
507
+ let i = occupancy.nextSetBit(occupancy_start);
508
+ i < occupancy_end && i !== -1;
509
+ i = occupancy.nextSetBit(i + 1)
510
+ ) {
511
+ const componentIndex = i % componentTypeCount;
512
+
513
+ const component = this.components[componentIndex][entity_id];
514
+
515
+ output[offset++] = component;
516
+
517
+ }
518
+
519
+ return offset - output_offset;
520
+ }
521
+
479
522
  /**
480
523
  * Get all components associated with a given entity.
481
524
  * Note that this method allocates. If performance is important - prefer alternatives.
525
+ * Prefer to use {@link readEntityComponents} for performance reasons.
482
526
  * @param {number} entity_id
483
527
  * @returns {[]} all components attached to the entity, array is not compacted
528
+ * @see readEntityComponents
484
529
  */
485
530
  getAllComponents(entity_id) {
486
531
  assert.isNonNegativeInteger(entity_id, 'entity_id');
@@ -1775,8 +1820,8 @@ export class EntityComponentDataset {
1775
1820
 
1776
1821
  /**
1777
1822
  * Notifies every component of specified entity with given event
1778
- * @param {Number} entity
1779
- * @param {String} name event name
1823
+ * @param {number} entity
1824
+ * @param {string} name event name
1780
1825
  * @param {Object} [event=undefined]
1781
1826
  * @returns {void}
1782
1827
  * @see addEntityEventListener
@@ -1785,6 +1830,7 @@ export class EntityComponentDataset {
1785
1830
  // console.log("sendEvent", entity, name, event);
1786
1831
 
1787
1832
  assert.isString(name, "name");
1833
+ assert.isNonNegativeInteger(entity, "entity");
1788
1834
 
1789
1835
  dispatchEntityEventListeners(this.__entityEventListeners, entity, name, event);
1790
1836
 
@@ -141,7 +141,7 @@ export class EntityManager {
141
141
  /**
142
142
  * If the {@link EntityManager} is already started, the system will be started automatically before being added
143
143
  * @param {System} system
144
- * @returns {Promise}
144
+ * @returns {Promise} resolution depends on {@link EntityManager}'s state, if running - promise resolves after system startup. Otherwise, the promise will be resolved immediately.
145
145
  * @throws {IllegalStateException}
146
146
  */
147
147
  addSystem(system: System<any, any, any, any, any>): Promise<any>;
@@ -166,8 +166,8 @@ export class EntityManager {
166
166
  */
167
167
  private startSystem;
168
168
  /**
169
- * This method is asynchronous by nature, it has to wait for each individual system to finish its own statup.
170
- * Make sure to register callback in order to be notified when the startup has finished
169
+ * This method is asynchronous by nature, it has to wait for each system to finish its own startup.
170
+ * Make sure to register callback to be notified when the startup has finished
171
171
  * @param {function} [readyCallback] executed once entity manager successfully completes startup
172
172
  * @param {function} [errorCallback] executed if entity manager encounters an error during startup
173
173
  */
@@ -179,17 +179,16 @@ export class EntityManager {
179
179
  */
180
180
  promiseSystem(systemClass: Class): Promise<System<any, any, any, any, any>>;
181
181
  /**
182
- *
183
182
  * @param {Class} systemClass
184
183
  * @param {SystemState} state
185
184
  * @returns {Promise.<System>}
186
185
  */
187
186
  promiseSystemInState(systemClass: Class, state: SystemState): Promise<System<any, any, any, any, any>>;
188
187
  /**
189
- * This method is asynchronous by nature, it will not be done until each individual system has finished its shutdown
188
+ * This method is asynchronous by nature, it will not be done until each system has finished its shutdown
190
189
  * Make sure to use callback to be notified when the shutdown has completed
191
190
  * @param {function} [readyCallback] Called when shutdown finishes successfully. defaults to no-operation
192
- * @param {function} [errorCallback] Called when an error occurs during shutdown process. defaults to console error output
191
+ * @param {function} [errorCallback] Called when an error occurs during the shutdown process. defaults to console error output
193
192
  */
194
193
  shutdown(readyCallback?: Function, errorCallback?: Function): void;
195
194
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":"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ityManager.js"],"names":[],"mappings":"iCAgBU,MAAM;;;;;;;;;AAiBhB;;;;;;GAMG;AACH;IAEI;;;;OAIG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;;;OAMG;IACH,uCAA2B;IAE3B;;;;;OAKG;IACH,iCAA4B;IAE5B;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;;;OAMG;IACH,gDAA2C;IAE3C;;;;;;;;;OASG;IACH,qBAFU,MAAM,CAEqB;IAErC;;;;;OAKG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;;OAIG;IACH,SAFU,sBAAsB,CAEjB;IAEf;;;;;OAKG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BAmFC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,uBAJW,sBAAsB,QA4ChC;IAGD;;;OAGG;IACH,sBA2BC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAgBC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAiBzB;IAGD;;;OAGG;IACH,oBAFW,MAAM,QAoEhB;IAED;;;;;OAKG;IACH,iEA6DC;IAED;;;;OAIG;IACH,uDAFa,QAAQ,OAAO,CAAC,CA2C5B;IAED;;;;;OAKG;IACH,mBAmCC;IAED;;;;;OAKG;IACH,oBAqFC;IAED;;;;;OAKG;IACH,kEAyEC;IAED;;;;OAIG;IACH,mCAFa,wCAAgB,CA0B5B;IAED;;;;OAIG;IACH,8DAFa,wCAAgB,CAsB5B;IAED;;;;;OAKG;IACH,mEAoFC;IAGL;;OAEG;IACH,yBAxrBe,sBAAsB,UAwrBA;IACrC;;OAEG;IACH,0BAAqC;CATpC;uBAh6BmC,aAAa;mBAR9B,oCAAoC;uCAMhB,6BAA6B"}