@woosh/meep-engine 2.115.0 → 2.116.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 (74) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +204 -177
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +204 -177
  5. package/editor/view/ecs/HierarchicalEntityListView.js +2 -2
  6. package/package.json +1 -1
  7. package/src/core/collection/array/{compareArrays.d.ts → array_compare.d.ts} +2 -2
  8. package/src/core/collection/array/array_compare.d.ts.map +1 -0
  9. package/src/core/collection/array/{compareArrays.js → array_compare.js} +5 -1
  10. package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts} +2 -2
  11. package/src/core/collection/array/array_index_by_equality.d.ts.map +1 -0
  12. package/src/core/collection/array/{arrayIndexByEquality.js → array_index_by_equality.js} +1 -1
  13. package/src/core/collection/array/array_pick_best_element.d.ts.map +1 -0
  14. package/src/core/collection/array/{arrayPickBestElement.js → array_pick_best_element.js} +2 -2
  15. package/src/core/collection/array/array_pick_best_elements.d.ts +8 -0
  16. package/src/core/collection/array/array_pick_best_elements.d.ts.map +1 -0
  17. package/src/core/collection/array/{arrayPickBestElements.js → array_pick_best_elements.js} +1 -1
  18. package/src/core/collection/array/array_replace_all.d.ts +2 -1
  19. package/src/core/collection/array/array_replace_all.d.ts.map +1 -1
  20. package/src/core/collection/array/array_replace_all.js +3 -0
  21. package/src/core/collection/array/{arraySetDiff.d.ts → array_set_diff.d.ts} +3 -3
  22. package/src/core/collection/array/array_set_diff.d.ts.map +1 -0
  23. package/src/core/collection/array/{arraySetDiff.js → array_set_diff.js} +4 -4
  24. package/src/core/collection/array/{arraySetSortingDiff.d.ts → array_set_diff_sorting.d.ts} +2 -2
  25. package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -0
  26. package/src/core/collection/array/{arraySetSortingDiff.js → array_set_diff_sorting.js} +1 -1
  27. package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
  28. package/src/core/collection/list/FilteredListProjection.js +2 -2
  29. package/src/core/collection/list/List.d.ts.map +1 -1
  30. package/src/core/collection/list/List.js +8 -11
  31. package/src/core/collection/set/ArraySet.d.ts.map +1 -1
  32. package/src/core/collection/set/ArraySet.js +11 -1
  33. package/src/core/geom/3d/topology/expandConnectivityByLocality.js +2 -2
  34. package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
  35. package/src/core/math/physics/brdf/brdf_burley.js +3 -14
  36. package/src/core/math/physics/bsdf/bsdf_schlick.js +1 -1
  37. package/src/core/math/physics/pdf/pdf_normal.d.ts +8 -0
  38. package/src/core/math/physics/pdf/pdf_normal.d.ts.map +1 -0
  39. package/src/core/math/physics/pdf/pdf_normal.js +11 -0
  40. package/src/core/math/physics/reflectivity_to_ior.d.ts.map +1 -1
  41. package/src/core/math/physics/reflectivity_to_ior.js +3 -1
  42. package/src/core/model/object/compareValues.js +3 -3
  43. package/src/core/primitives/strings/computeStringHash.d.ts +9 -1
  44. package/src/core/primitives/strings/computeStringHash.d.ts.map +1 -1
  45. package/src/core/primitives/strings/computeStringHash.js +10 -5
  46. package/src/engine/ecs/EntityComponentDataset.js +3 -3
  47. package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +2 -2
  48. package/src/engine/graphics/sh3/gi/material/common.glsl +3 -2
  49. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  50. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -3
  51. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  52. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -3
  53. package/src/engine/graphics/sh3/prototypeSH3Probe.js +16 -12
  54. package/src/engine/graphics/shaders/DenoiseShader.d.ts.map +1 -1
  55. package/src/engine/graphics/shaders/DenoiseShader.js +3 -12
  56. package/src/engine/input/ecs/components/InputBinding.d.ts.map +1 -1
  57. package/src/engine/input/ecs/components/InputBinding.js +3 -2
  58. package/src/engine/input/ecs/components/InputController.d.ts.map +1 -1
  59. package/src/engine/input/ecs/components/InputController.js +18 -1
  60. package/src/engine/input/ecs/controllers/KeyboardCameraController.js +9 -9
  61. package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
  62. package/src/engine/platform/WebEnginePlatform.js +4 -4
  63. package/src/engine/save/GameStateLoader.js +2 -2
  64. package/src/engine/ui/cursor/CursorCoalescence.d.ts.map +1 -1
  65. package/src/engine/ui/cursor/CursorCoalescence.js +2 -2
  66. package/src/view/elements/radial/RadialMenu.js +2 -2
  67. package/src/core/collection/array/arrayIndexByEquality.d.ts.map +0 -1
  68. package/src/core/collection/array/arrayPickBestElement.d.ts.map +0 -1
  69. package/src/core/collection/array/arrayPickBestElements.d.ts +0 -8
  70. package/src/core/collection/array/arrayPickBestElements.d.ts.map +0 -1
  71. package/src/core/collection/array/arraySetDiff.d.ts.map +0 -1
  72. package/src/core/collection/array/arraySetSortingDiff.d.ts.map +0 -1
  73. package/src/core/collection/array/compareArrays.d.ts.map +0 -1
  74. /package/src/core/collection/array/{arrayPickBestElement.d.ts → array_pick_best_element.d.ts} +0 -0
@@ -50988,9 +50988,11 @@ class Vector4 {
50988
50988
  /**
50989
50989
  *
50990
50990
  * @param {string|null|undefined} string
50991
+ * @param {number} [start]
50992
+ * @param {number} [length] how many characters to hash, defaults to full string length
50991
50993
  * @returns {number}
50992
50994
  */
50993
- function computeStringHash(string) {
50995
+ function computeStringHash(string, start, length) {
50994
50996
  if (string === null) {
50995
50997
  return 0;
50996
50998
  }
@@ -50999,11 +51001,14 @@ function computeStringHash(string) {
50999
51001
  return 1;
51000
51002
  }
51001
51003
 
51002
- const length = string.length;
51004
+ let _start = start ?? 0;
51005
+ let _length = length ?? string.length - _start;
51003
51006
 
51004
- let hash = length;
51007
+ let hash = _length;
51005
51008
 
51006
- for (let i = 0; i < length; i++) {
51009
+ const end = _start + _length;
51010
+
51011
+ for (let i = _start; i < end; i++) {
51007
51012
  const code_point = string.charCodeAt(i);
51008
51013
 
51009
51014
  /*
@@ -59530,6 +59535,26 @@ const AmbientOcclusionShader = function () {
59530
59535
  }
59531
59536
  };
59532
59537
 
59538
+ /**
59539
+ *
59540
+ * @param {number} sigma distance from mean
59541
+ * @param {number} v Variance
59542
+ * @returns {number}
59543
+ */
59544
+ function gaussian$1(sigma, v) {
59545
+ return Math.exp(-(v * v) / (2 * sigma * sigma));
59546
+ }
59547
+
59548
+ /**
59549
+ * Normal Probability Distribution Function
59550
+ * @param {number} x
59551
+ * @param {number} sigma
59552
+ * @return {number}
59553
+ */
59554
+ function pdf_normal(x, sigma) {
59555
+ return 0.39894 * gaussian$1(sigma, x) / sigma;
59556
+ }
59557
+
59533
59558
  const KERNEL_SIZE = 15;
59534
59559
 
59535
59560
  const fragment$1 = `
@@ -59589,16 +59614,6 @@ void main(void) {
59589
59614
  }
59590
59615
  `;
59591
59616
 
59592
- /**
59593
- * Normal Probability Distribution Function
59594
- * @param {number} x
59595
- * @param {number} sigma
59596
- * @return {number}
59597
- */
59598
- function normpdf(x, sigma) {
59599
- return 0.39894 * Math.exp(-0.5 * x * x / (sigma * sigma)) / sigma;
59600
- }
59601
-
59602
59617
  /**
59603
59618
  *
59604
59619
  * @param {number} sigma
@@ -59607,13 +59622,13 @@ function normpdf(x, sigma) {
59607
59622
  */
59608
59623
  function DenoiseShader(sigma = 10, filterSmoothness = 0.2) {
59609
59624
  // compute zNorm
59610
- const zNorm = 1 / normpdf(0, filterSmoothness);
59625
+ const zNorm = 1 / pdf_normal(0, filterSmoothness);
59611
59626
 
59612
59627
  // build kernel
59613
59628
  const kernel = new Float32Array(KERNEL_SIZE);
59614
59629
  const kSize = Math.floor((KERNEL_SIZE - 1) / 2);
59615
59630
  for (let i = 0; i <= kSize; i++) {
59616
- const v = normpdf(i, sigma);
59631
+ const v = pdf_normal(i, sigma);
59617
59632
 
59618
59633
  kernel[kSize + i] = v;
59619
59634
  kernel[kSize - i] = v;
@@ -61407,7 +61422,7 @@ function objectsEqual(a, b) {
61407
61422
  * @param {function(a:T,b:T):boolean} equals
61408
61423
  * @returns {number} index of first match or -1 if no matches found
61409
61424
  */
61410
- function arrayIndexByEquality(array, element, equals) {
61425
+ function array_index_by_equality(array, element, equals) {
61411
61426
  const n = array.length;
61412
61427
 
61413
61428
  for (let i = 0; i < n; i++) {
@@ -61423,14 +61438,14 @@ function arrayIndexByEquality(array, element, equals) {
61423
61438
 
61424
61439
  /**
61425
61440
  * Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
61426
- * @see prefer to use {@link arraySetSortingDiff}, as it's much faster, especially for large sets
61441
+ * @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
61427
61442
  * @template T
61428
61443
  * @param {T[]} a
61429
61444
  * @param {T[]} b
61430
61445
  * @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
61431
61446
  * @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
61432
61447
  */
61433
- function arraySetDiff(a, b, equals = strictEquals) {
61448
+ function array_set_diff(a, b, equals = strictEquals) {
61434
61449
 
61435
61450
  const uniqueA = a.slice();
61436
61451
  const uniqueB = b.slice();
@@ -61442,7 +61457,7 @@ function arraySetDiff(a, b, equals = strictEquals) {
61442
61457
  for (let i = 0; i < a_length; i++) {
61443
61458
  const elA = uniqueA[i];
61444
61459
 
61445
- const j = arrayIndexByEquality(uniqueB, elA, equals);
61460
+ const j = array_index_by_equality(uniqueB, elA, equals);
61446
61461
 
61447
61462
  if (j !== -1) {
61448
61463
  // common element found
@@ -61501,8 +61516,7 @@ class List {
61501
61516
  data = []
61502
61517
 
61503
61518
  /**
61504
- * @param {[]} [array]
61505
- * @constructor
61519
+ * @param {T[]} [array]
61506
61520
  */
61507
61521
  constructor(array) {
61508
61522
 
@@ -61667,7 +61681,7 @@ class List {
61667
61681
 
61668
61682
  const data = this.data;
61669
61683
 
61670
- const diff = arraySetDiff(data, new_data, objectsEqual);
61684
+ const diff = array_set_diff(data, new_data, objectsEqual);
61671
61685
 
61672
61686
  //resolve diff
61673
61687
  const removals = diff.uniqueA;
@@ -61744,12 +61758,10 @@ class List {
61744
61758
  * @param {Array.<T>} elements
61745
61759
  */
61746
61760
  addAllUnique(elements) {
61747
- const data = this.data;
61748
-
61749
- const length = data.length;
61761
+ const length = elements.length;
61750
61762
 
61751
61763
  for (let i = 0; i < length; i++) {
61752
- this.addUnique(data[i]);
61764
+ this.addUnique(elements[i]);
61753
61765
  }
61754
61766
  }
61755
61767
 
@@ -61859,7 +61871,7 @@ class List {
61859
61871
  /**
61860
61872
  *
61861
61873
  * @param {function(a:T, b:T):number} [compare_function]
61862
- * @returns {List}
61874
+ * @returns {this}
61863
61875
  */
61864
61876
  sort(compare_function) {
61865
61877
  Array.prototype.sort.call(this.data, compare_function);
@@ -62186,7 +62198,7 @@ class List {
62186
62198
  for (let i = 0; i < nThisItems; i++) {
62187
62199
  const a = thisItems[i];
62188
62200
 
62189
- const index = arrayIndexByEquality(otherItems, a, invokeObjectEquals);
62201
+ const index = array_index_by_equality(otherItems, a, invokeObjectEquals);
62190
62202
 
62191
62203
  if (index !== -1) {
62192
62204
  newData[index] = a;
@@ -94307,7 +94319,7 @@ class EntityComponentDataset {
94307
94319
 
94308
94320
  const newComponentTypeCount = map.length;
94309
94321
 
94310
- const diff = arraySetDiff(map, this.componentTypeMap);
94322
+ const diff = array_set_diff(map, this.componentTypeMap);
94311
94323
 
94312
94324
  const typesToAdd = diff.uniqueA;
94313
94325
  const typesToRemove = diff.uniqueB;
@@ -94525,7 +94537,7 @@ class EntityComponentDataset {
94525
94537
  * @returns {boolean} false if no new classes were added, true if at least one new class was added
94526
94538
  */
94527
94539
  registerManyComponentTypes(types) {
94528
- const diff = arraySetDiff(types, this.componentTypeMap);
94540
+ const diff = array_set_diff(types, this.componentTypeMap);
94529
94541
 
94530
94542
  if (diff.uniqueA.length === 0) {
94531
94543
  // all classes area already registered
@@ -105503,7 +105515,7 @@ class InputBinding {
105503
105515
  class InputController {
105504
105516
  /**
105505
105517
  *
105506
- * @param {Array} bindings
105518
+ * @param {Array} [bindings]
105507
105519
  * @constructor
105508
105520
  */
105509
105521
  constructor(bindings = []) {
@@ -105519,6 +105531,21 @@ class InputController {
105519
105531
  };
105520
105532
  }
105521
105533
 
105534
+ /**
105535
+ *
105536
+ * @param {string} path
105537
+ * @param {function} action
105538
+ * @returns {InputBinding}
105539
+ */
105540
+ bind(path, action) {
105541
+
105542
+ const binding = new InputBinding({ path, listener: action });
105543
+
105544
+ this.mapping.add(binding);
105545
+
105546
+ return binding;
105547
+ }
105548
+
105522
105549
  /**
105523
105550
  *
105524
105551
  * @param {Array} bindings
@@ -114992,19 +115019,19 @@ class KeyboardCameraController {
114992
115019
  function registerToggle(keys, object, propertyName) {
114993
115020
  keys.forEach((keyName) => {
114994
115021
 
114995
- inputController.mapping.add({
114996
- path: "keyboard/keys/" + keyName + "/down",
114997
- listener: () => {
115022
+ inputController.bind(
115023
+ "keyboard/keys/" + keyName + "/down",
115024
+ () => {
114998
115025
  object[propertyName] = true;
114999
115026
 
115000
115027
  //send interaction event
115001
115028
  ecd.sendEvent(cameraController.entity, 'user-input');
115002
115029
  }
115003
- });
115004
- inputController.mapping.add({
115005
- path: "keyboard/keys/" + keyName + "/up",
115006
- listener: () => object[propertyName] = false
115007
- });
115030
+ );
115031
+ inputController.bind(
115032
+ "keyboard/keys/" + keyName + "/up",
115033
+ () => object[propertyName] = false
115034
+ );
115008
115035
  });
115009
115036
  }
115010
115037
 
@@ -115036,7 +115063,7 @@ class KeyboardCameraController {
115036
115063
  return;
115037
115064
  }
115038
115065
 
115039
- let displacement = cameraPanSpeed.clone().multiplyScalar(keyboardPanSpeed * timeDelta);
115066
+ const displacement = cameraPanSpeed.clone().multiplyScalar(keyboardPanSpeed * timeDelta);
115040
115067
 
115041
115068
  const camera_transform = ecd.getComponent(cameraController.entity, Transform);
115042
115069
 
@@ -115487,43 +115514,138 @@ function getURLHash() {
115487
115514
  return result;
115488
115515
  }
115489
115516
 
115490
- class EnginePlatform {
115491
- /**
115492
- * @returns {Storage}
115493
- */
115494
- getStorage() {
115495
- throw new Error('Not implemented');
115517
+ /**
115518
+ * Picks element with highest score from the array using supplied scoring function.
115519
+ * If multiple elements with the same highest score exist, the result will be first such encountered element
115520
+ * @template T
115521
+ * @param {T[]} array
115522
+ * @param {function(el:T, index:number):number} scoreFunction
115523
+ * @returns {T|undefined}
115524
+ */
115525
+ function array_pick_best_element(array, scoreFunction) {
115526
+
115527
+ let bestElement;
115528
+ let bestScore;
115529
+
115530
+ const size = array.length;
115531
+
115532
+ if (size === 0) {
115533
+ return undefined;
115496
115534
  }
115497
115535
 
115498
- /**
115499
- * @returns {AchievementGateway}
115500
- */
115501
- getAchievementGateway() {
115502
- throw new Error('Not implemented');
115536
+ bestElement = array[0];
115537
+
115538
+ bestScore = scoreFunction(bestElement, 0);
115539
+
115540
+ for (let i = 1; i < size; i++) {
115541
+ const el = array[i];
115542
+
115543
+ // compute score
115544
+ const score = scoreFunction(el, i);
115545
+
115546
+ if (score > bestScore) {
115547
+ bestScore = score;
115548
+ bestElement = el;
115549
+ }
115550
+ }
115551
+
115552
+ return bestElement;
115553
+ }
115554
+
115555
+ /**
115556
+ * Base class for implementing achievement system API connectors
115557
+ */
115558
+ class AchievementGateway {
115559
+ constructor() {
115560
+
115503
115561
  }
115504
115562
 
115505
115563
  /**
115506
- * @param {string[]} options
115507
- * @returns {string}
115564
+ * Retrieve list of unlocked achievements
115565
+ * @returns {Promise<String[]>} IDs of unlocked achievements
115508
115566
  */
115509
- pickDefaultLocale(options) {
115567
+ getUnlocked() {
115568
+ //needs to be overridden in subclass
115510
115569
  throw new Error('Not implemented');
115511
115570
  }
115512
115571
 
115513
115572
  /**
115573
+ * Unlock an achievements by ID
115574
+ * @param {String} id
115514
115575
  * @returns {Promise}
115515
115576
  */
115516
- startup() {
115517
- return Promise.resolve();
115577
+ unlock(id) {
115578
+ //needs to be overridden in subclass
115579
+ throw new Error('Not implemented');
115518
115580
  }
115519
-
115581
+ }
115582
+
115583
+ class StorageAchievementGateway extends AchievementGateway {
115520
115584
  /**
115521
- * @returns {Promise}
115585
+ *
115586
+ * @param {Storage} storage
115587
+ * @param {String} [key]
115522
115588
  */
115523
- shutdown() {
115524
- return Promise.resolve();
115589
+ constructor(storage, key = "achievements") {
115590
+ super();
115591
+
115592
+ this.storage = storage;
115593
+
115594
+ this.key = key;
115595
+
115596
+ this.last = Promise.resolve();
115525
115597
  }
115526
115598
 
115599
+ getUnlocked() {
115600
+ return new Promise((resolve, reject) => {
115601
+ this.storage.load(this.key, (list) => {
115602
+
115603
+ if (list === undefined) {
115604
+ resolve([]);
115605
+ } else {
115606
+ resolve(list);
115607
+ }
115608
+
115609
+ }, reject, noop);
115610
+ });
115611
+ }
115612
+
115613
+ unlock(id) {
115614
+ const storage = this.storage;
115615
+
115616
+ const promise = this.last.finally(() => {
115617
+ return new Promise((resolve, reject) => {
115618
+ //read list of unlocked achievements
115619
+ storage.load(this.key, list => {
115620
+
115621
+ let unlocked;
115622
+ if (list !== undefined) {
115623
+ if (list.includes(id)) {
115624
+ //achievement is already unlocked
115625
+ resolve();
115626
+ return;
115627
+ }
115628
+
115629
+ unlocked = list.slice();
115630
+
115631
+ } else {
115632
+ unlocked = [];
115633
+ }
115634
+
115635
+ //modify unlocked achievements
115636
+ unlocked.push(id);
115637
+
115638
+ //write back
115639
+ storage.store(this.key, unlocked, resolve, reject, noop);
115640
+ }, reject, noop);
115641
+ });
115642
+ }
115643
+ );
115644
+
115645
+ this.last = promise;
115646
+
115647
+ return promise;
115648
+ }
115527
115649
  }
115528
115650
 
115529
115651
  class Storage {
@@ -115797,138 +115919,43 @@ class IndexedDBStorage extends Storage {
115797
115919
  }
115798
115920
  }
115799
115921
 
115800
- /**
115801
- * Base class for implementing achievement system API connectors
115802
- */
115803
- class AchievementGateway {
115804
- constructor() {
115805
-
115806
- }
115807
-
115922
+ class EnginePlatform {
115808
115923
  /**
115809
- * Retrieve list of unlocked achievements
115810
- * @returns {Promise<String[]>} IDs of unlocked achievements
115924
+ * @returns {Storage}
115811
115925
  */
115812
- getUnlocked() {
115813
- //needs to be overridden in subclass
115926
+ getStorage() {
115814
115927
  throw new Error('Not implemented');
115815
115928
  }
115816
115929
 
115817
115930
  /**
115818
- * Unlock an achievements by ID
115819
- * @param {String} id
115820
- * @returns {Promise}
115931
+ * @returns {AchievementGateway}
115821
115932
  */
115822
- unlock(id) {
115823
- //needs to be overridden in subclass
115933
+ getAchievementGateway() {
115824
115934
  throw new Error('Not implemented');
115825
115935
  }
115826
- }
115827
-
115828
- class StorageAchievementGateway extends AchievementGateway {
115936
+
115829
115937
  /**
115830
- *
115831
- * @param {Storage} storage
115832
- * @param {String} [key]
115938
+ * @param {string[]} options
115939
+ * @returns {string}
115833
115940
  */
115834
- constructor(storage, key = "achievements") {
115835
- super();
115836
-
115837
- this.storage = storage;
115838
-
115839
- this.key = key;
115840
-
115841
- this.last = Promise.resolve();
115842
- }
115843
-
115844
- getUnlocked() {
115845
- return new Promise((resolve, reject) => {
115846
- this.storage.load(this.key, (list) => {
115847
-
115848
- if (list === undefined) {
115849
- resolve([]);
115850
- } else {
115851
- resolve(list);
115852
- }
115853
-
115854
- }, reject, noop);
115855
- });
115856
- }
115857
-
115858
- unlock(id) {
115859
- const storage = this.storage;
115860
-
115861
- const promise = this.last.finally(() => {
115862
- return new Promise((resolve, reject) => {
115863
- //read list of unlocked achievements
115864
- storage.load(this.key, list => {
115865
-
115866
- let unlocked;
115867
- if (list !== undefined) {
115868
- if (list.includes(id)) {
115869
- //achievement is already unlocked
115870
- resolve();
115871
- return;
115872
- }
115873
-
115874
- unlocked = list.slice();
115875
-
115876
- } else {
115877
- unlocked = [];
115878
- }
115879
-
115880
- //modify unlocked achievements
115881
- unlocked.push(id);
115882
-
115883
- //write back
115884
- storage.store(this.key, unlocked, resolve, reject, noop);
115885
- }, reject, noop);
115886
- });
115887
- }
115888
- );
115889
-
115890
- this.last = promise;
115891
-
115892
- return promise;
115941
+ pickDefaultLocale(options) {
115942
+ throw new Error('Not implemented');
115893
115943
  }
115894
- }
115895
-
115896
- /**
115897
- * Picks element with highest score from the array using supplied scoring function.
115898
- * If multiple elements with the same highest score exist, the result will be first such encountered element
115899
- * @template T
115900
- * @param {T[]} array
115901
- * @param {function(el:T, index:number):number} scoreFunction
115902
- * @returns {T|undefined}
115903
- */
115904
- function arrayPickBestElement(array, scoreFunction) {
115905
-
115906
- let bestElement;
115907
- let bestScore;
115908
115944
 
115909
- const size = array.length;
115910
-
115911
- if (size === 0) {
115912
- return undefined;
115945
+ /**
115946
+ * @returns {Promise}
115947
+ */
115948
+ startup() {
115949
+ return Promise.resolve();
115913
115950
  }
115914
115951
 
115915
- bestElement = array[0];
115916
-
115917
- bestScore = scoreFunction(bestElement, 0);
115918
-
115919
- for (let i = 1; i < size; i++) {
115920
- const el = array[i];
115921
-
115922
- // compute score
115923
- const score = scoreFunction(el, i);
115924
-
115925
- if (score > bestScore) {
115926
- bestScore = score;
115927
- bestElement = el;
115928
- }
115952
+ /**
115953
+ * @returns {Promise}
115954
+ */
115955
+ shutdown() {
115956
+ return Promise.resolve();
115929
115957
  }
115930
115958
 
115931
- return bestElement;
115932
115959
  }
115933
115960
 
115934
115961
  class WebEnginePlatform extends EnginePlatform {
@@ -116003,7 +116030,7 @@ class WebEnginePlatform extends EnginePlatform {
116003
116030
  };
116004
116031
  });
116005
116032
 
116006
- const best = arrayPickBestElement(scoredKeys, o => o.score);
116033
+ const best = array_pick_best_element(scoredKeys, o => o.score);
116007
116034
 
116008
116035
  if (best.score === 0) {
116009
116036
  return 'en-gb';
@@ -1,4 +1,4 @@
1
- import { arraySetSortingDiff } from "../../../src/core/collection/array/arraySetSortingDiff.js";
1
+ import { array_set_diff_sorting } from "../../../src/core/collection/array/array_set_diff_sorting.js";
2
2
  import List from "../../../src/core/collection/list/List.js";
3
3
  import Signal from "../../../src/core/events/signal/Signal.js";
4
4
  import { number_compare_ascending } from "../../../src/core/primitives/numbers/number_compare_ascending.js";
@@ -50,7 +50,7 @@ export class HierarchicalEntityListView extends EmptyView {
50
50
  });
51
51
 
52
52
  // perform patch
53
- const diff = arraySetSortingDiff(new_roots, this.#roots.asArray(), number_compare_ascending);
53
+ const diff = array_set_diff_sorting(new_roots, this.#roots.asArray(), number_compare_ascending);
54
54
 
55
55
  for (let i = 0; i < diff.uniqueB.length; i++) {
56
56
  const removal_id = diff.uniqueB[i];
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.115.0",
8
+ "version": "2.116.1",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -5,5 +5,5 @@
5
5
  * @param {function(T,T):number} comparator
6
6
  * @return {number}
7
7
  */
8
- export function compareArrays<T>(as: T[], bs: T[], comparator: (arg0: T, arg1: T) => number): number;
9
- //# sourceMappingURL=compareArrays.d.ts.map
8
+ export function array_compare<T>(as: T[], bs: T[], comparator: (arg0: T, arg1: T) => number): number;
9
+ //# sourceMappingURL=array_compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_compare.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compare.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qFAHyB,MAAM,GACnB,MAAM,CA0BjB"}
@@ -1,3 +1,5 @@
1
+ import { assert } from "../../assert.js";
2
+
1
3
  /**
2
4
  * @template T
3
5
  * @param {T[]} as
@@ -5,7 +7,9 @@
5
7
  * @param {function(T,T):number} comparator
6
8
  * @return {number}
7
9
  */
8
- export function compareArrays(as, bs, comparator) {
10
+ export function array_compare(as, bs, comparator) {
11
+ assert.isFunction(comparator,'comparator');
12
+
9
13
  const n = as.length;
10
14
  const m = bs.length;
11
15
 
@@ -6,5 +6,5 @@
6
6
  * @param {function(a:T,b:T):boolean} equals
7
7
  * @returns {number} index of first match or -1 if no matches found
8
8
  */
9
- export function arrayIndexByEquality<T>(array: T[], element: T, equals: any): number;
10
- //# sourceMappingURL=arrayIndexByEquality.d.ts.map
9
+ export function array_index_by_equality<T>(array: T[], element: T, equals: any): number;
10
+ //# sourceMappingURL=array_index_by_equality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_index_by_equality.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_index_by_equality.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iFAFa,MAAM,CAclB"}
@@ -6,7 +6,7 @@
6
6
  * @param {function(a:T,b:T):boolean} equals
7
7
  * @returns {number} index of first match or -1 if no matches found
8
8
  */
9
- export function arrayIndexByEquality(array, element, equals) {
9
+ export function array_index_by_equality(array, element, equals) {
10
10
  const n = array.length;
11
11
 
12
12
  for (let i = 0; i < n; i++) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_pick_best_element.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_pick_best_element.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,8EAkCC"}
@@ -8,9 +8,9 @@ import { assert } from "../../assert.js";
8
8
  * @param {function(el:T, index:number):number} scoreFunction
9
9
  * @returns {T|undefined}
10
10
  */
11
- export function arrayPickBestElement(array, scoreFunction) {
11
+ export function array_pick_best_element(array, scoreFunction) {
12
12
  assert.notEqual(array, undefined, 'array is undefined');
13
- assert.typeOf(scoreFunction, 'function', 'scoreFunction');
13
+ assert.isFunction(scoreFunction, 'scoreFunction');
14
14
 
15
15
  let bestElement;
16
16
  let bestScore;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @template T
3
+ * @param {T[]} array
4
+ * @param {function(el:T, index:number):number} scoreFunction
5
+ * @returns {T[]}
6
+ */
7
+ export function array_pick_best_elements<T>(array: T[], scoreFunction: any): T[];
8
+ //# sourceMappingURL=array_pick_best_elements.d.ts.map