@woosh/meep-engine 2.165.1 → 2.165.2
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/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +11 -7
- package/src/engine/ecs/System.d.ts.map +1 -1
- package/src/engine/ecs/System.js +4 -0
- package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.d.ts.map +1 -1
- package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +20 -10
- package/src/engine/ecs/system_validate_class.d.ts.map +1 -1
- package/src/engine/ecs/system_validate_class.js +9 -2
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"author": "Alexander Goldring",
|
|
9
|
-
"version": "2.165.
|
|
9
|
+
"version": "2.165.2",
|
|
10
10
|
"main": "build/meep.module.js",
|
|
11
11
|
"module": "build/meep.module.js",
|
|
12
12
|
"exports": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":"iCAgBU,MAAM;;;;;;;;;AAiBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAEI;;;;OAIG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;;;OAMG;IACH,uCAA2B;IAE3B;;;;;OAKG;IACH,iCAA4B;IAE5B;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;;;;;;OASG;IACH,qBAFU,MAAM,CAEqB;IAErC;;;;;;;;OAQG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;;;;;;OAQG;IACH,eAFU,MAAM,CAEE;IAElB;;;;;OAKG;IACH,+BAA2B;IAE3B;;;;OAIG;IACH,SAFU,sBAAsB,CAEjB;IAEf;;;;;OAKG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BAmFC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,uBAJW,sBAAsB,QA4ChC;IAGD;;;OAGG;IACH,sBA2BC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAgBC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAiBzB;IAGD;;;OAGG;IACH,6BAFW,MAAM,QA8EhB;IAED;;;;;;;;;OASG;IACH,qBAFa,MAAM,CAKlB;IAED;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":"iCAgBU,MAAM;;;;;;;;;AAiBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAEI;;;;OAIG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;;;;OAMG;IACH,uCAA2B;IAE3B;;;;;OAKG;IACH,iCAA4B;IAE5B;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;;;;;;OASG;IACH,qBAFU,MAAM,CAEqB;IAErC;;;;;;;;OAQG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;;;;;;OAQG;IACH,eAFU,MAAM,CAEE;IAElB;;;;;OAKG;IACH,+BAA2B;IAE3B;;;;OAIG;IACH,SAFU,sBAAsB,CAEjB;IAEf;;;;;OAKG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BAmFC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,uBAJW,sBAAsB,QA4ChC;IAGD;;;OAGG;IACH,sBA2BC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAgBC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAiBzB;IAGD;;;OAGG;IACH,6BAFW,MAAM,QA8EhB;IAED;;;;;;;;;OASG;IACH,qBAFa,MAAM,CAKlB;IAED;;;;;OAKG;IACH,iEA6DC;IAED;;;;OAIG;IACH,uDAFa,QAAQ,OAAO,CAAC,CA2C5B;IAED;;;;;OAKG;IACH,mBAmCC;IAED;;;;;OAKG;IACH,oBAqFC;IAED;;;;;OAKG;IACH,kEAyEC;IAED;;;;OAIG;IACH,mCAFa,wCAAgB,CA0B5B;IAED;;;;OAIG;IACH,8DAFa,wCAAgB,CA0B5B;IAED;;;;;OAKG;IACH,mEAoFC;IAGL;;OAEG;IACH,yBArtBe,sBAAsB,UAqtBA;IACrC;;OAEG;IACH,0BAAqC;CATpC;uBAh+BmC,aAAa;mBAR9B,oCAAoC;uCAMhB,6BAA6B"}
|
|
@@ -557,9 +557,11 @@ export class EntityManager {
|
|
|
557
557
|
systems[systemIndex] = system;
|
|
558
558
|
|
|
559
559
|
|
|
560
|
-
//build observer
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
//build observer; a dependency-less system observes no entity tuple and never links
|
|
561
|
+
if (system.dependencies.length > 0) {
|
|
562
|
+
const entityObserver = new EntityObserver(system.dependencies, system.link, system.unlink, system);
|
|
563
|
+
this.systemObservers.set(system, entityObserver);
|
|
564
|
+
}
|
|
563
565
|
|
|
564
566
|
let result_promise;
|
|
565
567
|
if (this.state === EntityManagerState.Running) {
|
|
@@ -596,11 +598,11 @@ export class EntityManager {
|
|
|
596
598
|
return false;
|
|
597
599
|
}
|
|
598
600
|
|
|
599
|
-
//unlink system observer
|
|
601
|
+
//unlink system observer, dependency-less systems don't have one
|
|
600
602
|
const systemObserver = this.systemObservers.get(system);
|
|
601
603
|
this.systemObservers.delete(system);
|
|
602
604
|
|
|
603
|
-
assert.
|
|
605
|
+
assert.ok(systemObserver !== undefined || system.dependencies.length === 0, "System observer is undefined, it was possibly removed illegally or was not created");
|
|
604
606
|
|
|
605
607
|
//shutdown system
|
|
606
608
|
this.systems.splice(systemIndex, 1);
|
|
@@ -609,8 +611,10 @@ export class EntityManager {
|
|
|
609
611
|
this.__execution_order_needs_update = true;
|
|
610
612
|
|
|
611
613
|
if (this.dataset !== null) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
+
if (systemObserver !== undefined) {
|
|
615
|
+
// remove observed and unlink entities
|
|
616
|
+
this.dataset.removeObserver(systemObserver, true);
|
|
617
|
+
}
|
|
614
618
|
system.handleDatasetDetached(this.dataset);
|
|
615
619
|
}
|
|
616
620
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"System.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/System.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAEI;;;;;OAKG;IACH,uCAAqB;IAErB;;;;OAIG;IACH,oBAA+C;IAE/C
|
|
1
|
+
{"version":3,"file":"System.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/System.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAEI;;;;;OAKG;IACH,uCAAqB;IAErB;;;;OAIG;IACH,oBAA+C;IAE/C;;;;;;;;;OASG;IACH,6BAAkB;IAElB;;;;;;;;;;OAUG;IACH,0BAFU,6BAA6B,CAElB;IAGrB;;OAEG;IACH,mCAcC;IAED;;;;;OAKG;IACH,oCAFY,MAAM,CA8BjB;IAED;;;;;;OAMG;IACH,uCAHa,QAAQ,IAAI,CAAC,CAKzB;IAED;;;;;;;OAOG;IACH,wCAHa,QAAQ,IAAI,CAAC,CAKzB;IAGD;;;;;OAKG;IACH,wCAEC;IAED;;;;;OAKG;IACH,0CAEC;IAED;;;;;;;;;;OAUG;IACH,6DAEC;IAED;;;;;;;;;;OAUG;IACH,6DAEC;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;IAEzB;;;;OAIG;IACH,2CAFsC,MAAM,CAEhB;IAG5B;;;;;;OAMG;IACH,sCAFsC,MAAM,CAErB;CAvBtB;0BA2BS,MAAM"}
|
package/src/engine/ecs/System.js
CHANGED
|
@@ -53,6 +53,8 @@ export class System {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Component classes which have to be present before the system links an entity.
|
|
56
|
+
* May be left empty: such a system observes no entity tuple, {@link link}/{@link unlink} are never invoked,
|
|
57
|
+
* and it is driven purely by {@link startup}/{@link shutdown} and the {@link update}/{@link fixedUpdate} methods.
|
|
56
58
|
* NOTE: do not modify this while the system is running.
|
|
57
59
|
* @see link
|
|
58
60
|
* @see unlink
|
|
@@ -157,6 +159,7 @@ export class System {
|
|
|
157
159
|
/**
|
|
158
160
|
* Called automatically when an entity gets a complete component tuple {@link this.dependencies}.
|
|
159
161
|
* Inputs are the same as dependencies, only instances instead of classes, plus there is an extra argument at the end, which is the entity ID.
|
|
162
|
+
* Never invoked when {@link this.dependencies} is empty.
|
|
160
163
|
* see {@link EntityObserver} for more implementation detail
|
|
161
164
|
*/
|
|
162
165
|
link(component, entity) {
|
|
@@ -166,6 +169,7 @@ export class System {
|
|
|
166
169
|
/**
|
|
167
170
|
* Called automatically when an entity breaks component tuple {@link this.dependencies}.
|
|
168
171
|
* Inputs are the same as dependencies, only instances instead of classes, plus there is an extra argument at the end, which is the entity ID.
|
|
172
|
+
* Never invoked when {@link this.dependencies} is empty.
|
|
169
173
|
* see {@link EntityObserver} for more implementation detail
|
|
170
174
|
*/
|
|
171
175
|
unlink(component, entity) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenSpaceFogOfWarShader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH,kDAFW,cAAc,
|
|
1
|
+
{"version":3,"file":"screenSpaceFogOfWarShader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH,kDAFW,cAAc,CAmKxB;+BAxKyE,OAAO"}
|
|
@@ -28,16 +28,20 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
28
28
|
const float c_samplesX = 5.0;
|
|
29
29
|
const float c_samplesY = 5.0;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
const float
|
|
31
|
+
// True kernel centre is (N-1)/2, so a 5-tap kernel is centred on index 2.
|
|
32
|
+
const float c_halfSamplesX = (c_samplesX - 1.0) / 2.0;
|
|
33
|
+
const float c_halfSamplesY = (c_samplesY - 1.0) / 2.0;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// Std-dev in *sample-index* units (kernel is only c_samples wide), NOT
|
|
36
|
+
// fog-resolution units. ~1.2 gives a real bell over the 5 taps.
|
|
37
|
+
const vec2 sigma = vec2(1.2, 1.2);
|
|
35
38
|
|
|
36
39
|
const vec2 sigma2_sq = sigma*sigma*2.0;
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// Spacing between adjacent taps, in fog texels. Controls blur width and
|
|
42
|
+
// therefore how strongly the coarse fog grid is smoothed. 1.0 = one texel
|
|
43
|
+
// per tap, so a 5-tap kernel reaches +/-2 texels either side of centre.
|
|
44
|
+
const float texelSpacing = 1.0;
|
|
41
45
|
|
|
42
46
|
vec3 computeWorldPosition(){
|
|
43
47
|
// Convert screen coordinates to normalized device coordinates (NDC)
|
|
@@ -72,7 +76,8 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
72
76
|
|
|
73
77
|
float getFog(const in vec2 uv){
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
// size of one fog texel, in UV space, scaled by the desired tap spacing
|
|
80
|
+
vec2 texelSize = texelSpacing / uResolution;
|
|
76
81
|
|
|
77
82
|
float total = 0.0;
|
|
78
83
|
|
|
@@ -81,12 +86,12 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
81
86
|
for (float iy = 0.0; iy < c_samplesY; ++iy){
|
|
82
87
|
|
|
83
88
|
float fy = Gaussian(sigma2_sq.y, iy - c_halfSamplesY);
|
|
84
|
-
float offsety = (iy-c_halfSamplesY)
|
|
89
|
+
float offsety = (iy - c_halfSamplesY) * texelSize.y;
|
|
85
90
|
|
|
86
91
|
for (float ix = 0.0; ix < c_samplesX; ++ix){
|
|
87
92
|
|
|
88
93
|
float fx = Gaussian(sigma2_sq.x, ix - c_halfSamplesX);
|
|
89
|
-
float offsetx = (ix-c_halfSamplesX)
|
|
94
|
+
float offsetx = (ix - c_halfSamplesX) * texelSize.x;
|
|
90
95
|
|
|
91
96
|
float weight = fx * fy;
|
|
92
97
|
|
|
@@ -110,8 +115,13 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
110
115
|
gl_FragColor = uColor;
|
|
111
116
|
gl_FragColor.a *= fogValue;
|
|
112
117
|
|
|
113
|
-
//
|
|
118
|
+
// The fog is written to an 8-bit intermediate layer target; both channels of
|
|
119
|
+
// that target carry a quantized ramp: alpha holds fogValue, rgb holds
|
|
120
|
+
// uColor.rgb * alpha (multiplied by ROP blending). Dither each at +/-0.5 LSB
|
|
121
|
+
// of its own quantizer to break up banding. The rgb noise is attenuated by
|
|
122
|
+
// alpha in the blend, exactly matching how the rgb band amplitude scales.
|
|
114
123
|
gl_FragColor.a += gradientNoise(gl_FragCoord.xy) * (1.0 / 255.0) - (0.5 / 255.0);
|
|
124
|
+
gl_FragColor.rgb += vec3( gradientNoise(gl_FragCoord.xy + vec2(7.0, 13.0)) * (1.0 / 255.0) - (0.5 / 255.0) );
|
|
115
125
|
}
|
|
116
126
|
`;
|
|
117
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system_validate_class.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/system_validate_class.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"system_validate_class.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/system_validate_class.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qFAiGC;uBAxGsB,aAAa"}
|
|
@@ -60,8 +60,15 @@ export function system_validate_class(system) {
|
|
|
60
60
|
|
|
61
61
|
const numDependencies = dependencies.length;
|
|
62
62
|
|
|
63
|
-
if (numDependencies
|
|
64
|
-
|
|
63
|
+
if (numDependencies === 0) {
|
|
64
|
+
// no dependencies means no entity tuple is observed, so 'link'/'unlink' can never be invoked
|
|
65
|
+
if (system.link !== System.prototype.link) {
|
|
66
|
+
throw new Error(`'link' is overridden, but no dependencies are declared, so it would never be invoked`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (system.unlink !== System.prototype.unlink) {
|
|
70
|
+
throw new Error(`'unlink' is overridden, but no dependencies are declared, so it would never be invoked`);
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
if (numDependencies > 1) {
|