@woosh/meep-engine 2.84.3 → 2.84.5
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 +163 -109
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +163 -109
- package/editor/view/ecs/EntityEditor.js +7 -8
- package/package.json +1 -1
- package/src/core/math/random/roundFair.js +5 -2
- package/src/core/math/random/roundFair.spec.js +12 -0
- package/src/core/math/random/seededRandom_Mulberry32.spec.js +19 -0
- package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +25 -2
- package/src/core/model/node-graph/node/Port.js +8 -6
- package/src/core/model/node-graph/node/Port.spec.js +49 -0
- package/src/core/process/matcher/and.js +16 -0
- package/src/core/process/matcher/isDefined.js +8 -0
- package/src/core/process/matcher/isEqualTo.js +10 -0
- package/src/core/process/matcher/isGreaterThan.js +10 -0
- package/src/core/process/matcher/isGreaterThanOrEqualTo.js +10 -0
- package/src/core/process/matcher/isInstanceOf.js +10 -0
- package/src/core/process/matcher/isLessThan.js +10 -0
- package/src/core/process/matcher/isLessThanOrEqualTo.js +10 -0
- package/src/core/process/matcher/isNull.js +8 -0
- package/src/core/process/matcher/isTypeOf.js +16 -0
- package/src/core/process/matcher/not.js +10 -0
- package/src/core/process/matcher/or.js +16 -0
- package/src/core/process/task/util/actionTask.spec.js +14 -0
- package/src/core/process/task/util/countTask.js +1 -1
- package/src/core/process/task/util/countTask.spec.js +18 -0
- package/src/engine/asset/AssetDescription.js +6 -0
- package/src/engine/ecs/Entity.js +9 -4
- package/src/engine/ecs/EntityComponentDataset.js +78 -26
- package/src/view/common/LabelView.js +3 -1
- package/src/view/elements/windrose/WindRoseDiagram.js +3 -3
- package/src/core/math/spline/spline_catmullrom_1d.js +0 -120
- package/src/core/process/IntervalExecutor.js +0 -78
- package/src/core/process/matcher/Matchers.js +0 -145
package/build/meep.cjs
CHANGED
|
@@ -63966,7 +63966,7 @@ Task.prototype.isTask = true;
|
|
|
63966
63966
|
/**
|
|
63967
63967
|
*
|
|
63968
63968
|
* @param {number|function(*):number} initial
|
|
63969
|
-
* @param {number|function(*):number} limit
|
|
63969
|
+
* @param {number|function(*):number} limit limit is excluded from the count, same as `for(;i < limit;)`
|
|
63970
63970
|
* @param {function(index:int)} callback
|
|
63971
63971
|
* @returns {Task}
|
|
63972
63972
|
*/
|
|
@@ -69664,6 +69664,36 @@ function array_remove_first(array, element, start_index = 0, length = array.leng
|
|
|
69664
69664
|
return false;
|
|
69665
69665
|
}
|
|
69666
69666
|
|
|
69667
|
+
/**
|
|
69668
|
+
*
|
|
69669
|
+
* @param {*} value
|
|
69670
|
+
* @return {boolean}
|
|
69671
|
+
*/
|
|
69672
|
+
function isDefined(value) {
|
|
69673
|
+
return value !== undefined;
|
|
69674
|
+
}
|
|
69675
|
+
|
|
69676
|
+
/**
|
|
69677
|
+
*
|
|
69678
|
+
* @enum
|
|
69679
|
+
*/
|
|
69680
|
+
const EntityFlags = {
|
|
69681
|
+
/**
|
|
69682
|
+
* Whether the entity is built, set internally
|
|
69683
|
+
*/
|
|
69684
|
+
Built: 1,
|
|
69685
|
+
/**
|
|
69686
|
+
* If component type is not registered on the {@link EntityComponentDataset} when calling {@link Entity#build} - will register the component first
|
|
69687
|
+
*/
|
|
69688
|
+
RegisterComponents: 2,
|
|
69689
|
+
/**
|
|
69690
|
+
* Entity builder will watch destruction of the entity (subscribe to event), this will make the {@link Entity} automatically
|
|
69691
|
+
* recognize when the corresponding entity is destroyed outside the {@link Entity} API
|
|
69692
|
+
* NOTE: useful to turn off to save a bit of memory, as those event listeners take up a bit of space. Feel free to turn this flag off when you don't care to keep the reference to the {@link Entity}
|
|
69693
|
+
*/
|
|
69694
|
+
WatchDestruction: 4
|
|
69695
|
+
};
|
|
69696
|
+
|
|
69667
69697
|
/**
|
|
69668
69698
|
* de Bruijn sequence
|
|
69669
69699
|
* @see https://graphics.stanford.edu/~seander/bithacks.html
|
|
@@ -72276,78 +72306,6 @@ class EntityManager {
|
|
|
72276
72306
|
}
|
|
72277
72307
|
}
|
|
72278
72308
|
|
|
72279
|
-
/**
|
|
72280
|
-
* @author Alex Goldring
|
|
72281
|
-
* @copyright Alex Goldring 2017
|
|
72282
|
-
*/
|
|
72283
|
-
|
|
72284
|
-
|
|
72285
|
-
/**
|
|
72286
|
-
*
|
|
72287
|
-
* @param {*} value
|
|
72288
|
-
* @return {boolean}
|
|
72289
|
-
*/
|
|
72290
|
-
function isDefined(value) {
|
|
72291
|
-
return value !== undefined;
|
|
72292
|
-
}
|
|
72293
|
-
|
|
72294
|
-
/**
|
|
72295
|
-
* performs instanceof match
|
|
72296
|
-
* @param {function} type
|
|
72297
|
-
* @returns {function(*): boolean}
|
|
72298
|
-
*/
|
|
72299
|
-
function isInstanceOf$1(type) {
|
|
72300
|
-
return function (m) {
|
|
72301
|
-
return m instanceof type;
|
|
72302
|
-
}
|
|
72303
|
-
}
|
|
72304
|
-
|
|
72305
|
-
/**
|
|
72306
|
-
* performs typeof match
|
|
72307
|
-
* @param {string} type
|
|
72308
|
-
* @returns {function(*): boolean}
|
|
72309
|
-
*/
|
|
72310
|
-
function isTypeOf(type) {
|
|
72311
|
-
|
|
72312
|
-
return function (m) {
|
|
72313
|
-
return typeof m === type;
|
|
72314
|
-
}
|
|
72315
|
-
}
|
|
72316
|
-
|
|
72317
|
-
/**
|
|
72318
|
-
* Joins two matchers via OR
|
|
72319
|
-
* @param {function(*):boolean} a
|
|
72320
|
-
* @param {function(*):boolean} b
|
|
72321
|
-
* @returns {function(*):boolean}
|
|
72322
|
-
*/
|
|
72323
|
-
function or(a, b) {
|
|
72324
|
-
|
|
72325
|
-
return function (m) {
|
|
72326
|
-
return a(m) || b(m);
|
|
72327
|
-
}
|
|
72328
|
-
}
|
|
72329
|
-
|
|
72330
|
-
/**
|
|
72331
|
-
*
|
|
72332
|
-
* @enum
|
|
72333
|
-
*/
|
|
72334
|
-
const EntityFlags = {
|
|
72335
|
-
/**
|
|
72336
|
-
* Whether the entity is built, set internally
|
|
72337
|
-
*/
|
|
72338
|
-
Built: 1,
|
|
72339
|
-
/**
|
|
72340
|
-
* If component type is not registered on the {@link EntityComponentDataset} when calling {@link Entity#build} - will register the component first
|
|
72341
|
-
*/
|
|
72342
|
-
RegisterComponents: 2,
|
|
72343
|
-
/**
|
|
72344
|
-
* Entity builder will watch destruction of the entity (subscribe to event), this will make the {@link Entity} automatically
|
|
72345
|
-
* recognize when the corresponding entity is destroyed outside the {@link Entity} API
|
|
72346
|
-
* NOTE: useful to turn off to save a bit of memory, as those event listeners take up a bit of space. Feel free to turn this flag off when you don't care to keep the reference to the {@link Entity}
|
|
72347
|
-
*/
|
|
72348
|
-
WatchDestruction: 4
|
|
72349
|
-
};
|
|
72350
|
-
|
|
72351
72309
|
/**
|
|
72352
72310
|
* Set of default flags
|
|
72353
72311
|
* @type {number}
|
|
@@ -72546,6 +72504,7 @@ class Entity {
|
|
|
72546
72504
|
* @returns {*|null}
|
|
72547
72505
|
*/
|
|
72548
72506
|
removeComponent(klass) {
|
|
72507
|
+
|
|
72549
72508
|
const elements = this.components;
|
|
72550
72509
|
const n = elements.length;
|
|
72551
72510
|
|
|
@@ -72671,6 +72630,7 @@ class Entity {
|
|
|
72671
72630
|
dataset.removeEntity(entity);
|
|
72672
72631
|
|
|
72673
72632
|
this.id = -1;
|
|
72633
|
+
this.generation = -1;
|
|
72674
72634
|
|
|
72675
72635
|
this.clearFlag(EntityFlags.Built);
|
|
72676
72636
|
|
|
@@ -72696,6 +72656,7 @@ class Entity {
|
|
|
72696
72656
|
}
|
|
72697
72657
|
|
|
72698
72658
|
const entity = this.id = dataset.createEntity();
|
|
72659
|
+
this.generation = dataset.getEntityGeneration(entity);
|
|
72699
72660
|
this.dataset = dataset;
|
|
72700
72661
|
|
|
72701
72662
|
let i;
|
|
@@ -72753,6 +72714,7 @@ class Entity {
|
|
|
72753
72714
|
r.setFlag(EntityFlags.Built);
|
|
72754
72715
|
r.id = entity;
|
|
72755
72716
|
r.dataset = dataset;
|
|
72717
|
+
r.generation = dataset.getEntityGeneration(entity);
|
|
72756
72718
|
|
|
72757
72719
|
return r;
|
|
72758
72720
|
}
|
|
@@ -84094,7 +84056,13 @@ class AssetDescription {
|
|
|
84094
84056
|
toString() {
|
|
84095
84057
|
return `{ type: '${this.type}', path: '${this.path}' }`;
|
|
84096
84058
|
}
|
|
84097
|
-
}
|
|
84059
|
+
}
|
|
84060
|
+
|
|
84061
|
+
/**
|
|
84062
|
+
* @readonly
|
|
84063
|
+
* @type {boolean}
|
|
84064
|
+
*/
|
|
84065
|
+
AssetDescription.prototype.isAssetDescription = true;
|
|
84098
84066
|
|
|
84099
84067
|
/**
|
|
84100
84068
|
* @enum {number}
|
|
@@ -89825,7 +89793,7 @@ class InputDeviceSwitch {
|
|
|
89825
89793
|
* @param klass
|
|
89826
89794
|
* @returns {boolean}
|
|
89827
89795
|
*/
|
|
89828
|
-
function isInstanceOf(thing, klass) {
|
|
89796
|
+
function isInstanceOf$1(thing, klass) {
|
|
89829
89797
|
if (klass === undefined) {
|
|
89830
89798
|
return false;
|
|
89831
89799
|
}
|
|
@@ -89846,12 +89814,12 @@ function isInstanceOf(thing, klass) {
|
|
|
89846
89814
|
* @param {Element} el
|
|
89847
89815
|
*/
|
|
89848
89816
|
function isFocusable(el) {
|
|
89849
|
-
return isInstanceOf(el, HTMLInputElement)
|
|
89850
|
-
|| isInstanceOf(el, HTMLSelectElement)
|
|
89851
|
-
|| isInstanceOf(el, HTMLTextAreaElement)
|
|
89852
|
-
|| isInstanceOf(el, HTMLAnchorElement)
|
|
89853
|
-
|| isInstanceOf(el, HTMLButtonElement)
|
|
89854
|
-
|| isInstanceOf(el, HTMLAreaElement)
|
|
89817
|
+
return isInstanceOf$1(el, HTMLInputElement)
|
|
89818
|
+
|| isInstanceOf$1(el, HTMLSelectElement)
|
|
89819
|
+
|| isInstanceOf$1(el, HTMLTextAreaElement)
|
|
89820
|
+
|| isInstanceOf$1(el, HTMLAnchorElement)
|
|
89821
|
+
|| isInstanceOf$1(el, HTMLButtonElement)
|
|
89822
|
+
|| isInstanceOf$1(el, HTMLAreaElement)
|
|
89855
89823
|
}
|
|
89856
89824
|
|
|
89857
89825
|
/**
|
|
@@ -92404,6 +92372,15 @@ class EntityComponentDataset {
|
|
|
92404
92372
|
* @type {BitSet}
|
|
92405
92373
|
*/
|
|
92406
92374
|
entityOccupancy = new BitSet();
|
|
92375
|
+
|
|
92376
|
+
/**
|
|
92377
|
+
* For each entity ID records generation when entity was created
|
|
92378
|
+
* Values are invalid for unused entity IDs
|
|
92379
|
+
* @private
|
|
92380
|
+
* @type {Uint32Array}
|
|
92381
|
+
*/
|
|
92382
|
+
entityGeneration = new Uint32Array(0);
|
|
92383
|
+
|
|
92407
92384
|
/**
|
|
92408
92385
|
* @private
|
|
92409
92386
|
* @type {BitSet}
|
|
@@ -92455,7 +92432,7 @@ class EntityComponentDataset {
|
|
|
92455
92432
|
|
|
92456
92433
|
/**
|
|
92457
92434
|
* @readonly
|
|
92458
|
-
* @type {Signal}
|
|
92435
|
+
* @type {Signal<number>}
|
|
92459
92436
|
*/
|
|
92460
92437
|
onEntityCreated = new Signal();
|
|
92461
92438
|
|
|
@@ -93005,38 +92982,79 @@ class EntityComponentDataset {
|
|
|
93005
92982
|
|
|
93006
92983
|
/**
|
|
93007
92984
|
*
|
|
93008
|
-
* @
|
|
92985
|
+
* @param {number} min_size
|
|
93009
92986
|
*/
|
|
93010
|
-
|
|
93011
|
-
const
|
|
93012
|
-
this.entityOccupancy.set(entityIndex, true);
|
|
92987
|
+
enlargeGenerationTable(min_size) {
|
|
92988
|
+
const old_generation_table_size = this.entityGeneration.length;
|
|
93013
92989
|
|
|
93014
|
-
|
|
92990
|
+
const new_size = max3(
|
|
92991
|
+
min_size,
|
|
92992
|
+
Math.ceil(old_generation_table_size * 1.2),
|
|
92993
|
+
old_generation_table_size + 16
|
|
92994
|
+
);
|
|
93015
92995
|
|
|
93016
|
-
|
|
92996
|
+
const new_generation_table = new Uint32Array(new_size);
|
|
93017
92997
|
|
|
93018
|
-
this.
|
|
92998
|
+
new_generation_table.set(this.entityGeneration);
|
|
93019
92999
|
|
|
93020
|
-
|
|
93000
|
+
this.entityGeneration = new_generation_table;
|
|
93021
93001
|
}
|
|
93022
93002
|
|
|
93023
93003
|
/**
|
|
93024
|
-
*
|
|
93025
|
-
* @param {number}
|
|
93026
|
-
* @
|
|
93004
|
+
* Produces generation ID for a given entity
|
|
93005
|
+
* @param {number} entity_id
|
|
93006
|
+
* @returns {number}
|
|
93027
93007
|
*/
|
|
93028
|
-
|
|
93029
|
-
|
|
93030
|
-
|
|
93008
|
+
getEntityGeneration(entity_id) {
|
|
93009
|
+
return this.entityGeneration[entity_id];
|
|
93010
|
+
}
|
|
93011
|
+
|
|
93012
|
+
/**
|
|
93013
|
+
* @private
|
|
93014
|
+
* @param {number} entity_id
|
|
93015
|
+
*/
|
|
93016
|
+
createEntityUnsafe(entity_id) {
|
|
93017
|
+
this.entityOccupancy.set(entity_id, true);
|
|
93018
|
+
|
|
93019
|
+
// record entity generation
|
|
93020
|
+
if (this.entityGeneration.length <= entity_id) {
|
|
93021
|
+
// needs to be resized
|
|
93022
|
+
this.enlargeGenerationTable(entity_id + 1);
|
|
93031
93023
|
}
|
|
93032
93024
|
|
|
93033
|
-
this.
|
|
93025
|
+
const current_generation = this.generation;
|
|
93026
|
+
this.generation = current_generation + 1;
|
|
93027
|
+
|
|
93028
|
+
this.entityGeneration[entity_id] = current_generation;
|
|
93034
93029
|
|
|
93035
93030
|
this.entityCount++;
|
|
93036
93031
|
|
|
93037
|
-
this.onEntityCreated.send1(
|
|
93032
|
+
this.onEntityCreated.send1(entity_id);
|
|
93033
|
+
}
|
|
93038
93034
|
|
|
93039
|
-
|
|
93035
|
+
/**
|
|
93036
|
+
*
|
|
93037
|
+
* @returns {number} entityIndex
|
|
93038
|
+
*/
|
|
93039
|
+
createEntity() {
|
|
93040
|
+
const entity_id = this.entityOccupancy.nextClearBit(0);
|
|
93041
|
+
|
|
93042
|
+
this.createEntityUnsafe(entity_id);
|
|
93043
|
+
|
|
93044
|
+
return entity_id;
|
|
93045
|
+
}
|
|
93046
|
+
|
|
93047
|
+
/**
|
|
93048
|
+
*
|
|
93049
|
+
* @param {number} entity_id
|
|
93050
|
+
* @throws {Error} if entity index is already in use
|
|
93051
|
+
*/
|
|
93052
|
+
createEntitySpecific(entity_id) {
|
|
93053
|
+
if (this.entityExists(entity_id)) {
|
|
93054
|
+
throw new Error(`EntityId ${entity_id} is already in use`);
|
|
93055
|
+
}
|
|
93056
|
+
|
|
93057
|
+
this.createEntityUnsafe(entity_id);
|
|
93040
93058
|
}
|
|
93041
93059
|
|
|
93042
93060
|
/**
|
|
@@ -93161,7 +93179,7 @@ class EntityComponentDataset {
|
|
|
93161
93179
|
const componentClass = this.componentTypeMap[componentIndex];
|
|
93162
93180
|
|
|
93163
93181
|
//dispatch event to components
|
|
93164
|
-
this.sendEvent(entityIndex, EventType.ComponentRemoved, {klass: componentClass, instance: componentInstance});
|
|
93182
|
+
this.sendEvent(entityIndex, EventType.ComponentRemoved, { klass: componentClass, instance: componentInstance });
|
|
93165
93183
|
}
|
|
93166
93184
|
|
|
93167
93185
|
/**
|
|
@@ -93262,7 +93280,7 @@ class EntityComponentDataset {
|
|
|
93262
93280
|
const componentClass = this.componentTypeMap[componentIndex];
|
|
93263
93281
|
|
|
93264
93282
|
//dispatch event to components
|
|
93265
|
-
this.sendEvent(entityIndex, EventType.ComponentAdded, {klass: componentClass, instance: componentInstance});
|
|
93283
|
+
this.sendEvent(entityIndex, EventType.ComponentAdded, { klass: componentClass, instance: componentInstance });
|
|
93266
93284
|
}
|
|
93267
93285
|
|
|
93268
93286
|
/**
|
|
@@ -96123,6 +96141,42 @@ function number_pretty_print(value) {
|
|
|
96123
96141
|
|
|
96124
96142
|
}
|
|
96125
96143
|
|
|
96144
|
+
/**
|
|
96145
|
+
* performs instanceof match
|
|
96146
|
+
* @param {function} type
|
|
96147
|
+
* @returns {function(*): boolean}
|
|
96148
|
+
*/
|
|
96149
|
+
function isInstanceOf(type) {
|
|
96150
|
+
return function (m) {
|
|
96151
|
+
return m instanceof type;
|
|
96152
|
+
}
|
|
96153
|
+
}
|
|
96154
|
+
|
|
96155
|
+
/**
|
|
96156
|
+
* performs typeof match
|
|
96157
|
+
* @param {string} type
|
|
96158
|
+
* @returns {function(*): boolean}
|
|
96159
|
+
*/
|
|
96160
|
+
function isTypeOf(type) {
|
|
96161
|
+
|
|
96162
|
+
return function (m) {
|
|
96163
|
+
return typeof m === type;
|
|
96164
|
+
}
|
|
96165
|
+
}
|
|
96166
|
+
|
|
96167
|
+
/**
|
|
96168
|
+
* Joins two matchers via OR
|
|
96169
|
+
* @param {function(*):boolean} a
|
|
96170
|
+
* @param {function(*):boolean} b
|
|
96171
|
+
* @returns {function(*):boolean}
|
|
96172
|
+
*/
|
|
96173
|
+
function or(a, b) {
|
|
96174
|
+
|
|
96175
|
+
return function (m) {
|
|
96176
|
+
return a(m) || b(m);
|
|
96177
|
+
}
|
|
96178
|
+
}
|
|
96179
|
+
|
|
96126
96180
|
/**
|
|
96127
96181
|
* Created by Alex on 01/11/2014.
|
|
96128
96182
|
* @copyright Alex Goldring 2014
|
|
@@ -96271,14 +96325,14 @@ function p(m, e, f) {
|
|
|
96271
96325
|
* @type {Array.<ValueProcessor>}
|
|
96272
96326
|
*/
|
|
96273
96327
|
const processors = [
|
|
96274
|
-
p(isInstanceOf
|
|
96275
|
-
p(isInstanceOf
|
|
96276
|
-
p(isInstanceOf
|
|
96277
|
-
p(isInstanceOf
|
|
96278
|
-
p(isInstanceOf
|
|
96279
|
-
p(isInstanceOf
|
|
96280
|
-
p(isInstanceOf
|
|
96281
|
-
p(isInstanceOf
|
|
96328
|
+
p(isInstanceOf(ObservedBoolean), extractorGetValue, format),
|
|
96329
|
+
p(isInstanceOf(ObservedValue), extractorGetValue, format),
|
|
96330
|
+
p(isInstanceOf(ObservedString), extractorGetValue, format),
|
|
96331
|
+
p(isInstanceOf(LinearValue), extractorGetValue, formatNumber),
|
|
96332
|
+
p(isInstanceOf(BoundedValue), extractBoundedValue, formatArray),
|
|
96333
|
+
p(isInstanceOf(Stat), extractorGetValue, formatNumber),
|
|
96334
|
+
p(isInstanceOf(Vector1), extractorGetValue, formatNumber),
|
|
96335
|
+
p(isInstanceOf(ObservedInteger), extractorGetValue, formatNumber),
|
|
96282
96336
|
p(or(isTypedArray, Array.isArray), arrayUnwrap, formatArray),
|
|
96283
96337
|
p(isTypeOf("number"), passThrough, formatNumber),
|
|
96284
96338
|
p(isTypeOf("string"), passThrough, passThrough),
|