@woosh/meep-engine 2.124.12 → 2.124.13
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/package.json +1 -1
- package/src/engine/animation/AnimationUtils.js +1 -1
- package/src/engine/animation/curve/AnimationCurve.d.ts +13 -3
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +13 -3
- package/src/engine/animation/curve/Keyframe.d.ts +4 -2
- package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
- package/src/engine/animation/curve/Keyframe.js +6 -2
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +7 -2
- package/src/engine/ecs/EntityManager.d.ts +1 -1
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +49 -23
- package/src/engine/ecs/EntityObserver.d.ts.map +1 -1
- package/src/engine/ecs/EntityObserver.js +9 -0
- package/src/engine/ecs/util/EntityBuilderUtils.d.ts.map +1 -0
- package/src/engine/ecs/{EntityBuilderUtils.js → util/EntityBuilderUtils.js} +1 -1
- package/src/engine/ecs/EntityBuilderUtils.d.ts.map +0 -1
- /package/src/engine/ecs/{EntityBuilderUtils.d.ts → util/EntityBuilderUtils.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.124.
|
|
8
|
+
"version": "2.124.13",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
|
|
2
2
|
import Timer from "../ecs/components/Timer.js";
|
|
3
3
|
import Entity from "../ecs/Entity.js";
|
|
4
|
-
import { whenAllEntitiesDestroyed, whenEntityDestroyed } from "../ecs/EntityBuilderUtils.js";
|
|
5
4
|
import { Transform } from "../ecs/transform/Transform.js";
|
|
5
|
+
import { whenAllEntitiesDestroyed, whenEntityDestroyed } from "../ecs/util/EntityBuilderUtils.js";
|
|
6
6
|
import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
|
|
7
7
|
import { createSound, createTimer } from "../EntityCreator.js";
|
|
8
8
|
import Mesh from "../graphics/ecs/mesh/Mesh.js";
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
* Values are stored in {@link Keyframe}s, interpolation is defined by tangents on {@link Keyframe}s.
|
|
4
4
|
* The curve is a cubic Hermite spline, see https://en.wikipedia.org/wiki/Cubic_Hermite_spline.
|
|
5
5
|
*
|
|
6
|
+
* @example
|
|
7
|
+
* const jump_curve = AnimationCurve.from([
|
|
8
|
+
* Keyframe.from(0, 0), // start at height 0
|
|
9
|
+
* Keyframe.from(0.3, 2), // at time 0.3, jump height will be 2 meters
|
|
10
|
+
* Keyframe.from(1, 0) // at time 1.0, land back on the ground
|
|
11
|
+
* ]);
|
|
12
|
+
*
|
|
13
|
+
* jump_curve.evaluate(0.1); // what is the height at time 0.1?
|
|
14
|
+
*
|
|
6
15
|
* @author Alex Goldring
|
|
7
16
|
* @copyright Company Named Limited (c) 2025
|
|
8
17
|
*/
|
|
@@ -23,7 +32,7 @@ export class AnimationCurve {
|
|
|
23
32
|
*/
|
|
24
33
|
static easeInOut(timeStart?: number, valueStart?: number, timeEnd?: number, valueEnd?: number): AnimationCurve;
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* A flat-line curve with a specific start and end times
|
|
27
36
|
* @param {number} [timeStart]
|
|
28
37
|
* @param {number} [timeEnd]
|
|
29
38
|
* @param {number} [value]
|
|
@@ -31,7 +40,7 @@ export class AnimationCurve {
|
|
|
31
40
|
*/
|
|
32
41
|
static constant(timeStart?: number, timeEnd?: number, value?: number): AnimationCurve;
|
|
33
42
|
/**
|
|
34
|
-
*
|
|
43
|
+
* Curve with two keyframes connected by a straight line
|
|
35
44
|
* @param {number} [timeStart]
|
|
36
45
|
* @param {number} [valueStart]
|
|
37
46
|
* @param {number} [timeEnd]
|
|
@@ -45,7 +54,8 @@ export class AnimationCurve {
|
|
|
45
54
|
*/
|
|
46
55
|
readonly keys: Keyframe[];
|
|
47
56
|
/**
|
|
48
|
-
*
|
|
57
|
+
* Add a new keyframe into the animation.
|
|
58
|
+
* Keyframes can be added out of order, they will be inserted into correct chronological position.
|
|
49
59
|
* @param {Keyframe} key
|
|
50
60
|
* @returns {number} key index where it was inserted at
|
|
51
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"AAqBA
|
|
1
|
+
{"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;GAgBG;AACH;IA6WI;;;;OAIG;IACH,kBAHW,QAAQ,EAAE,GACR,cAAc,CAQ1B;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAUzB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,YACN,MAAM,UACN,MAAM,GACL,cAAc,CAOzB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAYzB;IA3aD;;;OAGG;IACH,eAFU,QAAQ,EAAE,CAEV;IAEV;;;;;OAKG;IACH,SAHW,QAAQ,GACN,MAAM,CAiClB;IAED;;;OAGG;IACH,cAFW,QAAQ,EAAE,QAUpB;IAED;;;;OAIG;IACH,YAHW,QAAQ,GACN,OAAO,CAYnB;IAED;;OAEG;IACH,cAEC;IAGD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,cAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAYlB;IAED;;;;OAIG;IACH,gBAFY,MAAM,CAYjB;IAED;;;OAGG;IACH,gBAFa,MAAM,CAgBlB;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,MAAM,CA0ClB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACL,MAAM,CAoCjB;IAED;;;;OAIG;IACH,qBAFW,MAAM,QAmChB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAWhB;IAED,0BAKC;IAED;;;;OAIG;IACH,cAHW,cAAc,GACb,OAAO,CAIlB;IAED;;;OAGG;IACH,YAFW,cAAc,QAIxB;IAED;;;OAGG;IACH,SAFY,cAAc,CAQzB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;MAIC;IAED;;aAeC;CAkEJ;yBA1cwB,eAAe"}
|
|
@@ -24,6 +24,15 @@ function compareKeyframeToTime(time, keyframe) {
|
|
|
24
24
|
* Values are stored in {@link Keyframe}s, interpolation is defined by tangents on {@link Keyframe}s.
|
|
25
25
|
* The curve is a cubic Hermite spline, see https://en.wikipedia.org/wiki/Cubic_Hermite_spline.
|
|
26
26
|
*
|
|
27
|
+
* @example
|
|
28
|
+
* const jump_curve = AnimationCurve.from([
|
|
29
|
+
* Keyframe.from(0, 0), // start at height 0
|
|
30
|
+
* Keyframe.from(0.3, 2), // at time 0.3, jump height will be 2 meters
|
|
31
|
+
* Keyframe.from(1, 0) // at time 1.0, land back on the ground
|
|
32
|
+
* ]);
|
|
33
|
+
*
|
|
34
|
+
* jump_curve.evaluate(0.1); // what is the height at time 0.1?
|
|
35
|
+
*
|
|
27
36
|
* @author Alex Goldring
|
|
28
37
|
* @copyright Company Named Limited (c) 2025
|
|
29
38
|
*/
|
|
@@ -35,7 +44,8 @@ export class AnimationCurve {
|
|
|
35
44
|
keys = [];
|
|
36
45
|
|
|
37
46
|
/**
|
|
38
|
-
*
|
|
47
|
+
* Add a new keyframe into the animation.
|
|
48
|
+
* Keyframes can be added out of order, they will be inserted into correct chronological position.
|
|
39
49
|
* @param {Keyframe} key
|
|
40
50
|
* @returns {number} key index where it was inserted at
|
|
41
51
|
*/
|
|
@@ -423,7 +433,7 @@ export class AnimationCurve {
|
|
|
423
433
|
}
|
|
424
434
|
|
|
425
435
|
/**
|
|
426
|
-
*
|
|
436
|
+
* A flat-line curve with a specific start and end times
|
|
427
437
|
* @param {number} [timeStart]
|
|
428
438
|
* @param {number} [timeEnd]
|
|
429
439
|
* @param {number} [value]
|
|
@@ -437,7 +447,7 @@ export class AnimationCurve {
|
|
|
437
447
|
}
|
|
438
448
|
|
|
439
449
|
/**
|
|
440
|
-
*
|
|
450
|
+
* Curve with two keyframes connected by a straight line
|
|
441
451
|
* @param {number} [timeStart]
|
|
442
452
|
* @param {number} [valueStart]
|
|
443
453
|
* @param {number} [timeEnd]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Single keyframe of {@link AnimationCurve}
|
|
2
|
+
* Single keyframe of {@link AnimationCurve}.
|
|
3
|
+
* Note that {@link AnimationCurve} relies on Keyframes to be static, so treat them as immutable.
|
|
4
|
+
* Do not change keyframe values unless you understand the implications of doing so.
|
|
3
5
|
*
|
|
4
6
|
* @author Alex Goldring
|
|
5
7
|
* @copyright Company Named Limited (c) 2025
|
|
@@ -20,7 +22,7 @@ export class Keyframe {
|
|
|
20
22
|
*/
|
|
21
23
|
value: number;
|
|
22
24
|
/**
|
|
23
|
-
* Timestamp
|
|
25
|
+
* Timestamp/position for the value
|
|
24
26
|
* @type {number}
|
|
25
27
|
*/
|
|
26
28
|
time: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyframe.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/Keyframe.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"Keyframe.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/Keyframe.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH;IAyBI;;;;;;;OAOG;IACH,kBANW,MAAM,SACN,MAAM,cACN,MAAM,eACN,MAAM,GACL,QAAQ,CAQnB;IAtCD;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,YAFU,MAAM,CAED;IAkBf;;;;;;OAMG;IACH,UALW,MAAM,SACN,MAAM,aACN,MAAM,cACN,MAAM,QAqBhB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAQnB;IAED;;;OAGG;IACH,YAFW,QAAQ,QAOlB;IAED;;;OAGG;IACH,SAFY,QAAQ,CAQnB;IAED;;;OAGG;IACH,QAFY,MAAM,CAKjB;IAED;;;;;MAOC;IAED;;;;;aAQC;IAIL;;;;OAIG;IACH,qBAFU,OAAO,CAEY;CAP5B"}
|
|
@@ -2,7 +2,9 @@ import { assert } from "../../../core/assert.js";
|
|
|
2
2
|
import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Single keyframe of {@link AnimationCurve}
|
|
5
|
+
* Single keyframe of {@link AnimationCurve}.
|
|
6
|
+
* Note that {@link AnimationCurve} relies on Keyframes to be static, so treat them as immutable.
|
|
7
|
+
* Do not change keyframe values unless you understand the implications of doing so.
|
|
6
8
|
*
|
|
7
9
|
* @author Alex Goldring
|
|
8
10
|
* @copyright Company Named Limited (c) 2025
|
|
@@ -15,7 +17,7 @@ export class Keyframe {
|
|
|
15
17
|
value = 0;
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
* Timestamp
|
|
20
|
+
* Timestamp/position for the value
|
|
19
21
|
* @type {number}
|
|
20
22
|
*/
|
|
21
23
|
time = 0;
|
|
@@ -64,9 +66,11 @@ export class Keyframe {
|
|
|
64
66
|
|
|
65
67
|
assert.isNumber(inTangent, 'inTangent');
|
|
66
68
|
assert.notNaN(inTangent, 'inTangent');
|
|
69
|
+
assert.isFinite(inTangent, 'inTangent');
|
|
67
70
|
|
|
68
71
|
assert.isNumber(outTangent, 'outTangent');
|
|
69
72
|
assert.notNaN(outTangent, 'outTangent');
|
|
73
|
+
assert.isFinite(outTangent, 'outTangent');
|
|
70
74
|
|
|
71
75
|
this.time = time;
|
|
72
76
|
this.value = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+CAfgB,QAAQ,CAAC,MAAM;IAiB3B;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;OASG;IACH,2BAAkC;IAElC;;;;;OAKG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;OAGG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,MAAM,CAAC,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,MAAM,CAEe;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,iBALa,CAAC,EAAE,CAAC,UACN,GAAG,kBACH,CAAC,GACC,OAAO,CAAC,CAAC,CAAC,CAoCtB;IAED;;;;;OAKG;IACH,sBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,yBAJW,cAAc,cACd,OAAO,GACL,OAAO,
|
|
1
|
+
{"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+CAfgB,QAAQ,CAAC,MAAM;IAiB3B;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;OASG;IACH,2BAAkC;IAElC;;;;;OAKG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;OAGG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,MAAM,CAAC,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,MAAM,CAEe;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,iBALa,CAAC,EAAE,CAAC,UACN,GAAG,kBACH,CAAC,GACC,OAAO,CAAC,CAAC,CAAC,CAoCtB;IAED;;;;;OAKG;IACH,sBAJW,cAAc,cACd,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,yBAJW,cAAc,cACd,OAAO,GACL,OAAO,CA4DnB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,yBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,qBACN,EAAE,SAmCZ;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,EAAE,CAyBd;IAED;;;;;OAKG;IACH,yBAJW,KAAK,EAAE,GACL,IAAI,CA0LhB;IAED;;;;OAIG;IACH,mCAHW,KAAK,EAAE,GACL,OAAO,CAenB;IAED;;;;;OAKG;IACH,gCAHW,KAAK,WAAS,GACb,OAAO,CASlB;IAED;;;OAGG;IACH,uBAFa,KAAK,EAAE,CAInB;I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OAIG;IACH,SAHa,IAAI,CAShB;IAED;;;;;OAKG;IACH,YAHa,IAAI,CAehB;IAED;;;;OAIG;IACH,wBAJa,CAAC,cACH,MAAM,GACJ,IAAI,cAAU,KAAK,CAAC,CAAC,CAAC,CAiBlC;IAED;;;;;OAKG;IACH,mBAHW,sBAAsB,6BACpB,IAAI,CA6DhB;IAED;;;;;OAKG;IACH,2EAFa,IAAI,CAgDhB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,8CAHW,GAAC,GACC,IAAI,CAgBhB;IAGL;;;OAGG;IACH,mCAFU,OAAO,CAEwC;IAIzD;;OAEG;IACH,4BAzmBgB,SAAS,CAAC,MAAM,CAAC,CAymBoB;IAErD;;OAEG;IACH,iCA/Ye,MAAM,gCAEN,GAAC,KACC,OAAO,CA4Y+B;IAhnBnD;;;OAGG;IACH,qBAFY,SAAS,CAAC,MAAM,CAAC,CAY5B;CAglBJ;mBAv9DkB,oCAAoC"}
|
|
@@ -359,6 +359,11 @@ export class EntityComponentDataset {
|
|
|
359
359
|
* @returns {boolean}
|
|
360
360
|
*/
|
|
361
361
|
removeObserver(observer, immediate) {
|
|
362
|
+
if (observer.dataset !== this) {
|
|
363
|
+
// not connected to this dataset
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
|
|
362
367
|
let i;
|
|
363
368
|
let foundFlag = false;
|
|
364
369
|
|
|
@@ -1074,13 +1079,13 @@ export class EntityComponentDataset {
|
|
|
1074
1079
|
|
|
1075
1080
|
const index = this.computeComponentTypeIndex(component_type);
|
|
1076
1081
|
|
|
1077
|
-
if(index!== -1) {
|
|
1082
|
+
if (index !== -1) {
|
|
1078
1083
|
|
|
1079
1084
|
const components = this.components[index];
|
|
1080
1085
|
for (const entity_key in components) {
|
|
1081
1086
|
const c = components[entity_key];
|
|
1082
1087
|
|
|
1083
|
-
if(c !== undefined){
|
|
1088
|
+
if (c !== undefined) {
|
|
1084
1089
|
entity = Number(entity_key);
|
|
1085
1090
|
component = c;
|
|
1086
1091
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":"iCAeU,MAAM;;;;;;;;;AAWhB;;;GAGG;AACH;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;OAIG;IACH,uCAA2B;IAE3B;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":"iCAeU,MAAM;;;;;;;;;AAWhB;;;GAGG;AACH;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;OAIG;IACH,uCAA2B;IAE3B;;;;OAIG;IACH,iCAA4B;IAE5B;;OAEG;IACH;;;QAGI;;WAEG;qBADO,MAAM,iCAAQ;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;;;OAMG;IACH,gDAA2C;IAE3C;;;;;;;;;OASG;IACH,qBAFU,MAAM,CAEqB;IAErC;;;;;OAKG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;;OAIG;IACH,SAFU,sBAAsB,CAEjB;IAEf;;;;;OAKG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BAmFC;IAED,sBAkBC;IAED;;;OAGG;IACH,uBAFa,KAAK,EAAE,CAuBnB;IAED;;;;;OAKG;IACH,uBAJW,sBAAsB,QA+BhC;IAED;;;;OAIG;IACH,UAJa,CAAC,eACH,KAAK,CAAC,CAAC,CAAC,GACN,OAAO,CAInB;IAED;;;;OAIG;IACH,UAJa,CAAC,eACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,GAAC,IAAI,CAkBlB;IAED;;;;;OAKG;IACH,wBAJa,CAAC,aACH,MAAM,GACJ,IAAI,GAAC,KAAK,CAAC,CAAC,CAAC,CAiBzB;IAGD;;;OAGG;IACH,oBAFW,MAAM,QAoEhB;IAED;;;;;OAKG;IACH,iEAoEC;IAED;;;;OAIG;IACH,uDAFa,OAAO,CAAC,OAAO,CAAC,CAyC5B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;;OAKG;IACH,oBAsDC;IAED;;;;;OAKG;IACH,kEAwEC;IAED;;;;OAIG;IACH,2BAHW,KAAK,GACH,OAAO,iCAAS,CA0B5B;IAED;;;;;OAKG;IACH,kCAJW,KAAK,SACL,WAAW,GACT,OAAO,iCAAS,CAsB5B;IAED;;;;;OAKG;IACH,mEAsEC;CACJ;uBA10BmC,aAAa;mBAP9B,oCAAoC"}
|
|
@@ -46,9 +46,9 @@ export class EntityManager {
|
|
|
46
46
|
/**
|
|
47
47
|
* @readonly
|
|
48
48
|
* @private
|
|
49
|
-
* @type {EntityObserver
|
|
49
|
+
* @type {Map<System,EntityObserver>}
|
|
50
50
|
*/
|
|
51
|
-
systemObservers =
|
|
51
|
+
systemObservers = new Map();
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @readonly
|
|
@@ -132,6 +132,11 @@ export class EntityManager {
|
|
|
132
132
|
for (let i = 0; i < system_count; i++) {
|
|
133
133
|
const system = systems[i];
|
|
134
134
|
|
|
135
|
+
if (system.state.get() !== SystemState.RUNNING) {
|
|
136
|
+
// exclude systems that are not running
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
135
140
|
if (system.update === noop && system.fixedUpdate === noop) {
|
|
136
141
|
// not a simulation system
|
|
137
142
|
continue;
|
|
@@ -206,9 +211,13 @@ export class EntityManager {
|
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
//remove system observers
|
|
209
|
-
this.systemObservers
|
|
214
|
+
for (const [_, observer] of this.systemObservers) {
|
|
215
|
+
if (!observer.isConnected) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
dataset.removeObserver(observer, true);
|
|
211
|
-
}
|
|
220
|
+
}
|
|
212
221
|
|
|
213
222
|
this.dataset = null;
|
|
214
223
|
}
|
|
@@ -255,7 +264,7 @@ export class EntityManager {
|
|
|
255
264
|
return;
|
|
256
265
|
}
|
|
257
266
|
|
|
258
|
-
throw new Error("Illegal status, another dataset is currently attached");
|
|
267
|
+
throw new Error("Illegal status, another dataset is currently attached, you must detach it first");
|
|
259
268
|
}
|
|
260
269
|
|
|
261
270
|
const localComponentTypeMap = this.getComponentTypeMap();
|
|
@@ -265,9 +274,14 @@ export class EntityManager {
|
|
|
265
274
|
|
|
266
275
|
this.dataset = dataset;
|
|
267
276
|
|
|
268
|
-
this.systemObservers
|
|
277
|
+
for (const [s, observer] of this.systemObservers) {
|
|
278
|
+
if (s.state.get() !== SystemState.RUNNING) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
|
|
269
282
|
dataset.addObserver(observer, true);
|
|
270
|
-
}
|
|
283
|
+
}
|
|
284
|
+
|
|
271
285
|
}
|
|
272
286
|
|
|
273
287
|
/**
|
|
@@ -285,6 +299,8 @@ export class EntityManager {
|
|
|
285
299
|
* @returns {T|null}
|
|
286
300
|
*/
|
|
287
301
|
getSystem(systemClass) {
|
|
302
|
+
assert.isFunction(systemClass, 'systemClass');
|
|
303
|
+
|
|
288
304
|
const systems = this.systems;
|
|
289
305
|
const numSystems = systems.length;
|
|
290
306
|
|
|
@@ -307,6 +323,8 @@ export class EntityManager {
|
|
|
307
323
|
* @returns {null|Class<T>}
|
|
308
324
|
*/
|
|
309
325
|
getComponentClassByName(className) {
|
|
326
|
+
assert.isString(className, 'className');
|
|
327
|
+
|
|
310
328
|
const componentTypes = this.getComponentTypeMap();
|
|
311
329
|
|
|
312
330
|
let i = 0;
|
|
@@ -330,18 +348,17 @@ export class EntityManager {
|
|
|
330
348
|
assert.isNumber(timeDelta, 'timeDelta');
|
|
331
349
|
assert.notNaN(timeDelta, 'timeDelta');
|
|
332
350
|
assert.greaterThanOrEqual(timeDelta, 0, 'timeDelta must be >= 0');
|
|
333
|
-
assert.
|
|
351
|
+
assert.isFinite(timeDelta, 'timeDelta');
|
|
334
352
|
|
|
335
353
|
if (this.__execution_order_needs_update) {
|
|
336
354
|
this.updateExecutionOrder();
|
|
337
355
|
}
|
|
338
356
|
|
|
339
|
-
|
|
340
357
|
/**
|
|
341
358
|
*
|
|
342
359
|
* @type {System[]}
|
|
343
360
|
*/
|
|
344
|
-
const systems = this.
|
|
361
|
+
const systems = this.systemsExecutionOrder;
|
|
345
362
|
|
|
346
363
|
const system_count = systems.length;
|
|
347
364
|
|
|
@@ -360,6 +377,7 @@ export class EntityManager {
|
|
|
360
377
|
let accumulated_time = accumulatedTime.get(system) + timeDelta;
|
|
361
378
|
|
|
362
379
|
const t0 = performance.now();
|
|
380
|
+
|
|
363
381
|
while (accumulated_time >= fixed_step) {
|
|
364
382
|
|
|
365
383
|
try {
|
|
@@ -437,12 +455,10 @@ export class EntityManager {
|
|
|
437
455
|
|
|
438
456
|
systems[systemIndex] = system;
|
|
439
457
|
|
|
440
|
-
// request exec order update
|
|
441
|
-
this.__execution_order_needs_update = true;
|
|
442
458
|
|
|
443
459
|
//build observer
|
|
444
|
-
const
|
|
445
|
-
this.systemObservers
|
|
460
|
+
const entityObserver = new EntityObserver(system.dependencies, system.link, system.unlink, system);
|
|
461
|
+
this.systemObservers.set(system, entityObserver);
|
|
446
462
|
|
|
447
463
|
let startup_promise;
|
|
448
464
|
if (this.state === EntityManagerState.Running) {
|
|
@@ -461,18 +477,14 @@ export class EntityManager {
|
|
|
461
477
|
throw new Error(`System is bound to another EntityManager`);
|
|
462
478
|
}
|
|
463
479
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
// link dependency components
|
|
467
|
-
this.dataset.registerManyComponentTypes(system.referenced_components);
|
|
468
|
-
|
|
469
|
-
this.dataset.addObserver(linkObserver);
|
|
470
|
-
}
|
|
480
|
+
// link dependency components
|
|
481
|
+
this.dataset?.registerManyComponentTypes(system.referenced_components);
|
|
471
482
|
|
|
472
483
|
this.systemAccumulatedFixedStepTime.set(system, 0);
|
|
473
484
|
|
|
474
485
|
this.on.systemAdded.send1(system);
|
|
475
486
|
|
|
487
|
+
|
|
476
488
|
return startup_promise;
|
|
477
489
|
}
|
|
478
490
|
|
|
@@ -493,8 +505,8 @@ export class EntityManager {
|
|
|
493
505
|
}
|
|
494
506
|
|
|
495
507
|
//unlink system observer
|
|
496
|
-
const systemObserver = this.systemObservers
|
|
497
|
-
this.systemObservers.
|
|
508
|
+
const systemObserver = this.systemObservers.get(system);
|
|
509
|
+
this.systemObservers.delete(system);
|
|
498
510
|
|
|
499
511
|
assert.notEqual(systemObserver, undefined, "System observer is undefined, it was possibly removed illegally or was not created");
|
|
500
512
|
|
|
@@ -592,6 +604,20 @@ export class EntityManager {
|
|
|
592
604
|
|
|
593
605
|
self.on.systemStarted.dispatch(system);
|
|
594
606
|
|
|
607
|
+
const i = self.systems.indexOf(system);
|
|
608
|
+
|
|
609
|
+
assert.notEqual(i, -1, "System was not found in the system list");
|
|
610
|
+
|
|
611
|
+
const observer = self.systemObservers.get(system);
|
|
612
|
+
|
|
613
|
+
if (observer !== undefined) {
|
|
614
|
+
// only link the observer once startup has succeeded
|
|
615
|
+
self.dataset?.addObserver(observer, true);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// request exec order update
|
|
619
|
+
self.__execution_order_needs_update = true;
|
|
620
|
+
|
|
595
621
|
successCallback(system);
|
|
596
622
|
}
|
|
597
623
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityObserver.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityObserver.js"],"names":[],"mappings":"AAGA;IAoBI;;;;;;;OAOG;IACH,0FAHW,GAAC,EA+CX;IAvED;;;OAGG;IACH,eAFU,MAAM,CAEa;IAE7B;;;;OAIG;IACH,uBAFU,MAAM,EAAE,CAES;IAE3B;;;OAGG;IACH,SAFU,sBAAsB,GAAC,IAAI,CAEtB;IA0BX;;OAEG;IACH,oBAFU,MAAM,CAE2B;IAE3C;;;OAGG;IACH,kBAFU,CAAS,IAAK,eAAC,CAEgB;IAEzC;;;OAGG;IACH,gBAFU,CAAS,IAAK,eAAC,CAEW;IAEpC;;;OAGG;IACH,sBAAoC;IAEpC;;;OAGG;IACH,SAFU,GAAC,CAEW;IAG1B;;;OAGG;IACH,qCAqBC;IAED;;;OAGG;IACH,iBAFW,sBAAsB,QAIhC;IAED,
|
|
1
|
+
{"version":3,"file":"EntityObserver.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityObserver.js"],"names":[],"mappings":"AAGA;IAoBI;;;;;;;OAOG;IACH,0FAHW,GAAC,EA+CX;IAvED;;;OAGG;IACH,eAFU,MAAM,CAEa;IAE7B;;;;OAIG;IACH,uBAFU,MAAM,EAAE,CAES;IAE3B;;;OAGG;IACH,SAFU,sBAAsB,GAAC,IAAI,CAEtB;IA0BX;;OAEG;IACH,oBAFU,MAAM,CAE2B;IAE3C;;;OAGG;IACH,kBAFU,CAAS,IAAK,eAAC,CAEgB;IAEzC;;;OAGG;IACH,gBAFU,CAAS,IAAK,eAAC,CAEW;IAEpC;;;OAGG;IACH,sBAAoC;IAEpC;;;OAGG;IACH,SAFU,GAAC,CAEW;IAG1B;;;OAGG;IACH,qCAqBC;IAED;;;OAGG;IACH,iBAFW,sBAAsB,QAIhC;IAED;;;OAGG;IACH,mBAFY,OAAO,CAIlB;IAED,mBAIC;CACJ;uBA5HsB,6BAA6B"}
|
|
@@ -110,8 +110,17 @@ export class EntityObserver {
|
|
|
110
110
|
dataset.addObserver(this, true);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @return {boolean}
|
|
116
|
+
*/
|
|
117
|
+
get isConnected() {
|
|
118
|
+
return this.dataset === null;
|
|
119
|
+
}
|
|
120
|
+
|
|
113
121
|
disconnect() {
|
|
114
122
|
//de-register updates
|
|
115
123
|
this.dataset.removeObserver(this);
|
|
124
|
+
this.dataset = null;
|
|
116
125
|
}
|
|
117
126
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityBuilderUtils.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/util/EntityBuilderUtils.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,mDAHW,MAAM,EAAE,gBAKlB;AAED;;;;GAIG;AACH,6CAHW,MAAM,gBAOhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityBuilderUtils.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityBuilderUtils.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,mDAHW,MAAM,EAAE,gBAKlB;AAED;;;;GAIG;AACH,6CAHW,MAAM,gBAOhB"}
|
|
File without changes
|