@woosh/meep-engine 2.105.0 → 2.106.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 (79) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/build/meep.cjs +358 -188
  4. package/build/meep.min.js +1 -1
  5. package/build/meep.module.js +358 -188
  6. package/package.json +1 -1
  7. package/src/core/assert.d.ts.map +1 -1
  8. package/src/core/assert.js +3 -1
  9. package/src/core/cache/Cache.d.ts.map +1 -1
  10. package/src/core/cache/Cache.js +23 -19
  11. package/src/core/collection/array/array_copy.spec.d.ts +2 -0
  12. package/src/core/collection/array/array_copy.spec.d.ts.map +1 -0
  13. package/src/core/collection/array/array_copy.spec.js +19 -0
  14. package/src/core/collection/list/List.d.ts.map +1 -1
  15. package/src/core/collection/list/List.js +55 -30
  16. package/src/core/collection/list/List.spec.js +101 -0
  17. package/src/core/collection/list/ListForwarder.d.ts.map +1 -1
  18. package/src/core/collection/list/ListForwarder.js +49 -53
  19. package/src/core/collection/list/ListForwarder.spec.js +2 -0
  20. package/src/core/collection/list/SortedListProjection.d.ts +4 -1
  21. package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
  22. package/src/core/collection/list/SortedListProjection.js +4 -1
  23. package/src/core/collection/map/AbstractAsyncMap.d.ts.map +1 -1
  24. package/src/core/collection/map/AbstractAsyncMap.js +0 -3
  25. package/src/core/collection/map/AsyncMapWrapper.d.ts +6 -10
  26. package/src/core/collection/map/AsyncMapWrapper.d.ts.map +1 -1
  27. package/src/core/collection/map/AsyncMapWrapper.js +14 -9
  28. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  29. package/src/core/collection/map/HashMap.js +30 -3
  30. package/src/core/collection/map/ObservedMap.d.ts +12 -3
  31. package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
  32. package/src/core/collection/map/ObservedMap.js +14 -4
  33. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  34. package/src/core/collection/queue/Deque.js +100 -95
  35. package/src/core/collection/set/ArraySet.d.ts.map +1 -0
  36. package/src/core/collection/set/{Set.js → ArraySet.js} +2 -2
  37. package/src/core/collection/set/set_remove.d.ts +3 -3
  38. package/src/core/collection/set/set_remove.d.ts.map +1 -1
  39. package/src/core/collection/set/set_remove.js +5 -5
  40. package/src/core/color/oklab/find_gamut_intersection.js +1 -1
  41. package/src/core/geom/2d/Rectangle.d.ts +54 -5
  42. package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
  43. package/src/core/geom/2d/Rectangle.js +70 -3
  44. package/src/core/geom/2d/circle/Circle.d.ts +1 -1
  45. package/src/core/geom/2d/circle/Circle.js +1 -1
  46. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
  47. package/src/core/geom/2d/compute_triangle_area_2d.js +7 -1
  48. package/src/core/geom/2d/shape/AbstractShape.d.ts +2 -0
  49. package/src/core/geom/2d/shape/AbstractShape.d.ts.map +1 -1
  50. package/src/core/geom/2d/shape/AbstractShape.js +8 -2
  51. package/src/core/geom/2d/shape/CircleShape.d.ts +14 -0
  52. package/src/core/geom/2d/shape/CircleShape.d.ts.map +1 -1
  53. package/src/core/geom/2d/shape/CircleShape.js +64 -22
  54. package/src/core/geom/2d/uv_map_circle_to_square.d.ts +8 -0
  55. package/src/core/geom/2d/uv_map_circle_to_square.d.ts.map +1 -0
  56. package/src/core/geom/2d/{UvUtils.js → uv_map_circle_to_square.js} +2 -17
  57. package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts +2 -0
  58. package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts.map +1 -0
  59. package/src/core/geom/2d/uv_map_circle_to_square.spec.js +28 -0
  60. package/src/core/geom/2d/uv_map_square_to_circle.d.ts +8 -0
  61. package/src/core/geom/2d/uv_map_square_to_circle.d.ts.map +1 -0
  62. package/src/core/geom/2d/uv_map_square_to_circle.js +14 -0
  63. package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts +2 -0
  64. package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts.map +1 -0
  65. package/src/core/geom/2d/uv_map_square_to_circle.spec.js +30 -0
  66. package/src/core/geom/Vector3.d.ts +13 -4
  67. package/src/core/geom/Vector3.d.ts.map +1 -1
  68. package/src/core/geom/Vector3.js +83 -36
  69. package/src/core/geom/Vector3.spec.js +113 -12
  70. package/src/core/collection/set/Set.d.ts.map +0 -1
  71. package/src/core/geom/2d/Geometry2D.d.ts +0 -31
  72. package/src/core/geom/2d/Geometry2D.d.ts.map +0 -1
  73. package/src/core/geom/2d/Geometry2D.js +0 -59
  74. package/src/core/geom/2d/UvUtils.d.ts +0 -15
  75. package/src/core/geom/2d/UvUtils.d.ts.map +0 -1
  76. package/src/core/geom/2d/UvUtils.spec.d.ts +0 -2
  77. package/src/core/geom/2d/UvUtils.spec.d.ts.map +0 -1
  78. package/src/core/geom/2d/UvUtils.spec.js +0 -55
  79. /package/src/core/collection/set/{Set.d.ts → ArraySet.d.ts} +0 -0
@@ -249,7 +249,9 @@ class InMemoryDescriptor extends BaseDescription {
249
249
 
250
250
  function equal(a, b, m) {
251
251
  if (a !== b) {
252
- const message = m !== undefined ? m : `${a} !== ${b}`;
252
+ const details = `${a} !== ${b}`;
253
+
254
+ const message = (m !== undefined && m !== "") ? `${m}. ${details}` : details;
253
255
  throw new Error(message);
254
256
  }
255
257
  }
@@ -2104,10 +2106,23 @@ let Vector3$1 = class Vector3 {
2104
2106
  * @constructor
2105
2107
  */
2106
2108
  constructor(x = 0, y = 0, z = 0) {
2109
+ /**
2110
+ * @type {number}
2111
+ */
2107
2112
  this.x = x;
2113
+ /**
2114
+ * @type {number}
2115
+ */
2108
2116
  this.y = y;
2117
+ /**
2118
+ * @type {number}
2119
+ */
2109
2120
  this.z = z;
2110
2121
 
2122
+ /**
2123
+ * @readonly
2124
+ * @type {Signal<number,number,number,number,number,number>}
2125
+ */
2111
2126
  this.onChanged = new Signal();
2112
2127
  }
2113
2128
 
@@ -2405,7 +2420,11 @@ let Vector3$1 = class Vector3 {
2405
2420
  const ax = first.x, ay = first.y, az = first.z;
2406
2421
  const bx = second.x, by = second.y, bz = second.z;
2407
2422
 
2408
- this._crossVectors(ax, ay, az, bx, by, bz);
2423
+ this._crossVectors(
2424
+ ax, ay, az,
2425
+ bx, by, bz
2426
+ );
2427
+
2409
2428
  }
2410
2429
 
2411
2430
  /**
@@ -2617,6 +2636,7 @@ let Vector3$1 = class Vector3 {
2617
2636
  /**
2618
2637
  *
2619
2638
  * @param {THREE.Matrix4} matrix4
2639
+ * @deprecated use {@link @applyMatrix4} directly instead, pass `mat.elements`
2620
2640
  */
2621
2641
  applyMatrix4_three(matrix4) {
2622
2642
  this.applyMatrix4(matrix4.elements);
@@ -2645,7 +2665,9 @@ let Vector3$1 = class Vector3 {
2645
2665
  * @param {ArrayLike<number>|number[]|Float32Array} m4
2646
2666
  */
2647
2667
  applyDirectionMatrix4(m4) {
2648
- const x = this.x, y = this.y, z = this.z;
2668
+ const x = this.x;
2669
+ const y = this.y;
2670
+ const z = this.z;
2649
2671
 
2650
2672
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
2651
2673
  const _y = m4[1] * x + m4[5] * y + m4[9] * z;
@@ -2676,25 +2698,34 @@ let Vector3$1 = class Vector3 {
2676
2698
  }
2677
2699
 
2678
2700
  /**
2679
- *
2701
+ * @deprecated use non-three.js version instead
2680
2702
  * @param {THREE.Matrix3} m
2681
2703
  * @returns {Vector3}
2682
2704
  */
2683
2705
  applyMatrix3_three(m) {
2706
+ this.applyMatrix3(m.elements);
2684
2707
 
2685
- const x = this.x, y = this.y, z = this.z;
2686
- const e = m.elements;
2708
+ return this;
2709
+ }
2687
2710
 
2688
- const _x = e[0] * x + e[3] * y + e[6] * z;
2689
- const _y = e[1] * x + e[4] * y + e[7] * z;
2690
- const _z = e[2] * x + e[5] * y + e[8] * z;
2711
+ /**
2712
+ *
2713
+ * @param {number[]|Float32Array} mat
2714
+ */
2715
+ applyMatrix3(mat) {
2716
+ const x = this.x;
2717
+ const y = this.y;
2718
+ const z = this.z;
2691
2719
 
2692
- return this.set(_x, _y, _z);
2720
+ const _x = mat[0] * x + mat[3] * y + mat[6] * z;
2721
+ const _y = mat[1] * x + mat[4] * y + mat[7] * z;
2722
+ const _z = mat[2] * x + mat[5] * y + mat[8] * z;
2693
2723
 
2724
+ this.set(_x, _y, _z);
2694
2725
  }
2695
2726
 
2696
2727
  /**
2697
- *
2728
+ * @deprecated use non-three.js version instead
2698
2729
  * @param {THREE.Matrix4} matrix4
2699
2730
  */
2700
2731
  threejs_setFromMatrixPosition(matrix4) {
@@ -2779,17 +2810,7 @@ let Vector3$1 = class Vector3 {
2779
2810
  const y1 = other.y;
2780
2811
  const z1 = other.z;
2781
2812
 
2782
- const d = v3_dot(x0, y0, z0, x1, y1, z1);
2783
-
2784
- const mag2 = (x1 * x1 + y1 * y1 + z1 * z1);
2785
-
2786
- const m = d / mag2;
2787
-
2788
- const x = x1 * m;
2789
- const y = y1 * m;
2790
- const z = z1 * m;
2791
-
2792
- this.set(x, y, z);
2813
+ this._projectVectors(x0, y0, z0, x1, y1, z1);
2793
2814
  }
2794
2815
 
2795
2816
  /**
@@ -2826,7 +2847,10 @@ let Vector3$1 = class Vector3 {
2826
2847
  * @param {number} y1
2827
2848
  * @param {number} z1
2828
2849
  */
2829
- _projectVectors(x0, y0, z0, x1, y1, z1) {
2850
+ _projectVectors(
2851
+ x0, y0, z0,
2852
+ x1, y1, z1
2853
+ ) {
2830
2854
 
2831
2855
  const d = v3_dot(x0, y0, z0, x1, y1, z1);
2832
2856
 
@@ -2849,11 +2873,15 @@ let Vector3$1 = class Vector3 {
2849
2873
  */
2850
2874
  setFromSphericalCoords(radius, phi, theta) {
2851
2875
 
2852
- const sinPhiRadius = Math.sin(phi) * radius;
2876
+ const sin_phi = Math.sin(phi);
2877
+ const cos_phi = Math.cos(phi);
2878
+
2879
+ const sin_theta = Math.sin(theta);
2880
+ const cos_theta = Math.cos(theta);
2853
2881
 
2854
- const _x = sinPhiRadius * Math.sin(theta);
2855
- const _y = Math.cos(phi) * radius;
2856
- const _z = sinPhiRadius * Math.cos(theta);
2882
+ const _x = radius * sin_phi * sin_theta;
2883
+ const _y = radius * cos_phi;
2884
+ const _z = radius * sin_phi * cos_theta;
2857
2885
 
2858
2886
  this.set(_x, _y, _z);
2859
2887
  }
@@ -2861,11 +2889,15 @@ let Vector3$1 = class Vector3 {
2861
2889
  /**
2862
2890
  *
2863
2891
  * @param {function} processor
2892
+ * @param {*} [thisArg]
2864
2893
  * @returns {Vector3}
2865
2894
  */
2866
- process(processor) {
2867
- processor(this.x, this.y, this.z);
2868
- this.onChanged.add(processor);
2895
+ process(processor, thisArg) {
2896
+
2897
+ processor.call(thisArg, this.x, this.y, this.z);
2898
+
2899
+ this.onChanged.add(processor, thisArg);
2900
+
2869
2901
  return this;
2870
2902
  }
2871
2903
 
@@ -2879,6 +2911,7 @@ let Vector3$1 = class Vector3 {
2879
2911
  */
2880
2912
  fromJSON(json) {
2881
2913
  if (typeof json === 'number') {
2914
+ // special case where input is a number
2882
2915
  this.setScalar(json);
2883
2916
  } else {
2884
2917
  this.copy(json);
@@ -2892,6 +2925,7 @@ let Vector3$1 = class Vector3 {
2892
2925
  /**
2893
2926
  *
2894
2927
  * @param {BinaryBuffer} buffer
2928
+ * @deprecated
2895
2929
  */
2896
2930
  toBinaryBuffer(buffer) {
2897
2931
  buffer.writeFloat64(this.x);
@@ -2902,6 +2936,7 @@ let Vector3$1 = class Vector3 {
2902
2936
  /**
2903
2937
  *
2904
2938
  * @param {BinaryBuffer} buffer
2939
+ * @deprecated
2905
2940
  */
2906
2941
  fromBinaryBuffer(buffer) {
2907
2942
  const x = buffer.readFloat64();
@@ -2914,6 +2949,7 @@ let Vector3$1 = class Vector3 {
2914
2949
  /**
2915
2950
  *
2916
2951
  * @param {BinaryBuffer} buffer
2952
+ * @deprecated
2917
2953
  */
2918
2954
  toBinaryBufferFloat32(buffer) {
2919
2955
  buffer.writeFloat32(this.x);
@@ -2924,6 +2960,7 @@ let Vector3$1 = class Vector3 {
2924
2960
  /**
2925
2961
  *
2926
2962
  * @param {BinaryBuffer} buffer
2963
+ * @deprecated
2927
2964
  */
2928
2965
  fromBinaryBufferFloat32(buffer) {
2929
2966
  const x = buffer.readFloat32();
@@ -3043,12 +3080,6 @@ Vector3$1.prototype.fromArray = Vector3$1.prototype.readFromArray;
3043
3080
  Vector3$1.prototype.toArray = Vector3$1.prototype.writeToArray;
3044
3081
 
3045
3082
 
3046
- /**
3047
- * @readonly
3048
- * @type {boolean}
3049
- */
3050
- Vector3$1.prototype.isVector3 = true;
3051
-
3052
3083
  /**
3053
3084
  * @readonly
3054
3085
  * @type {Vector3}
@@ -3105,10 +3136,20 @@ Vector3$1.forward = Object.freeze(new Vector3$1(0, 0, 1));
3105
3136
  */
3106
3137
  Vector3$1.back = Object.freeze(new Vector3$1(0, 0, -1));
3107
3138
 
3139
+ /**
3140
+ * @readonly
3141
+ * @type {boolean}
3142
+ */
3143
+ Vector3$1.prototype.isVector3 = true;
3144
+
3145
+ /**
3146
+ * @readonly
3147
+ * @type {string}
3148
+ */
3108
3149
  Vector3$1.typeName = "Vector3";
3109
3150
 
3110
3151
  /**
3111
- *
3152
+ * @deprecated use {@link v3_dot} directly instead
3112
3153
  * @param {number} x0
3113
3154
  * @param {number} y0
3114
3155
  * @param {number} z0
@@ -60139,6 +60180,8 @@ class HashMap {
60139
60180
  this.#bin_count = 2 ** this.#bin_count_power_of_two;
60140
60181
  this.#bin_count_mask = this.#bin_count - 1;
60141
60182
 
60183
+ const old_entry_allocation_count = this.#entries_allocated_count;
60184
+
60142
60185
  this.#entries_allocated_count = 2 ** this.#entries_count_power_of_two;
60143
60186
 
60144
60187
  const BinsArray = UintArrayForCount(this.#entries_allocated_count + ENTRY_BASE);
@@ -60150,7 +60193,7 @@ class HashMap {
60150
60193
 
60151
60194
  this.#entries = new_entries;
60152
60195
 
60153
- array_copy(old_entries, 0, new_entries, 0, min2(old_entries.length, this.#entries_allocated_count));
60196
+ array_copy(old_entries, 0, new_entries, 0, min2(old_entry_allocation_count, this.#entries_allocated_count));
60154
60197
 
60155
60198
  if (this.#size > 0) {
60156
60199
  // re-hash
@@ -60219,12 +60262,21 @@ class HashMap {
60219
60262
  this.#entries_bound++;
60220
60263
 
60221
60264
  if (this.#entries[i] !== undefined) {
60265
+
60266
+ // entry exists, let's reuse it
60267
+
60222
60268
  const entry = this.#entries[i];
60269
+
60223
60270
  entry.hash = hash;
60224
60271
  entry.key = k;
60225
60272
  entry.value = v;
60273
+
60226
60274
  } else {
60275
+
60276
+ // entry slot is empty
60277
+
60227
60278
  this.#entries[i] = new HashMapEntry(k, v, hash);
60279
+
60228
60280
  }
60229
60281
 
60230
60282
  return i;
@@ -60296,7 +60348,9 @@ class HashMap {
60296
60348
 
60297
60349
  const entry_index = this.#allocate_entry(key, value, raw_hash);
60298
60350
 
60299
- this.#bins[bin_index] = entry_index + ENTRY_BASE;
60351
+ const bin_value = entry_index + ENTRY_BASE;
60352
+
60353
+ this.#bins[bin_index] = bin_value;
60300
60354
 
60301
60355
  break;
60302
60356
 
@@ -60371,6 +60425,7 @@ class HashMap {
60371
60425
  * @return {V}
60372
60426
  */
60373
60427
  getOrCompute(key, compute, compute_context) {
60428
+
60374
60429
  const existing = this.get(key);
60375
60430
 
60376
60431
  if (existing !== undefined) {
@@ -60526,7 +60581,11 @@ class HashMap {
60526
60581
 
60527
60582
  let written_entries = 0;
60528
60583
 
60529
- for (let existing_entry_index = this.#entries_start; existing_entry_index < entries_bound; existing_entry_index++) {
60584
+ for (
60585
+ let existing_entry_index = this.#entries_start;
60586
+ existing_entry_index < entries_bound;
60587
+ existing_entry_index++
60588
+ ) {
60530
60589
  const entry = entries[existing_entry_index];
60531
60590
 
60532
60591
  const hash = entry.hash;
@@ -60580,6 +60639,7 @@ class HashMap {
60580
60639
  }
60581
60640
 
60582
60641
  forEach(callback, thisArg) {
60642
+
60583
60643
  const count = this.#bin_count;
60584
60644
  const entries = this.#entries;
60585
60645
  const bins = this.#bins;
@@ -61080,6 +61140,22 @@ class Cache {
61080
61140
  let element = this.data.get(key);
61081
61141
 
61082
61142
  if (element === undefined) {
61143
+ //compute weight
61144
+ const elementWeight = this.computeElementWeight(key, value);
61145
+
61146
+ /**
61147
+ * It's possible that element being added is larger than cache's capacity,
61148
+ * in which case entire cache will be evicted, but there still won't be enough space
61149
+ * @type {number}
61150
+ */
61151
+ const weightTarget = this.#maxWeight - elementWeight;
61152
+
61153
+ if (weightTarget < 0) {
61154
+ // Special case
61155
+ // element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
61156
+ return;
61157
+ }
61158
+
61083
61159
  element = new CacheElement();
61084
61160
 
61085
61161
  element.key = key;
@@ -61097,25 +61173,8 @@ class Cache {
61097
61173
  this.__last = element;
61098
61174
  }
61099
61175
 
61100
- //compute weight
61101
- const elementWeight = this.computeElementWeight(key, value);
61102
-
61103
61176
  element.weight = elementWeight;
61104
61177
 
61105
-
61106
- /**
61107
- * It's possible that element being added is larger than cache's capacity,
61108
- * in which case entire cache will be evicted, but there still won't be enough space
61109
- * @type {number}
61110
- */
61111
- const weightTarget = this.#maxWeight - elementWeight;
61112
-
61113
- if (weightTarget < 0) {
61114
- // Special case
61115
- // element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
61116
- return;
61117
- }
61118
-
61119
61178
  //evict elements until there is enough space for the element
61120
61179
  this.evictUntilWeight(weightTarget);
61121
61180
 
@@ -61128,9 +61187,14 @@ class Cache {
61128
61187
  // check if value is the same
61129
61188
  if (value === element.value) ; else {
61130
61189
  // replace value, adjust weight
61131
- this.#weight -= this.valueWeigher(element.value);
61132
- this.#weight += this.valueWeigher(value);
61190
+ this.#weight -= element.weight;
61133
61191
 
61192
+ const elementWeight = this.computeElementWeight(key, value);
61193
+
61194
+ this.#weight += elementWeight;
61195
+
61196
+ // assign new values
61197
+ element.weight = elementWeight;
61134
61198
  element.value = value;
61135
61199
  }
61136
61200
 
@@ -61430,18 +61494,27 @@ class List {
61430
61494
  removed: new Signal()
61431
61495
  };
61432
61496
 
61497
+ /**
61498
+ *
61499
+ * @type {T[]}
61500
+ */
61501
+ data = []
61502
+
61433
61503
  /**
61434
61504
  * @param {[]} [array]
61435
61505
  * @constructor
61436
61506
  */
61437
61507
  constructor(array) {
61438
61508
 
61439
- /**
61440
- * @private
61441
- * @readonly
61442
- * @type {T[]}
61443
- */
61444
- this.data = array !== undefined ? array.slice() : [];
61509
+ if (array !== undefined) {
61510
+
61511
+ /**
61512
+ * @private
61513
+ * @readonly
61514
+ * @type {T[]}
61515
+ */
61516
+ this.data = array.slice();
61517
+ }
61445
61518
 
61446
61519
  /**
61447
61520
  * Number of elements in the list
@@ -61530,9 +61603,11 @@ class List {
61530
61603
 
61531
61604
  if (index > this.length) {
61532
61605
  this.length = index;
61533
- }
61534
61606
 
61535
- this.data.splice(index, 0, el);
61607
+ this.data[index] = el;
61608
+ } else {
61609
+ this.data.splice(index, 0, el);
61610
+ }
61536
61611
 
61537
61612
  this.length++;
61538
61613
 
@@ -61670,11 +61745,11 @@ class List {
61670
61745
  addAllUnique(elements) {
61671
61746
  const data = this.data;
61672
61747
 
61673
- const unique = elements.filter(function (e, i) {
61674
- return data.indexOf(e) === -1 && elements.indexOf(e, i + 1) === -1;
61675
- });
61748
+ const length = data.length;
61676
61749
 
61677
- this.addAll(unique);
61750
+ for (let i = 0; i < length; i++) {
61751
+ this.addUnique(data[i]);
61752
+ }
61678
61753
  }
61679
61754
 
61680
61755
  /**
@@ -61685,21 +61760,23 @@ class List {
61685
61760
  */
61686
61761
  removeMany(index, removeCount) {
61687
61762
 
61688
- const els = this.data.splice(index, removeCount);
61763
+ const removed_elements = this.data.splice(index, removeCount);
61689
61764
 
61690
- const removedCount = els.length;
61765
+ const removedCount = removed_elements.length;
61691
61766
 
61692
61767
  this.length -= removedCount;
61693
61768
 
61694
- if (this.on.removed.hasHandlers()) {
61769
+ const onRemoved = this.on.removed;
61770
+
61771
+ if (onRemoved.hasHandlers()) {
61695
61772
  for (let i = 0; i < removedCount; i++) {
61696
- const element = els[i];
61773
+ const element = removed_elements[i];
61697
61774
 
61698
- this.on.removed.send2(element, index + i);
61775
+ onRemoved.send2(element, index + i);
61699
61776
  }
61700
61777
  }
61701
61778
 
61702
- return els;
61779
+ return removed_elements;
61703
61780
  }
61704
61781
 
61705
61782
  /**
@@ -61778,8 +61855,13 @@ class List {
61778
61855
  }
61779
61856
  }
61780
61857
 
61781
- sort() {
61782
- Array.prototype.sort.apply(this.data, arguments);
61858
+ /**
61859
+ *
61860
+ * @param {function(a:T, b:T):number} [compare_function]
61861
+ * @returns {List}
61862
+ */
61863
+ sort(compare_function) {
61864
+ Array.prototype.sort.call(this.data, compare_function);
61783
61865
  return this;
61784
61866
  }
61785
61867
 
@@ -61943,18 +62025,24 @@ class List {
61943
62025
  *
61944
62026
  * @param {function(el:T):boolean} matcher
61945
62027
  * @param {function(el:T, index:number):*} callback
62028
+ * @returns {boolean}
61946
62029
  */
61947
62030
  visitFirstMatch(matcher, callback) {
61948
- const data = this.data;
61949
- let i = 0;
61950
- const l = this.length;
61951
- for (; i < l; i++) {
61952
- const el = data[i];
61953
- if (matcher(el)) {
61954
- callback(el, i);
61955
- return;
61956
- }
62031
+ const index = this.findIndex(matcher);
62032
+
62033
+ if (index === -1) {
62034
+ return false;
61957
62035
  }
62036
+
62037
+ const el = this.data[index];
62038
+
62039
+ if (matcher(el)) {
62040
+ callback(el, index);
62041
+ return true;
62042
+ } else {
62043
+ return false;
62044
+ }
62045
+
61958
62046
  }
61959
62047
 
61960
62048
  /**
@@ -84556,15 +84644,25 @@ class BinaryHeap {
84556
84644
  * @template K,V
84557
84645
  */
84558
84646
  class ObservedMap {
84647
+ /**
84648
+ * @readonly
84649
+ */
84650
+ on = {
84651
+ /**
84652
+ * @type {Signal}
84653
+ */
84654
+ set: new Signal(),
84655
+ /**
84656
+ * @type {Signal}
84657
+ */
84658
+ deleted: new Signal()
84659
+ };
84660
+
84559
84661
  /**
84560
84662
  * @template K,V
84561
84663
  * @constructor
84562
84664
  */
84563
84665
  constructor(source = new Map()) {
84564
- this.on = {
84565
- set: new Signal(),
84566
- deleted: new Signal()
84567
- };
84568
84666
 
84569
84667
  /**
84570
84668
  *
@@ -84634,11 +84732,42 @@ const STATUS_FULL = 0;
84634
84732
  const STATUS_EMPTY = 1;
84635
84733
  const STATUS_NORMAL = 2;
84636
84734
 
84735
+ const EMPTY_ARRAY = new Array(0);
84736
+
84637
84737
  /**
84638
84738
  * Double-ended queue backed by an array
84639
84739
  * @template T
84640
84740
  */
84641
84741
  class Deque {
84742
+
84743
+ /**
84744
+ * Using static array allocator to preserve data locality.
84745
+ * Initialization via "[]" would give us a dynamically sized array,
84746
+ * but it would have unpredictable locality as array may or may not have it's elements stored next to each other in memory
84747
+ * @type {T[]}
84748
+ * @private
84749
+ */
84750
+ #data=EMPTY_ARRAY;
84751
+ /**
84752
+ *
84753
+ * @type {number}
84754
+ * @private
84755
+ */
84756
+ #head = 0;
84757
+ /**
84758
+ *
84759
+ * @type {number}
84760
+ * @private
84761
+ */
84762
+ #tail = 0;
84763
+
84764
+ /**
84765
+ *
84766
+ * @type {number}
84767
+ * @private
84768
+ */
84769
+ #status = STATUS_EMPTY;
84770
+
84642
84771
  /**
84643
84772
  * @template T
84644
84773
  * @param {number} [min_size]
@@ -84647,34 +84776,8 @@ class Deque {
84647
84776
 
84648
84777
  const size = ceilPowerOfTwo(max2(1, min_size));
84649
84778
 
84650
- /**
84651
- * Using static array allocator to preserve data locality.
84652
- * Initialization via "[]" would give us a dynamically sized array,
84653
- * but it would have unpredictable locality as array may or may not have it's elements stored next to each other in memory
84654
- * @type {T[]}
84655
- * @private
84656
- */
84657
- this.__data = new Array(size);
84658
-
84659
- /**
84660
- *
84661
- * @type {number}
84662
- * @private
84663
- */
84664
- this.__head = 0;
84665
- /**
84666
- *
84667
- * @type {number}
84668
- * @private
84669
- */
84670
- this.__tail = 0;
84779
+ this.#data = new Array(size);
84671
84780
 
84672
- /**
84673
- *
84674
- * @type {number}
84675
- * @private
84676
- */
84677
- this.__status = STATUS_EMPTY;
84678
84781
  }
84679
84782
 
84680
84783
  /**
@@ -84682,14 +84785,14 @@ class Deque {
84682
84785
  * @param {boolean} adding
84683
84786
  * @private
84684
84787
  */
84685
- resetStatus(adding) {
84686
- const head = this.__head;
84687
- const tail = this.__tail;
84788
+ #reset_status(adding) {
84789
+ const head = this.#head;
84790
+ const tail = this.#tail;
84688
84791
 
84689
84792
  if (head === tail) {
84690
- this.__status = adding ? STATUS_FULL : STATUS_EMPTY;
84793
+ this.#status = adding ? STATUS_FULL : STATUS_EMPTY;
84691
84794
  } else {
84692
- this.__status = STATUS_NORMAL;
84795
+ this.#status = STATUS_NORMAL;
84693
84796
  }
84694
84797
  }
84695
84798
 
@@ -84699,10 +84802,10 @@ class Deque {
84699
84802
  * @returns {number}
84700
84803
  * @private
84701
84804
  */
84702
- __circular_next_position(current) {
84805
+ #circular_next_position(current) {
84703
84806
  const next = current + 1;
84704
84807
 
84705
- const length = this.__data.length;
84808
+ const length = this.#data.length;
84706
84809
 
84707
84810
  return (next >= length) ? 0 : next;
84708
84811
  }
@@ -84713,20 +84816,20 @@ class Deque {
84713
84816
  * @returns {number}
84714
84817
  * @private
84715
84818
  */
84716
- __circular_previous_position(current) {
84819
+ #circular_previous_position(current) {
84717
84820
  const prev = current - 1;
84718
- return (prev < 0) ? (this.__data.length - 1) : prev;
84821
+ return (prev < 0) ? (this.#data.length - 1) : prev;
84719
84822
  }
84720
84823
 
84721
- __check_and_expand() {
84722
- const status = this.__status;
84824
+ #check_and_expand() {
84825
+ const status = this.#status;
84723
84826
 
84724
84827
  if (status !== STATUS_FULL) {
84725
84828
  // queue still has space, we're done
84726
84829
  return;
84727
84830
  }
84728
84831
 
84729
- const length = this.__data.length;
84832
+ const length = this.#data.length;
84730
84833
 
84731
84834
  if (UINT32_MAX === length) {
84732
84835
  throw new Error('Maximum array size exceeded');
@@ -84745,19 +84848,19 @@ class Deque {
84745
84848
  */
84746
84849
  const new_data = new Array(new_length);
84747
84850
 
84748
- const head = this.__head;
84851
+ const head = this.#head;
84749
84852
 
84750
84853
  // copy the front portion
84751
- array_copy(this.__data, head, new_data, 0, length - head);
84854
+ array_copy(this.#data, head, new_data, 0, length - head);
84752
84855
  // copy the remainder
84753
- array_copy(this.__data, 0, new_data, length - head, head);
84856
+ array_copy(this.#data, 0, new_data, length - head, head);
84754
84857
 
84755
- this.__head = 0;
84756
- this.__tail = length;
84858
+ this.#head = 0;
84859
+ this.#tail = length;
84757
84860
 
84758
- this.__status = STATUS_NORMAL;
84861
+ this.#status = STATUS_NORMAL;
84759
84862
 
84760
- this.__data = new_data;
84863
+ this.#data = new_data;
84761
84864
  }
84762
84865
 
84763
84866
  /**
@@ -84769,34 +84872,34 @@ class Deque {
84769
84872
  }
84770
84873
 
84771
84874
  clear() {
84772
- if (this.__status !== STATUS_EMPTY) {
84773
- let cursor = this.__head;
84774
- const tail = this.__tail;
84875
+ if (this.#status !== STATUS_EMPTY) {
84876
+ let cursor = this.#head;
84877
+ const tail = this.#tail;
84775
84878
 
84776
84879
  do {
84777
- this.__data[cursor] = undefined;
84778
- cursor = this.__circular_next_position(cursor);
84880
+ this.#data[cursor] = undefined;
84881
+ cursor = this.#circular_next_position(cursor);
84779
84882
  } while (cursor !== tail);
84780
84883
 
84781
- this.__status = STATUS_EMPTY;
84884
+ this.#status = STATUS_EMPTY;
84782
84885
  }
84783
84886
 
84784
- this.__head = 0;
84785
- this.__tail = 0;
84887
+ this.#head = 0;
84888
+ this.#tail = 0;
84786
84889
  }
84787
84890
 
84788
84891
  /**
84789
84892
  * @returns {number}
84790
84893
  */
84791
84894
  size() {
84792
- const data = this.__data;
84895
+ const data = this.#data;
84793
84896
 
84794
- if (this.__status === STATUS_FULL) {
84897
+ if (this.#status === STATUS_FULL) {
84795
84898
  return data.length;
84796
84899
  }
84797
84900
 
84798
- const head = this.__head;
84799
- const tail = this.__tail;
84901
+ const head = this.#head;
84902
+ const tail = this.#tail;
84800
84903
 
84801
84904
  return (head <= tail) ? (tail - head) : (tail + data.length - head);
84802
84905
  }
@@ -84807,43 +84910,43 @@ class Deque {
84807
84910
  * @param {boolean} shift_front should we shift elements before the removed element or after?
84808
84911
  * @private
84809
84912
  */
84810
- __remove_internal(current, shift_front) {
84913
+ #remove_internal(current, shift_front) {
84811
84914
  let cursor = current;
84812
84915
 
84813
84916
  if (shift_front) {
84814
84917
 
84815
84918
  // shift towards tail
84816
84919
 
84817
- const head = this.__head;
84920
+ const head = this.#head;
84818
84921
 
84819
84922
  while (cursor !== head) {
84820
- const next = this.__circular_previous_position(cursor);
84821
- this.__data[cursor] = this.__data[next];
84923
+ const next = this.#circular_previous_position(cursor);
84924
+ this.#data[cursor] = this.#data[next];
84822
84925
  cursor = next;
84823
84926
  }
84824
84927
 
84825
- this.__head = this.__circular_next_position(head);
84928
+ this.#head = this.#circular_next_position(head);
84826
84929
 
84827
84930
  } else {
84828
84931
 
84829
84932
  // shift towards head
84830
84933
 
84831
- const tail = this.__tail;
84934
+ const tail = this.#tail;
84832
84935
 
84833
84936
  while (cursor !== tail) {
84834
- const next = this.__circular_next_position(cursor);
84835
- this.__data[cursor] = this.__data[next];
84937
+ const next = this.#circular_next_position(cursor);
84938
+ this.#data[cursor] = this.#data[next];
84836
84939
  cursor = next;
84837
84940
  }
84838
84941
 
84839
- this.__tail = this.__circular_previous_position(tail);
84942
+ this.#tail = this.#circular_previous_position(tail);
84840
84943
 
84841
84944
  }
84842
84945
 
84843
84946
  // fill in slot of last moved element
84844
- this.__data[cursor] = undefined;
84947
+ this.#data[cursor] = undefined;
84845
84948
 
84846
- this.resetStatus(false);
84949
+ this.#reset_status(false);
84847
84950
  }
84848
84951
 
84849
84952
  /**
@@ -84852,13 +84955,13 @@ class Deque {
84852
84955
  * @returns {boolean}
84853
84956
  */
84854
84957
  remove(e) {
84855
- const i = this.__index_of(e);
84958
+ const i = this.#index_of(e);
84856
84959
 
84857
84960
  if (i === -1) {
84858
84961
  return false;
84859
84962
  }
84860
84963
 
84861
- this.__remove_internal(i, true);
84964
+ this.#remove_internal(i, true);
84862
84965
 
84863
84966
  return true;
84864
84967
  }
@@ -84869,14 +84972,14 @@ class Deque {
84869
84972
  * @returns {number}
84870
84973
  * @private
84871
84974
  */
84872
- __index_of(e) {
84975
+ #index_of(e) {
84873
84976
  const size = this.size();
84874
84977
 
84875
- const data = this.__data;
84978
+ const data = this.#data;
84876
84979
  const capacity = data.length;
84877
84980
 
84878
84981
  for (let i = 0; i < size; i++) {
84879
- const index = (this.__head + i) % capacity;
84982
+ const index = (this.#head + i) % capacity;
84880
84983
 
84881
84984
  const el = data[index];
84882
84985
 
@@ -84894,7 +84997,7 @@ class Deque {
84894
84997
  * @returns {boolean}
84895
84998
  */
84896
84999
  has(e) {
84897
- return this.__index_of(e) !== -1;
85000
+ return this.#index_of(e) !== -1;
84898
85001
  }
84899
85002
 
84900
85003
  /**
@@ -84902,10 +85005,10 @@ class Deque {
84902
85005
  * @param {T} e
84903
85006
  */
84904
85007
  addFirst(e) {
84905
- this.__check_and_expand();
84906
- this.__head = this.__circular_previous_position(this.__head);
84907
- this.__data[this.__head] = e;
84908
- this.resetStatus(true);
85008
+ this.#check_and_expand();
85009
+ this.#head = this.#circular_previous_position(this.#head);
85010
+ this.#data[this.#head] = e;
85011
+ this.#reset_status(true);
84909
85012
  }
84910
85013
 
84911
85014
  /**
@@ -84913,10 +85016,10 @@ class Deque {
84913
85016
  * @returns {T|undefined}
84914
85017
  */
84915
85018
  removeFirst() {
84916
- const element = this.__data[this.__head];
84917
- this.__data[this.__head] = undefined;
84918
- this.__head = this.__circular_next_position(this.__head);
84919
- this.resetStatus(false);
85019
+ const element = this.#data[this.#head];
85020
+ this.#data[this.#head] = undefined;
85021
+ this.#head = this.#circular_next_position(this.#head);
85022
+ this.#reset_status(false);
84920
85023
  return element;
84921
85024
  }
84922
85025
 
@@ -84925,7 +85028,7 @@ class Deque {
84925
85028
  * @returns {T|undefined}
84926
85029
  */
84927
85030
  getFirst() {
84928
- return this.__data[this.__head];
85031
+ return this.#data[this.#head];
84929
85032
  }
84930
85033
 
84931
85034
  /**
@@ -84933,10 +85036,10 @@ class Deque {
84933
85036
  * @param {T} e
84934
85037
  */
84935
85038
  addLast(e) {
84936
- this.__check_and_expand();
84937
- this.__data[this.__tail] = e;
84938
- this.__tail = this.__circular_next_position(this.__tail);
84939
- this.resetStatus(true);
85039
+ this.#check_and_expand();
85040
+ this.#data[this.#tail] = e;
85041
+ this.#tail = this.#circular_next_position(this.#tail);
85042
+ this.#reset_status(true);
84940
85043
  }
84941
85044
 
84942
85045
  /**
@@ -84944,11 +85047,11 @@ class Deque {
84944
85047
  * @returns {T}
84945
85048
  */
84946
85049
  removeLast() {
84947
- const last = this.__circular_previous_position(this.__tail);
84948
- const element = this.__data[last];
84949
- this.__data[last] = undefined;
84950
- this.__tail = last;
84951
- this.resetStatus(false);
85050
+ const last = this.#circular_previous_position(this.#tail);
85051
+ const element = this.#data[last];
85052
+ this.#data[last] = undefined;
85053
+ this.#tail = last;
85054
+ this.#reset_status(false);
84952
85055
  return element;
84953
85056
  }
84954
85057
 
@@ -84958,8 +85061,8 @@ class Deque {
84958
85061
  * @returns {T|undefined}
84959
85062
  */
84960
85063
  getLast() {
84961
- const last = this.__circular_previous_position(this.__tail);
84962
- return this.__data[last];
85064
+ const last = this.#circular_previous_position(this.#tail);
85065
+ return this.#data[last];
84963
85066
  }
84964
85067
  }
84965
85068
 
@@ -98772,6 +98875,38 @@ class Rectangle {
98772
98875
  this.size = new Vector2(width, height);
98773
98876
  }
98774
98877
 
98878
+ /**
98879
+ *
98880
+ * @return {number}
98881
+ */
98882
+ get x0() {
98883
+ return this.position.x;
98884
+ }
98885
+
98886
+ /**
98887
+ *
98888
+ * @return {number}
98889
+ */
98890
+ get x1() {
98891
+ return this.position.x + this.size.x;
98892
+ }
98893
+
98894
+ /**
98895
+ *
98896
+ * @return {number}
98897
+ */
98898
+ get y0() {
98899
+ return this.position.y;
98900
+ }
98901
+
98902
+ /**
98903
+ *
98904
+ * @return {number}
98905
+ */
98906
+ get y1() {
98907
+ return this.position.y + this.size.y;
98908
+ }
98909
+
98775
98910
  /**
98776
98911
  *
98777
98912
  * @param {number} x
@@ -98789,7 +98924,13 @@ class Rectangle {
98789
98924
  * @returns {Rectangle}
98790
98925
  */
98791
98926
  clone() {
98792
- return new Rectangle(this.position.x, this.position.y, this.size.x, this.size.y);
98927
+ const position = this.position;
98928
+ const size = this.size;
98929
+
98930
+ return new Rectangle(
98931
+ position.x, position.y,
98932
+ size.x, size.y
98933
+ );
98793
98934
  }
98794
98935
 
98795
98936
  /**
@@ -98850,6 +98991,11 @@ class Rectangle {
98850
98991
  return overlap1D(x0, x1, _x0, s.x + _x0) && overlap1D(y0, y1, _y0, _y0 + s.y);
98851
98992
  }
98852
98993
 
98994
+ /**
98995
+ *
98996
+ * @param {Rectangle} other
98997
+ * @returns {boolean}
98998
+ */
98853
98999
  overlaps(other) {
98854
99000
  const x0 = other.position.x;
98855
99001
  const y0 = other.position.y;
@@ -98858,6 +99004,13 @@ class Rectangle {
98858
99004
  return this._overlaps(x0, y0, x1, y1);
98859
99005
  }
98860
99006
 
99007
+ /**
99008
+ *
99009
+ * @param {number} x0
99010
+ * @param {number} y0
99011
+ * @param {number} x1
99012
+ * @param {number} y1
99013
+ */
98861
99014
  _resizeToFit(x0, y0, x1, y1) {
98862
99015
  const size = this.size;
98863
99016
 
@@ -98883,6 +99036,10 @@ class Rectangle {
98883
99036
  size.set(nX1 - nX0, nY1 - nY0);
98884
99037
  }
98885
99038
 
99039
+ /**
99040
+ *
99041
+ * @param {Rectangle} other
99042
+ */
98886
99043
  resizeToFit(other) {
98887
99044
  const x0 = other.position.x;
98888
99045
  const y0 = other.position.y;
@@ -98892,6 +99049,14 @@ class Rectangle {
98892
99049
  return this._resizeToFit(x0, y0, x1, y1);
98893
99050
  }
98894
99051
 
99052
+ /**
99053
+ *
99054
+ * @param {number} x0
99055
+ * @param {number} y0
99056
+ * @param {number} x1
99057
+ * @param {number} y1
99058
+ * @returns {boolean}
99059
+ */
98895
99060
  _contains(x0, y0, x1, y1) {
98896
99061
  const size = this.size;
98897
99062
 
@@ -98904,6 +99069,11 @@ class Rectangle {
98904
99069
  return x0 >= _x0 && x1 <= _x1 && y0 >= _y0 && y1 <= _y1;
98905
99070
  }
98906
99071
 
99072
+ /**
99073
+ *
99074
+ * @param {Rectangle} other
99075
+ * @returns {boolean}
99076
+ */
98907
99077
  contains(other) {
98908
99078
  const x0 = other.position.x;
98909
99079
  const y0 = other.position.y;