@woosh/meep-engine 2.115.0 → 2.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/meep.cjs +144 -144
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +144 -144
- package/editor/view/ecs/HierarchicalEntityListView.js +2 -2
- package/package.json +1 -1
- package/src/core/collection/array/{compareArrays.d.ts → array_compare.d.ts} +2 -2
- package/src/core/collection/array/array_compare.d.ts.map +1 -0
- package/src/core/collection/array/{compareArrays.js → array_compare.js} +5 -1
- package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts} +2 -2
- package/src/core/collection/array/array_index_by_equality.d.ts.map +1 -0
- package/src/core/collection/array/{arrayIndexByEquality.js → array_index_by_equality.js} +1 -1
- package/src/core/collection/array/array_pick_best_element.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElement.js → array_pick_best_element.js} +2 -2
- package/src/core/collection/array/array_pick_best_elements.d.ts +8 -0
- package/src/core/collection/array/array_pick_best_elements.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElements.js → array_pick_best_elements.js} +1 -1
- package/src/core/collection/array/{arraySetDiff.d.ts → array_set_diff.d.ts} +3 -3
- package/src/core/collection/array/array_set_diff.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetDiff.js → array_set_diff.js} +4 -4
- package/src/core/collection/array/{arraySetSortingDiff.d.ts → array_set_diff_sorting.d.ts} +2 -2
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetSortingDiff.js → array_set_diff_sorting.js} +1 -1
- package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
- package/src/core/collection/list/FilteredListProjection.js +2 -2
- package/src/core/collection/list/List.js +4 -4
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +2 -2
- package/src/core/model/object/compareValues.js +3 -3
- package/src/engine/ecs/EntityComponentDataset.js +3 -3
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +2 -2
- package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
- package/src/engine/platform/WebEnginePlatform.js +4 -4
- package/src/engine/save/GameStateLoader.js +2 -2
- package/src/engine/ui/cursor/CursorCoalescence.d.ts.map +1 -1
- package/src/engine/ui/cursor/CursorCoalescence.js +2 -2
- package/src/view/elements/radial/RadialMenu.js +2 -2
- package/src/core/collection/array/arrayIndexByEquality.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElements.d.ts +0 -8
- package/src/core/collection/array/arrayPickBestElements.d.ts.map +0 -1
- package/src/core/collection/array/arraySetDiff.d.ts.map +0 -1
- package/src/core/collection/array/arraySetSortingDiff.d.ts.map +0 -1
- package/src/core/collection/array/compareArrays.d.ts.map +0 -1
- /package/src/core/collection/array/{arrayPickBestElement.d.ts → array_pick_best_element.d.ts} +0 -0
package/build/meep.cjs
CHANGED
|
@@ -61409,7 +61409,7 @@ function objectsEqual(a, b) {
|
|
|
61409
61409
|
* @param {function(a:T,b:T):boolean} equals
|
|
61410
61410
|
* @returns {number} index of first match or -1 if no matches found
|
|
61411
61411
|
*/
|
|
61412
|
-
function
|
|
61412
|
+
function array_index_by_equality(array, element, equals) {
|
|
61413
61413
|
const n = array.length;
|
|
61414
61414
|
|
|
61415
61415
|
for (let i = 0; i < n; i++) {
|
|
@@ -61425,14 +61425,14 @@ function arrayIndexByEquality(array, element, equals) {
|
|
|
61425
61425
|
|
|
61426
61426
|
/**
|
|
61427
61427
|
* 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
|
|
61428
|
-
* @see prefer to use {@link
|
|
61428
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
61429
61429
|
* @template T
|
|
61430
61430
|
* @param {T[]} a
|
|
61431
61431
|
* @param {T[]} b
|
|
61432
61432
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
61433
61433
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
61434
61434
|
*/
|
|
61435
|
-
function
|
|
61435
|
+
function array_set_diff(a, b, equals = strictEquals) {
|
|
61436
61436
|
|
|
61437
61437
|
const uniqueA = a.slice();
|
|
61438
61438
|
const uniqueB = b.slice();
|
|
@@ -61444,7 +61444,7 @@ function arraySetDiff(a, b, equals = strictEquals) {
|
|
|
61444
61444
|
for (let i = 0; i < a_length; i++) {
|
|
61445
61445
|
const elA = uniqueA[i];
|
|
61446
61446
|
|
|
61447
|
-
const j =
|
|
61447
|
+
const j = array_index_by_equality(uniqueB, elA, equals);
|
|
61448
61448
|
|
|
61449
61449
|
if (j !== -1) {
|
|
61450
61450
|
// common element found
|
|
@@ -61669,7 +61669,7 @@ class List {
|
|
|
61669
61669
|
|
|
61670
61670
|
const data = this.data;
|
|
61671
61671
|
|
|
61672
|
-
const diff =
|
|
61672
|
+
const diff = array_set_diff(data, new_data, objectsEqual);
|
|
61673
61673
|
|
|
61674
61674
|
//resolve diff
|
|
61675
61675
|
const removals = diff.uniqueA;
|
|
@@ -62188,7 +62188,7 @@ class List {
|
|
|
62188
62188
|
for (let i = 0; i < nThisItems; i++) {
|
|
62189
62189
|
const a = thisItems[i];
|
|
62190
62190
|
|
|
62191
|
-
const index =
|
|
62191
|
+
const index = array_index_by_equality(otherItems, a, invokeObjectEquals);
|
|
62192
62192
|
|
|
62193
62193
|
if (index !== -1) {
|
|
62194
62194
|
newData[index] = a;
|
|
@@ -94309,7 +94309,7 @@ class EntityComponentDataset {
|
|
|
94309
94309
|
|
|
94310
94310
|
const newComponentTypeCount = map.length;
|
|
94311
94311
|
|
|
94312
|
-
const diff =
|
|
94312
|
+
const diff = array_set_diff(map, this.componentTypeMap);
|
|
94313
94313
|
|
|
94314
94314
|
const typesToAdd = diff.uniqueA;
|
|
94315
94315
|
const typesToRemove = diff.uniqueB;
|
|
@@ -94527,7 +94527,7 @@ class EntityComponentDataset {
|
|
|
94527
94527
|
* @returns {boolean} false if no new classes were added, true if at least one new class was added
|
|
94528
94528
|
*/
|
|
94529
94529
|
registerManyComponentTypes(types) {
|
|
94530
|
-
const diff =
|
|
94530
|
+
const diff = array_set_diff(types, this.componentTypeMap);
|
|
94531
94531
|
|
|
94532
94532
|
if (diff.uniqueA.length === 0) {
|
|
94533
94533
|
// all classes area already registered
|
|
@@ -115489,43 +115489,138 @@ function getURLHash() {
|
|
|
115489
115489
|
return result;
|
|
115490
115490
|
}
|
|
115491
115491
|
|
|
115492
|
-
|
|
115493
|
-
|
|
115494
|
-
|
|
115495
|
-
|
|
115496
|
-
|
|
115497
|
-
|
|
115492
|
+
/**
|
|
115493
|
+
* Picks element with highest score from the array using supplied scoring function.
|
|
115494
|
+
* If multiple elements with the same highest score exist, the result will be first such encountered element
|
|
115495
|
+
* @template T
|
|
115496
|
+
* @param {T[]} array
|
|
115497
|
+
* @param {function(el:T, index:number):number} scoreFunction
|
|
115498
|
+
* @returns {T|undefined}
|
|
115499
|
+
*/
|
|
115500
|
+
function array_pick_best_element(array, scoreFunction) {
|
|
115501
|
+
|
|
115502
|
+
let bestElement;
|
|
115503
|
+
let bestScore;
|
|
115504
|
+
|
|
115505
|
+
const size = array.length;
|
|
115506
|
+
|
|
115507
|
+
if (size === 0) {
|
|
115508
|
+
return undefined;
|
|
115498
115509
|
}
|
|
115499
115510
|
|
|
115500
|
-
|
|
115501
|
-
|
|
115502
|
-
|
|
115503
|
-
|
|
115504
|
-
|
|
115511
|
+
bestElement = array[0];
|
|
115512
|
+
|
|
115513
|
+
bestScore = scoreFunction(bestElement, 0);
|
|
115514
|
+
|
|
115515
|
+
for (let i = 1; i < size; i++) {
|
|
115516
|
+
const el = array[i];
|
|
115517
|
+
|
|
115518
|
+
// compute score
|
|
115519
|
+
const score = scoreFunction(el, i);
|
|
115520
|
+
|
|
115521
|
+
if (score > bestScore) {
|
|
115522
|
+
bestScore = score;
|
|
115523
|
+
bestElement = el;
|
|
115524
|
+
}
|
|
115525
|
+
}
|
|
115526
|
+
|
|
115527
|
+
return bestElement;
|
|
115528
|
+
}
|
|
115529
|
+
|
|
115530
|
+
/**
|
|
115531
|
+
* Base class for implementing achievement system API connectors
|
|
115532
|
+
*/
|
|
115533
|
+
class AchievementGateway {
|
|
115534
|
+
constructor() {
|
|
115535
|
+
|
|
115505
115536
|
}
|
|
115506
115537
|
|
|
115507
115538
|
/**
|
|
115508
|
-
*
|
|
115509
|
-
* @returns {
|
|
115539
|
+
* Retrieve list of unlocked achievements
|
|
115540
|
+
* @returns {Promise<String[]>} IDs of unlocked achievements
|
|
115510
115541
|
*/
|
|
115511
|
-
|
|
115542
|
+
getUnlocked() {
|
|
115543
|
+
//needs to be overridden in subclass
|
|
115512
115544
|
throw new Error('Not implemented');
|
|
115513
115545
|
}
|
|
115514
115546
|
|
|
115515
115547
|
/**
|
|
115548
|
+
* Unlock an achievements by ID
|
|
115549
|
+
* @param {String} id
|
|
115516
115550
|
* @returns {Promise}
|
|
115517
115551
|
*/
|
|
115518
|
-
|
|
115519
|
-
|
|
115552
|
+
unlock(id) {
|
|
115553
|
+
//needs to be overridden in subclass
|
|
115554
|
+
throw new Error('Not implemented');
|
|
115520
115555
|
}
|
|
115521
|
-
|
|
115556
|
+
}
|
|
115557
|
+
|
|
115558
|
+
class StorageAchievementGateway extends AchievementGateway {
|
|
115522
115559
|
/**
|
|
115523
|
-
*
|
|
115560
|
+
*
|
|
115561
|
+
* @param {Storage} storage
|
|
115562
|
+
* @param {String} [key]
|
|
115524
115563
|
*/
|
|
115525
|
-
|
|
115526
|
-
|
|
115564
|
+
constructor(storage, key = "achievements") {
|
|
115565
|
+
super();
|
|
115566
|
+
|
|
115567
|
+
this.storage = storage;
|
|
115568
|
+
|
|
115569
|
+
this.key = key;
|
|
115570
|
+
|
|
115571
|
+
this.last = Promise.resolve();
|
|
115527
115572
|
}
|
|
115528
115573
|
|
|
115574
|
+
getUnlocked() {
|
|
115575
|
+
return new Promise((resolve, reject) => {
|
|
115576
|
+
this.storage.load(this.key, (list) => {
|
|
115577
|
+
|
|
115578
|
+
if (list === undefined) {
|
|
115579
|
+
resolve([]);
|
|
115580
|
+
} else {
|
|
115581
|
+
resolve(list);
|
|
115582
|
+
}
|
|
115583
|
+
|
|
115584
|
+
}, reject, noop);
|
|
115585
|
+
});
|
|
115586
|
+
}
|
|
115587
|
+
|
|
115588
|
+
unlock(id) {
|
|
115589
|
+
const storage = this.storage;
|
|
115590
|
+
|
|
115591
|
+
const promise = this.last.finally(() => {
|
|
115592
|
+
return new Promise((resolve, reject) => {
|
|
115593
|
+
//read list of unlocked achievements
|
|
115594
|
+
storage.load(this.key, list => {
|
|
115595
|
+
|
|
115596
|
+
let unlocked;
|
|
115597
|
+
if (list !== undefined) {
|
|
115598
|
+
if (list.includes(id)) {
|
|
115599
|
+
//achievement is already unlocked
|
|
115600
|
+
resolve();
|
|
115601
|
+
return;
|
|
115602
|
+
}
|
|
115603
|
+
|
|
115604
|
+
unlocked = list.slice();
|
|
115605
|
+
|
|
115606
|
+
} else {
|
|
115607
|
+
unlocked = [];
|
|
115608
|
+
}
|
|
115609
|
+
|
|
115610
|
+
//modify unlocked achievements
|
|
115611
|
+
unlocked.push(id);
|
|
115612
|
+
|
|
115613
|
+
//write back
|
|
115614
|
+
storage.store(this.key, unlocked, resolve, reject, noop);
|
|
115615
|
+
}, reject, noop);
|
|
115616
|
+
});
|
|
115617
|
+
}
|
|
115618
|
+
);
|
|
115619
|
+
|
|
115620
|
+
this.last = promise;
|
|
115621
|
+
|
|
115622
|
+
return promise;
|
|
115623
|
+
}
|
|
115529
115624
|
}
|
|
115530
115625
|
|
|
115531
115626
|
class Storage {
|
|
@@ -115799,138 +115894,43 @@ class IndexedDBStorage extends Storage {
|
|
|
115799
115894
|
}
|
|
115800
115895
|
}
|
|
115801
115896
|
|
|
115802
|
-
|
|
115803
|
-
* Base class for implementing achievement system API connectors
|
|
115804
|
-
*/
|
|
115805
|
-
class AchievementGateway {
|
|
115806
|
-
constructor() {
|
|
115807
|
-
|
|
115808
|
-
}
|
|
115809
|
-
|
|
115897
|
+
class EnginePlatform {
|
|
115810
115898
|
/**
|
|
115811
|
-
*
|
|
115812
|
-
* @returns {Promise<String[]>} IDs of unlocked achievements
|
|
115899
|
+
* @returns {Storage}
|
|
115813
115900
|
*/
|
|
115814
|
-
|
|
115815
|
-
//needs to be overridden in subclass
|
|
115901
|
+
getStorage() {
|
|
115816
115902
|
throw new Error('Not implemented');
|
|
115817
115903
|
}
|
|
115818
115904
|
|
|
115819
115905
|
/**
|
|
115820
|
-
*
|
|
115821
|
-
* @param {String} id
|
|
115822
|
-
* @returns {Promise}
|
|
115906
|
+
* @returns {AchievementGateway}
|
|
115823
115907
|
*/
|
|
115824
|
-
|
|
115825
|
-
//needs to be overridden in subclass
|
|
115908
|
+
getAchievementGateway() {
|
|
115826
115909
|
throw new Error('Not implemented');
|
|
115827
115910
|
}
|
|
115828
|
-
|
|
115829
|
-
|
|
115830
|
-
class StorageAchievementGateway extends AchievementGateway {
|
|
115911
|
+
|
|
115831
115912
|
/**
|
|
115832
|
-
*
|
|
115833
|
-
* @
|
|
115834
|
-
* @param {String} [key]
|
|
115913
|
+
* @param {string[]} options
|
|
115914
|
+
* @returns {string}
|
|
115835
115915
|
*/
|
|
115836
|
-
|
|
115837
|
-
|
|
115838
|
-
|
|
115839
|
-
this.storage = storage;
|
|
115840
|
-
|
|
115841
|
-
this.key = key;
|
|
115842
|
-
|
|
115843
|
-
this.last = Promise.resolve();
|
|
115844
|
-
}
|
|
115845
|
-
|
|
115846
|
-
getUnlocked() {
|
|
115847
|
-
return new Promise((resolve, reject) => {
|
|
115848
|
-
this.storage.load(this.key, (list) => {
|
|
115849
|
-
|
|
115850
|
-
if (list === undefined) {
|
|
115851
|
-
resolve([]);
|
|
115852
|
-
} else {
|
|
115853
|
-
resolve(list);
|
|
115854
|
-
}
|
|
115855
|
-
|
|
115856
|
-
}, reject, noop);
|
|
115857
|
-
});
|
|
115858
|
-
}
|
|
115859
|
-
|
|
115860
|
-
unlock(id) {
|
|
115861
|
-
const storage = this.storage;
|
|
115862
|
-
|
|
115863
|
-
const promise = this.last.finally(() => {
|
|
115864
|
-
return new Promise((resolve, reject) => {
|
|
115865
|
-
//read list of unlocked achievements
|
|
115866
|
-
storage.load(this.key, list => {
|
|
115867
|
-
|
|
115868
|
-
let unlocked;
|
|
115869
|
-
if (list !== undefined) {
|
|
115870
|
-
if (list.includes(id)) {
|
|
115871
|
-
//achievement is already unlocked
|
|
115872
|
-
resolve();
|
|
115873
|
-
return;
|
|
115874
|
-
}
|
|
115875
|
-
|
|
115876
|
-
unlocked = list.slice();
|
|
115877
|
-
|
|
115878
|
-
} else {
|
|
115879
|
-
unlocked = [];
|
|
115880
|
-
}
|
|
115881
|
-
|
|
115882
|
-
//modify unlocked achievements
|
|
115883
|
-
unlocked.push(id);
|
|
115884
|
-
|
|
115885
|
-
//write back
|
|
115886
|
-
storage.store(this.key, unlocked, resolve, reject, noop);
|
|
115887
|
-
}, reject, noop);
|
|
115888
|
-
});
|
|
115889
|
-
}
|
|
115890
|
-
);
|
|
115891
|
-
|
|
115892
|
-
this.last = promise;
|
|
115893
|
-
|
|
115894
|
-
return promise;
|
|
115916
|
+
pickDefaultLocale(options) {
|
|
115917
|
+
throw new Error('Not implemented');
|
|
115895
115918
|
}
|
|
115896
|
-
}
|
|
115897
|
-
|
|
115898
|
-
/**
|
|
115899
|
-
* Picks element with highest score from the array using supplied scoring function.
|
|
115900
|
-
* If multiple elements with the same highest score exist, the result will be first such encountered element
|
|
115901
|
-
* @template T
|
|
115902
|
-
* @param {T[]} array
|
|
115903
|
-
* @param {function(el:T, index:number):number} scoreFunction
|
|
115904
|
-
* @returns {T|undefined}
|
|
115905
|
-
*/
|
|
115906
|
-
function arrayPickBestElement(array, scoreFunction) {
|
|
115907
115919
|
|
|
115908
|
-
|
|
115909
|
-
|
|
115910
|
-
|
|
115911
|
-
|
|
115912
|
-
|
|
115913
|
-
if (size === 0) {
|
|
115914
|
-
return undefined;
|
|
115920
|
+
/**
|
|
115921
|
+
* @returns {Promise}
|
|
115922
|
+
*/
|
|
115923
|
+
startup() {
|
|
115924
|
+
return Promise.resolve();
|
|
115915
115925
|
}
|
|
115916
115926
|
|
|
115917
|
-
|
|
115918
|
-
|
|
115919
|
-
|
|
115920
|
-
|
|
115921
|
-
|
|
115922
|
-
const el = array[i];
|
|
115923
|
-
|
|
115924
|
-
// compute score
|
|
115925
|
-
const score = scoreFunction(el, i);
|
|
115926
|
-
|
|
115927
|
-
if (score > bestScore) {
|
|
115928
|
-
bestScore = score;
|
|
115929
|
-
bestElement = el;
|
|
115930
|
-
}
|
|
115927
|
+
/**
|
|
115928
|
+
* @returns {Promise}
|
|
115929
|
+
*/
|
|
115930
|
+
shutdown() {
|
|
115931
|
+
return Promise.resolve();
|
|
115931
115932
|
}
|
|
115932
115933
|
|
|
115933
|
-
return bestElement;
|
|
115934
115934
|
}
|
|
115935
115935
|
|
|
115936
115936
|
class WebEnginePlatform extends EnginePlatform {
|
|
@@ -116005,7 +116005,7 @@ class WebEnginePlatform extends EnginePlatform {
|
|
|
116005
116005
|
};
|
|
116006
116006
|
});
|
|
116007
116007
|
|
|
116008
|
-
const best =
|
|
116008
|
+
const best = array_pick_best_element(scoredKeys, o => o.score);
|
|
116009
116009
|
|
|
116010
116010
|
if (best.score === 0) {
|
|
116011
116011
|
return 'en-gb';
|