@woosh/meep-engine 3.60.7 → 3.60.9

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 (126) hide show
  1. package/package.json +1 -1
  2. package/src/engine/graphics3/AnimationGraphSystem.d.ts +4 -1
  3. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  4. package/src/engine/graphics3/AnimationGraphSystem.js +35 -5
  5. package/src/engine/graphics3/AnimationSystem.d.ts +1 -1
  6. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  7. package/src/engine/graphics3/AnimationSystem.js +34 -5
  8. package/src/engine/graphics3/FoliageWindSystem.d.ts +2 -1
  9. package/src/engine/graphics3/FoliageWindSystem.d.ts.map +1 -1
  10. package/src/engine/graphics3/FoliageWindSystem.js +50 -3
  11. package/src/engine/graphics3/GPUFluidSystem.d.ts.map +1 -1
  12. package/src/engine/graphics3/GPUFluidSystem.js +16 -14
  13. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +2 -2
  14. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  15. package/src/engine/graphics3/GPUParticleEmitterSystem.js +84 -32
  16. package/src/engine/graphics3/LightSystem.d.ts +4 -0
  17. package/src/engine/graphics3/LightSystem.d.ts.map +1 -1
  18. package/src/engine/graphics3/LightSystem.js +23 -6
  19. package/src/engine/graphics3/MeshSkinSystem.d.ts +1 -1
  20. package/src/engine/graphics3/MeshSkinSystem.d.ts.map +1 -1
  21. package/src/engine/graphics3/MeshSkinSystem.js +50 -5
  22. package/src/engine/graphics3/MeshSystem.d.ts +1 -0
  23. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  24. package/src/engine/graphics3/MeshSystem.js +22 -8
  25. package/src/engine/graphics3/ShadedGeometrySystem.d.ts +5 -1
  26. package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
  27. package/src/engine/graphics3/ShadedGeometrySystem.js +56 -7
  28. package/src/engine/graphics3/WaterSystem.d.ts +3 -0
  29. package/src/engine/graphics3/WaterSystem.d.ts.map +1 -1
  30. package/src/engine/graphics3/WaterSystem.js +10 -2
  31. package/src/engine/graphics3/animation/AnimationClipsSink.d.ts +15 -7
  32. package/src/engine/graphics3/animation/AnimationClipsSink.d.ts.map +1 -1
  33. package/src/engine/graphics3/animation/AnimationClipsSink.js +42 -8
  34. package/src/engine/network/state/ReplicationSlotTable.d.ts +9 -5
  35. package/src/engine/network/state/ReplicationSlotTable.d.ts.map +1 -1
  36. package/src/engine/network/state/ReplicationSlotTable.js +36 -8
  37. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  38. package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
  39. package/src/generation/markers/GridActionRuleSet.js +12 -3
  40. package/src/shade/renderer/GraphicsContext.d.ts +8 -0
  41. package/src/shade/renderer/GraphicsContext.d.ts.map +1 -1
  42. package/src/shade/renderer/GraphicsContext.js +29 -0
  43. package/src/shade/renderer/Renderer.d.ts +10 -0
  44. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  45. package/src/shade/renderer/Renderer.js +22 -2
  46. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  47. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  48. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  49. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  50. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  51. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  52. package/src/shade/renderer/light/GPULightCollection.d.ts +3 -1
  53. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  54. package/src/shade/renderer/light/GPULightCollection.js +34 -9
  55. package/src/shade/renderer/light/LightCollection.d.ts +13 -3
  56. package/src/shade/renderer/light/LightCollection.d.ts.map +1 -1
  57. package/src/shade/renderer/light/LightCollection.js +19 -3
  58. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  59. package/src/shade/renderer/material/GPUMaterialManager.d.ts +22 -0
  60. package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
  61. package/src/shade/renderer/material/GPUMaterialManager.js +30 -0
  62. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts +75 -0
  63. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts.map +1 -0
  64. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.js +338 -0
  65. package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.d.ts +50 -0
  66. package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.d.ts.map +1 -0
  67. package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.js +54 -0
  68. package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts +37 -0
  69. package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts.map +1 -0
  70. package/src/shade/renderer/material/dispatch/MaterialDispatch.js +31 -0
  71. package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.d.ts +42 -0
  72. package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.d.ts.map +1 -0
  73. package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.js +132 -0
  74. package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.d.ts +21 -0
  75. package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.d.ts.map +1 -0
  76. package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.js +46 -0
  77. package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.d.ts +20 -0
  78. package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.d.ts.map +1 -0
  79. package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.js +111 -0
  80. package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.d.ts +18 -0
  81. package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.d.ts.map +1 -0
  82. package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.js +33 -0
  83. package/src/shade/renderer/material/dispatch/gbuffer_compute.d.ts +116 -0
  84. package/src/shade/renderer/material/dispatch/gbuffer_compute.d.ts.map +1 -0
  85. package/src/shade/renderer/material/dispatch/gbuffer_compute.js +249 -0
  86. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts +56 -0
  87. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts.map +1 -0
  88. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.js +315 -0
  89. package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.d.ts +16 -0
  90. package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.d.ts.map +1 -0
  91. package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.js +83 -0
  92. package/src/shade/renderer/material/dispatch/shader_material_pixel_count.d.ts +22 -0
  93. package/src/shade/renderer/material/dispatch/shader_material_pixel_count.d.ts.map +1 -0
  94. package/src/shade/renderer/material/dispatch/shader_material_pixel_count.js +133 -0
  95. package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.d.ts +14 -0
  96. package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.d.ts.map +1 -0
  97. package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.js +98 -0
  98. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts +1 -0
  99. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts.map +1 -1
  100. package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.js +11 -0
  101. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts +41 -6
  102. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  103. package/src/shade/renderer/material/standard/fragment_gbuffer.js +88 -29
  104. package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts +13 -1
  105. package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts.map +1 -1
  106. package/src/shade/renderer/material/template/ShadeMaterialTemplate.js +18 -1
  107. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  108. package/src/shade/renderer/scene/GPUSceneContext.d.ts +6 -0
  109. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  110. package/src/shade/renderer/scene/GPUSceneContext.js +17 -7
  111. package/src/shade/renderer/scene/Scene.d.ts +4 -3
  112. package/src/shade/renderer/scene/Scene.d.ts.map +1 -1
  113. package/src/shade/renderer/scene/Scene.js +54 -53
  114. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +16 -0
  115. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
  116. package/src/shade/renderer/scene/rows/GPUSceneRows.js +34 -0
  117. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.d.ts +19 -0
  118. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.d.ts.map +1 -1
  119. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.js +55 -20
  120. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.d.ts +31 -0
  121. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.d.ts.map +1 -0
  122. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.js +77 -0
  123. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +6 -0
  124. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
  125. package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +15 -1
  126. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Advanced 3D game engine",
7
7
  "type": "module",
8
8
  "author": "Alexander Goldring",
9
- "version": "3.60.7",
9
+ "version": "3.60.9",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
3
+ */
1
4
  /**
2
5
  * Drives every entity's {@link AnimationGraphController}: runs its clock, writes its clips' weights
3
6
  * and times into the entity's {@link AnimationClips}, and hands that blend to the renderer through
@@ -58,10 +61,10 @@ export class AnimationGraphSystem extends System<any> {
58
61
  * @param {number} entity
59
62
  */
60
63
  unlink(controller: AnimationGraphController, clips: AnimationClips, entity: number): void;
61
- startup(entityManager: any): Promise<void>;
62
64
  shutdown(entityManager: any): Promise<void>;
63
65
  #private;
64
66
  }
67
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
65
68
  import { System } from "../ecs/System.js";
66
69
  import { AnimationClips } from "./animation/AnimationClips.js";
67
70
  import { AnimationGraphController } from "./animation/AnimationGraphController.js";
@@ -1 +1 @@
1
- {"version":3,"file":"AnimationGraphSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/AnimationGraphSystem.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAWI;;;OAGG;IACH,oDAcC;IATG,0EAA8D;IAK9D,uIAGC;IAGL;;;;;;;;;OASG;IACH,iBAJW,wBAAwB,SACxB,cAAc,UACd,MAAM,QAShB;IAED;;;;;;;;;OASG;IACH,6BANW,cAAc,UACd,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,mBAJW,wBAAwB,SACxB,cAAc,UACd,MAAM,QAYhB;IAED,2CAEC;IAED,4CAYC;;CAoGJ;uBAxOsB,kBAAkB;+BACV,+BAA+B;yCAErB,yCAAyC;4CAJtC,iDAAiD"}
1
+ {"version":3,"file":"AnimationGraphSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/AnimationGraphSystem.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAWI;;;OAGG;IACH,oDAcC;IATG,0EAA8D;IAK9D,uIAGC;IAGL;;;;;;;;;OASG;IACH,iBAJW,wBAAwB,SACxB,cAAc,UACd,MAAM,QAShB;IAED;;;;;;;;;OASG;IACH,6BANW,cAAc,UACd,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,mBAJW,wBAAwB,SACxB,cAAc,UACd,MAAM,QAYhB;IAED,4CAEC;;CA4IJ;qCAhQY,OAAO,kCAAkC,EAAE,sBAAsB;uBANvD,kBAAkB;+BACV,+BAA+B;yCAErB,yCAAyC;4CAJtC,iDAAiD"}
@@ -5,6 +5,10 @@ import { AnimationClips } from "./animation/AnimationClips.js";
5
5
  import { AnimationClipsSink } from "./animation/AnimationClipsSink.js";
6
6
  import { AnimationGraphController } from "./animation/AnimationGraphController.js";
7
7
 
8
+ /**
9
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
10
+ */
11
+
8
12
  /**
9
13
  * Drives every entity's {@link AnimationGraphController}: runs its clock, writes its clips' weights
10
14
  * and times into the entity's {@link AnimationClips}, and hands that blend to the renderer through
@@ -116,28 +120,54 @@ export class AnimationGraphSystem extends System {
116
120
  this.#entries.delete(entity);
117
121
  }
118
122
 
119
- async startup(entityManager) {
120
- this.#sink.startup(entityManager.dataset);
123
+ async shutdown(entityManager) {
124
+ this.#detach();
121
125
  }
122
126
 
123
- async shutdown(entityManager) {
127
+ /**
128
+ * @param {EntityComponentDataset} dataset
129
+ */
130
+ handleDatasetAttached(dataset) {
131
+ this.#detach();
132
+
133
+ this.#sink.attach_dataset(dataset);
134
+ }
135
+
136
+ /**
137
+ * @param {EntityComponentDataset} dataset
138
+ */
139
+ handleDatasetDetached(dataset) {
140
+ this.#detach();
141
+ }
142
+
143
+ /**
144
+ * Let go of the dataset: every entity's graph and clips, the sink's chains, and the scene's name
145
+ * for it.
146
+ */
147
+ #detach() {
148
+ // the manager unlinks every entity before it detaches; anything left goes the same way
124
149
  for (const entry of this.#entries.values()) {
125
150
  entry.controller.unlink();
126
151
 
127
152
  if (entry.bound) {
128
- this.#sink.unbind_on_shutdown(entry.clips);
153
+ this.#sink.unbind_on_detach(entry.clips);
129
154
  }
130
155
  }
131
156
 
132
157
  this.#entries.clear();
133
158
 
134
- this.#sink.shutdown();
159
+ this.#sink.detach_dataset();
135
160
  }
136
161
 
137
162
  /**
138
163
  * @param {number} time_delta_seconds
139
164
  */
140
165
  update(time_delta_seconds) {
166
+ if (!this.#sink.attached) {
167
+ // nothing to run
168
+ return;
169
+ }
170
+
141
171
  const ecd = this.entityManager.dataset;
142
172
  const context = this.#sink.begin_update();
143
173
 
@@ -70,10 +70,10 @@ export class AnimationSystem extends System<any> {
70
70
  * @param {number} entity
71
71
  */
72
72
  unlink(component: Animation, clips: AnimationClips, entity: number): void;
73
- startup(entityManager: any): Promise<void>;
74
73
  shutdown(entityManager: any): Promise<void>;
75
74
  #private;
76
75
  }
76
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
77
77
  import { System } from "../ecs/System.js";
78
78
  import { Animation } from "../ecs/animation/Animation.js";
79
79
  import { AnimationClips } from "./animation/AnimationClips.js";
@@ -1 +1 @@
1
- {"version":3,"file":"AnimationSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/AnimationSystem.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAWI;;;OAGG;IACH,oDAcC;IATG,2DAA+C;IAK/C,wHAGC;IAGL;;;;;;;;OAQG;IACH,qBAHW,MAAM,GACJ,cAAc,CAU1B;IAED;;;;;;;;;OASG;IACH,6BANW,cAAc,UACd,MAAM,GACJ,OAAO,CAYnB;IAED;;;;;;;;OAQG;IACH,gBAJW,SAAS,SACT,cAAc,UACd,MAAM,QAQhB;IAED;;;;OAIG;IACH,kBAJW,SAAS,SACT,cAAc,UACd,MAAM,QAUhB;IAED,2CAEC;IAED,4CAUC;;CAkEJ;uBAlOsB,kBAAkB;0BADf,+BAA+B;+BAE1B,+BAA+B;4CAHlB,iDAAiD"}
1
+ {"version":3,"file":"AnimationSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/AnimationSystem.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAWI;;;OAGG;IACH,oDAcC;IATG,2DAA+C;IAK/C,wHAGC;IAGL;;;;;;;;OAQG;IACH,qBAHW,MAAM,GACJ,cAAc,CAU1B;IAED;;;;;;;;;OASG;IACH,6BANW,cAAc,UACd,MAAM,GACJ,OAAO,CAYnB;IAED;;;;;;;;OAQG;IACH,gBAJW,SAAS,SACT,cAAc,UACd,MAAM,QAQhB;IAED;;;;OAIG;IACH,kBAJW,SAAS,SACT,cAAc,UACd,MAAM,QAUhB;IAED,4CAEC;;CAuGJ;qCAzPY,OAAO,kCAAkC,EAAE,sBAAsB;uBANvD,kBAAkB;0BADf,+BAA+B;+BAE1B,+BAA+B;4CAHlB,iDAAiD"}
@@ -6,6 +6,10 @@ import { AnimationClips } from "./animation/AnimationClips.js";
6
6
  import { AnimationClipsSink } from "./animation/AnimationClipsSink.js";
7
7
  import { ClipListPlayer } from "./animation/ClipListPlayer.js";
8
8
 
9
+ /**
10
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
11
+ */
12
+
9
13
  /**
10
14
  * @type {ClipPlayback[]}
11
15
  */
@@ -147,20 +151,40 @@ export class AnimationSystem extends System {
147
151
  this.#entries.delete(entity);
148
152
  }
149
153
 
150
- async startup(entityManager) {
151
- this.#sink.startup(entityManager.dataset);
154
+ async shutdown(entityManager) {
155
+ this.#detach();
152
156
  }
153
157
 
154
- async shutdown(entityManager) {
158
+ /**
159
+ * @param {EntityComponentDataset} dataset
160
+ */
161
+ handleDatasetAttached(dataset) {
162
+ this.#detach();
163
+
164
+ this.#sink.attach_dataset(dataset);
165
+ }
166
+
167
+ /**
168
+ * @param {EntityComponentDataset} dataset
169
+ */
170
+ handleDatasetDetached(dataset) {
171
+ this.#detach();
172
+ }
173
+
174
+ /**
175
+ * Let go of the dataset: every entity's clips, the sink's chains, and the scene's name for it.
176
+ */
177
+ #detach() {
178
+ // the manager unlinks every entity before it detaches; anything left goes the same way
155
179
  for (const entry of this.#entries.values()) {
156
180
  if (entry.bound) {
157
- this.#sink.unbind_on_shutdown(entry.clips);
181
+ this.#sink.unbind_on_detach(entry.clips);
158
182
  }
159
183
  }
160
184
 
161
185
  this.#entries.clear();
162
186
 
163
- this.#sink.shutdown();
187
+ this.#sink.detach_dataset();
164
188
  }
165
189
 
166
190
  /**
@@ -206,6 +230,11 @@ export class AnimationSystem extends System {
206
230
  * @param {number} time_delta_seconds
207
231
  */
208
232
  update(time_delta_seconds) {
233
+ if (!this.#sink.attached) {
234
+ // nothing to play
235
+ return;
236
+ }
237
+
209
238
  const ecd = this.entityManager.dataset;
210
239
  const context = this.#sink.begin_update();
211
240
 
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
2
3
  * @typedef {import("../../shade/ShadeGraphicsEngine.js").ShadeGraphicsEngine} ShadeGraphicsEngine
3
4
  * @typedef {import("../../shade/PublicScene.js").PublicScene} PublicScene
4
5
  * @typedef {import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext} GPUSceneContext
@@ -33,7 +34,6 @@ export class FoliageWindSystem extends System<any> {
33
34
  */
34
35
  constructor(graphics: any, scene: any);
35
36
  dependencies: (typeof Transform64 | typeof FoliageWindRigs)[];
36
- startup(entityManager: any): Promise<void>;
37
37
  shutdown(): Promise<void>;
38
38
  /**
39
39
  * @param {FoliageWindRigs} component
@@ -50,6 +50,7 @@ export class FoliageWindSystem extends System<any> {
50
50
  update(): void;
51
51
  #private;
52
52
  }
53
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
53
54
  export type ShadeGraphicsEngine = any;
54
55
  export type PublicScene = any;
55
56
  export type GPUSceneContext = import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext;
@@ -1 +1 @@
1
- {"version":3,"file":"FoliageWindSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/FoliageWindSystem.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH;IA0BI;;;OAGG;IACH,uCAUC;IADG,8DAAkD;IAGtD,2CAYC;IAED,0BAUC;IAED;;;;OAIG;IACH,gBAJW,eAAe,cACf,WAAW,UACX,MAAM,QAkChB;IAED;;;;OAIG;IACH,mBAJW,eAAe,cACf,WAAW,UACX,MAAM,QA0BhB;IAED,eAoCC;;CA8CJ;;;8BAvPY,OAAO,+CAA+C,EAAE,eAAe;6BACvE,OAAO,0DAA0D,EAAE,cAAc;;eAKhF,eAAe;UACf,cAAc,EAAE;aAChB,eAAe,GAAC,IAAI;aACpB,UAAU,GAAC,IAAI;oBACf,MAAM;;uBAlBG,kBAAkB;4BACb,iCAAiC;gCAC7B,gCAAgC"}
1
+ {"version":3,"file":"FoliageWindSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/FoliageWindSystem.js"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH;IAoCI;;;OAGG;IACH,uCAUC;IADG,8DAAkD;IAGtD,0BAEC;IAuDD;;;;OAIG;IACH,gBAJW,eAAe,cACf,WAAW,UACX,MAAM,QAkChB;IAED;;;;OAIG;IACH,mBAJW,eAAe,cACf,WAAW,UACX,MAAM,QA0BhB;IAED,eAyCC;;CA8CJ;qCAxSY,OAAO,kCAAkC,EAAE,sBAAsB;;;8BAGjE,OAAO,+CAA+C,EAAE,eAAe;6BACvE,OAAO,0DAA0D,EAAE,cAAc;;eAKhF,eAAe;UACf,cAAc,EAAE;aAChB,eAAe,GAAC,IAAI;aACpB,UAAU,GAAC,IAAI;oBACf,MAAM;;uBAnBG,kBAAkB;4BACb,iCAAiC;gCAC7B,gCAAgC"}
@@ -5,6 +5,7 @@ import { FoliageWindRigs } from "./animation/FoliageWindRigs.js";
5
5
  import { RowChains } from "./RowChains.js";
6
6
 
7
7
  /**
8
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
8
9
  * @typedef {import("../../shade/ShadeGraphicsEngine.js").ShadeGraphicsEngine} ShadeGraphicsEngine
9
10
  * @typedef {import("../../shade/PublicScene.js").PublicScene} PublicScene
10
11
  * @typedef {import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext} GPUSceneContext
@@ -46,6 +47,16 @@ export class FoliageWindSystem extends System {
46
47
  #scene;
47
48
 
48
49
  /**
50
+ * The dataset whose rigs are registered, from {@link handleDatasetAttached} to
51
+ * {@link handleDatasetDetached}. Null while none is attached.
52
+ *
53
+ * @type {EntityComponentDataset|null}
54
+ */
55
+ #dataset = null;
56
+
57
+ /**
58
+ * Null while no dataset is attached.
59
+ *
49
60
  * @type {RowChains|null}
50
61
  */
51
62
  #chains = null;
@@ -76,8 +87,16 @@ export class FoliageWindSystem extends System {
76
87
  this.dependencies = [FoliageWindRigs, Transform64];
77
88
  }
78
89
 
79
- async startup(entityManager) {
80
- const dataset = entityManager.dataset;
90
+ async shutdown() {
91
+ this.#detach();
92
+ }
93
+
94
+ /**
95
+ * @param {EntityComponentDataset} dataset
96
+ */
97
+ handleDatasetAttached(dataset) {
98
+ this.#detach();
99
+
81
100
  const scene = this.#scene;
82
101
 
83
102
  assert.ok(
@@ -87,10 +106,27 @@ export class FoliageWindSystem extends System {
87
106
 
88
107
  scene.dataset = dataset;
89
108
 
109
+ this.#dataset = dataset;
90
110
  this.#chains = new RowChains(dataset);
91
111
  }
92
112
 
93
- async shutdown() {
113
+ /**
114
+ * @param {EntityComponentDataset} dataset
115
+ */
116
+ handleDatasetDetached(dataset) {
117
+ this.#detach();
118
+ }
119
+
120
+ /**
121
+ * Let go of the dataset: every rig's registration, the chains, and the scene's name for it.
122
+ */
123
+ #detach() {
124
+ const dataset = this.#dataset;
125
+
126
+ if (dataset === null) {
127
+ return;
128
+ }
129
+
94
130
  for (const entry of this.#entries.values()) {
95
131
  this.#unregister(entry);
96
132
  }
@@ -100,6 +136,12 @@ export class FoliageWindSystem extends System {
100
136
  this.#chains.destroy();
101
137
  this.#chains = null;
102
138
  this.#context = null;
139
+
140
+ if (this.#scene.dataset === dataset) {
141
+ this.#scene.dataset = null;
142
+ }
143
+
144
+ this.#dataset = null;
103
145
  }
104
146
 
105
147
  /**
@@ -173,6 +215,11 @@ export class FoliageWindSystem extends System {
173
215
  }
174
216
 
175
217
  update() {
218
+ if (this.#dataset === null) {
219
+ // nothing to register
220
+ return;
221
+ }
222
+
176
223
  const context = this.#graphics.scene_context(this.#scene);
177
224
 
178
225
  if (context !== this.#context) {
@@ -1 +1 @@
1
- {"version":3,"file":"GPUFluidSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/GPUFluidSystem.js"],"names":[],"mappings":"AAyCA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wCAFU,MAAM,CAE2B;AAmG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AACH;IAEI;;;;;OAKG;IACH,iCAFW,OAAO,gDAAgD,EAAE,eAAe,QAMlF;IAyID;;;OAGG;IACH,sBAHW,OAAO,qBAAqB,EAAE,cAAc,SAC5C,OAAO,qCAAqC,EAAE,KAAK,EAU7D;IAnJD,gEAAgD;IAEhD,oOAME;IA6IF;;OAEG;IACH,iEAEC;IAED;;;;;OAKG;IACH,qBAEC;IAED;;;;;OAKG;IACH,kCAEC;IAED;;;;;OAKG;IACH,+BAEC;IAED;;;;;OAKG;IACH,iCAEC;IAED;;;;;;OAMG;IACH,eAFW,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,QAQ5C;IAED;;;;;;;;;;OAUG;IACH,yBAEC;IAED;;;;;OAKG;IACH,+BAEC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAbW,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CA+ClB;IAmMD,2CAoBC;IAED,4CAaC;IA6CD;;;;OAIG;IACH,gBAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAOhB;IAED;;;;OAIG;IACH,kBAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAiBhB;IAqiBD;;;;;OAKG;IACH,eAFW,YAAY,QAetB;IAkKL;;;;;;;OAOG;IACH,2BAFU,OAAO,CAEwB;;CAVxC;AAYD;;;GAGG;AACH;IAII;;OAEG;IACH,oBAFW,cAAc,EAMxB;IADG,uBAAoB;CAkB3B;8BAxkDY,OAAO,+CAA+C,EAAE,eAAe;2BACvE,OAAO,gDAAgD,EAAE,YAAY;oCACrE,OAAO,oDAAoD,EAAE,qBAAqB;kCAClF,OAAO,kEAAkE,EAAE,mBAAmB;kCAC9F,OAAO,2DAA2D,EAAE,mBAAmB;8BACvF,OAAO,6CAA6C,EAAE,eAAe;uBAjC3D,kBAAkB;4BACb,iCAAiC;kCAWtD,2CAA2C;wCARV,iDAAiD;4CAf7C,iDAAiD;8BAiB/D,uCAAuC;yBAJ5C,4BAA4B;0BAC3B,6BAA6B;qCARlB,oDAAoD;gCADzD,uDAAuD;gCAE5B,qDAAqD;gCAJhF,mDAAmD"}
1
+ {"version":3,"file":"GPUFluidSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/GPUFluidSystem.js"],"names":[],"mappings":"AAyCA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wCAFU,MAAM,CAE2B;AAmG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AACH;IAEI;;;;;OAKG;IACH,iCAFW,OAAO,gDAAgD,EAAE,eAAe,QAMlF;IAyID;;;OAGG;IACH,sBAHW,OAAO,qBAAqB,EAAE,cAAc,SAC5C,OAAO,qCAAqC,EAAE,KAAK,EAU7D;IAnJD,gEAAgD;IAEhD,oOAME;IA6IF;;OAEG;IACH,iEAEC;IAED;;;;;OAKG;IACH,qBAEC;IAED;;;;;OAKG;IACH,kCAEC;IAED;;;;;OAKG;IACH,+BAEC;IAED;;;;;OAKG;IACH,iCAEC;IAED;;;;;;OAMG;IACH,eAFW,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,QAQ5C;IAED;;;;;;;;;;OAUG;IACH,yBAEC;IAED;;;;;OAKG;IACH,+BAEC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAbW,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CA+ClB;IAmMD,2CAOC;IAED,4CAaC;IA4DD;;;;OAIG;IACH,gBAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAOhB;IAED;;;;OAIG;IACH,kBAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAiBhB;IAqiBD;;;;;OAKG;IACH,eAFW,YAAY,QAetB;IAkKL;;;;;;;OAOG;IACH,2BAFU,OAAO,CAEwB;;CAVxC;AAYD;;;GAGG;AACH;IAII;;OAEG;IACH,oBAFW,cAAc,EAMxB;IADG,uBAAoB;CAkB3B;8BA1kDY,OAAO,+CAA+C,EAAE,eAAe;2BACvE,OAAO,gDAAgD,EAAE,YAAY;oCACrE,OAAO,oDAAoD,EAAE,qBAAqB;kCAClF,OAAO,kEAAkE,EAAE,mBAAmB;kCAC9F,OAAO,2DAA2D,EAAE,mBAAmB;8BACvF,OAAO,6CAA6C,EAAE,eAAe;uBAjC3D,kBAAkB;4BACb,iCAAiC;kCAWtD,2CAA2C;wCARV,iDAAiD;4CAf7C,iDAAiD;8BAiB/D,uCAAuC;yBAJ5C,4BAA4B;0BAC3B,6BAA6B;qCARlB,oDAAoD;gCADzD,uDAAuD;gCAE5B,qDAAqD;gCAJhF,mDAAmD"}
@@ -767,19 +767,6 @@ export class GPUFluidSystem extends System {
767
767
  async startup(entityManager) {
768
768
  this.entityManager = entityManager;
769
769
 
770
- const dataset = entityManager.dataset;
771
- const scene = this.#scene;
772
-
773
- assert.ok(
774
- scene.dataset === null || scene.dataset === undefined || dataset === null || scene.dataset === dataset,
775
- 'the scene is bound to another dataset'
776
- );
777
-
778
- if (dataset !== null) {
779
- // the scene's rows are this dataset's entities; the first system to place one says so
780
- scene.dataset = dataset;
781
- }
782
-
783
770
  this.#effectors_system = entityManager.getSystem(FluidEffectorsSystem);
784
771
 
785
772
  this.#extension = new GPUFluidExtension(this);
@@ -807,6 +794,16 @@ export class GPUFluidSystem extends System {
807
794
  handleDatasetAttached(dataset) {
808
795
  this.#detach();
809
796
 
797
+ // the scene's rows are this dataset's entities; the first system to place one says so
798
+ const scene = this.#scene;
799
+
800
+ assert.ok(
801
+ scene.dataset === null || scene.dataset === undefined || scene.dataset === dataset,
802
+ 'the scene is bound to another dataset'
803
+ );
804
+
805
+ scene.dataset = dataset;
806
+
810
807
  this.#dataset = dataset;
811
808
  this.#transform_index = dataset.computeComponentTypeIndex(Transform64);
812
809
  this.#chains = new RowChains(dataset);
@@ -823,7 +820,8 @@ export class GPUFluidSystem extends System {
823
820
  }
824
821
 
825
822
  /**
826
- * Stop watching the dataset: every entry let go, the device state and the chains with them.
823
+ * Stop watching the dataset: every entry let go, the device state and the chains with them, and
824
+ * the scene's name for it.
827
825
  */
828
826
  #detach() {
829
827
  const dataset = this.#dataset;
@@ -840,6 +838,10 @@ export class GPUFluidSystem extends System {
840
838
  this.#chains.destroy();
841
839
  this.#chains = null;
842
840
 
841
+ if (this.#scene.dataset === dataset) {
842
+ this.#scene.dataset = null;
843
+ }
844
+
843
845
  this.#dataset = null;
844
846
  this.#transform_index = -1;
845
847
  }
@@ -175,8 +175,8 @@ export class GPUParticleEmitterSystem extends System<any> {
175
175
  *
176
176
  * Refused with a warning when the entity has no Transform64 or the field is declared at another
177
177
  * width than the channel writes; a refused binding is not retried until the request changes.
178
- * The binding holds until {@link unbind_global_field}, the entity's removal, or
179
- * {@link shutdown}. It is runtime state and is not saved.
178
+ * The binding holds until {@link unbind_global_field}, the entity's removal, the detach of the
179
+ * dataset it is an entity of, or {@link shutdown}. It is runtime state and is not saved.
180
180
  *
181
181
  * @param {string} name
182
182
  * @param {number} entity an entity with a Transform64
@@ -1 +1 @@
1
- {"version":3,"file":"GPUParticleEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/GPUParticleEmitterSystem.js"],"names":[],"mappings":"AAqpCA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,+CAJW,eAAe,UACf,cAAc,GACZ,OAAO,CAyGnB;AAtvCD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;IAgFI;;;;;OAKG;IACH,sBALW,OAAO,qBAAqB,EAAE,cAAc,SAC5C,OAAO,qCAAqC,EAAE,KAAK,gEAoB7D;IArGD,6DAA6C;IAE7C;;;OAGG;IACH,OAFU,WAAW,CAEmC;IAiGxD;;;;;;OAMG;IACH,iEAEC;IAED;;;;;OAKG;IACH,kCAEC;IAED;;;;;;;;;;OAUG;IACH,mBAJW,MAAM,GACJ,eAAe,GAAC,IAAI,CAWhC;IAED;;;;;;;;;;;OAWG;IACH,cAHW,MAAM,SACN,MAAM,QA4BhB;IAED;;;;;;;;;;;;OAYG;IACH,uBAHW,MAAM,UACN,UAAU,MAAM,CAAC,QA8B3B;IAED;;;;;;;;;;;;;OAaG;IACH,wBAJW,MAAM,UACN,MAAM,WACN,MAAM,QAOhB;IAED;;;;;OAKG;IACH,0BAFW,MAAM,QAIhB;IAyQD,+BAA+B;IAC/B,YADc,QAAQ,IAAI,CAAC,CA0C1B;IAED;;;;OAIG;IACH,aAJW,cAAc,aACd,WAAW,UACX,MAAM,QAuChB;IAED;;;;OAIG;IACH,eAJW,cAAc,aACd,WAAW,UACX,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,4BAHW,MAAM,GACJ,IAAI,CAgBhB;IAoCD;;;;;;;;;;;;OAYG;IACH,eAHW,OAAO,gDAAgD,EAAE,YAAY,GACnE,IAAI,CA4ChB;;CA0UJ;;YAnnCa,MAAM;;;;YACN,cAAc;;;;eACd,WAAW;;;;aACX,eAAe,GAAC,IAAI;;;;;aACpB,OAAO,+CAA+C,EAAE,eAAe,GAAC,IAAI;gCAGjE,IAAI;;;;SACf,MAAM,GAAC,IAAI;;;;aACX,OAAO,kDAAkD,EAAE,qBAAqB,GAAC,IAAI;;;;;;;WACrF,IAAI,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,WAAS,IAAI,CAAC;QAAC,MAAM,EAAE,OAAO,yDAAyD,EAAE,cAAc,GAAC,IAAI,CAAA;KAAC,CAAC;;;;qBAKvL,OAAO,uDAAuD,EAAE,eAAe,GAAC,IAAI;;gCA3ClE,2DAA2D;+BAU5D,6CAA6C;uBARrD,kBAAkB;4BAEb,iCAAiC;4BAQjC,0CAA0C"}
1
+ {"version":3,"file":"GPUParticleEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/GPUParticleEmitterSystem.js"],"names":[],"mappings":"AAysCA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,+CAJW,eAAe,UACf,cAAc,GACZ,OAAO,CAyGnB;AA1yCD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;IAsFI;;;;;OAKG;IACH,sBALW,OAAO,qBAAqB,EAAE,cAAc,SAC5C,OAAO,qCAAqC,EAAE,KAAK,gEAoB7D;IA3GD,6DAA6C;IAE7C;;;OAGG;IACH,OAFU,WAAW,CAEmC;IAuGxD;;;;;;OAMG;IACH,iEAEC;IAED;;;;;OAKG;IACH,kCAEC;IAED;;;;;;;;;;OAUG;IACH,mBAJW,MAAM,GACJ,eAAe,GAAC,IAAI,CAWhC;IAED;;;;;;;;;;;OAWG;IACH,cAHW,MAAM,SACN,MAAM,QA4BhB;IAED;;;;;;;;;;;;OAYG;IACH,uBAHW,MAAM,UACN,UAAU,MAAM,CAAC,QA8B3B;IAED;;;;;;;;;;;;;OAaG;IACH,wBAJW,MAAM,UACN,MAAM,WACN,MAAM,QAOhB;IAED;;;;;OAKG;IACH,0BAFW,MAAM,QAIhB;IA8PD,+BAA+B;IAC/B,YADc,QAAQ,IAAI,CAAC,CAuB1B;IA0ED;;;;OAIG;IACH,aAJW,cAAc,aACd,WAAW,UACX,MAAM,QAuChB;IAED;;;;OAIG;IACH,eAJW,cAAc,aACd,WAAW,UACX,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,4BAHW,MAAM,GACJ,IAAI,CAgBhB;IAoCD;;;;;;;;;;;;OAYG;IACH,eAHW,OAAO,gDAAgD,EAAE,YAAY,GACnE,IAAI,CAgDhB;;CA0UJ;;YAvqCa,MAAM;;;;YACN,cAAc;;;;eACd,WAAW;;;;aACX,eAAe,GAAC,IAAI;;;;;aACpB,OAAO,+CAA+C,EAAE,eAAe,GAAC,IAAI;gCAGjE,IAAI;;;;SACf,MAAM,GAAC,IAAI;;;;aACX,OAAO,kDAAkD,EAAE,qBAAqB,GAAC,IAAI;;;;;;;WACrF,IAAI,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,WAAS,IAAI,CAAC;QAAC,MAAM,EAAE,OAAO,yDAAyD,EAAE,cAAc,GAAC,IAAI,CAAA;KAAC,CAAC;;;;qBAKvL,OAAO,uDAAuD,EAAE,eAAe,GAAC,IAAI;;gCA3ClE,2DAA2D;+BAU5D,6CAA6C;uBARrD,kBAAkB;4BAEb,iCAAiC;4BAQjC,0CAA0C"}
@@ -121,6 +121,12 @@ export class GPUParticleEmitterSystem extends System {
121
121
  #scene;
122
122
  /** @type {import("../asset/AssetManager.js").AssetManager} */
123
123
  #assets;
124
+ /**
125
+ * The dataset whose emitters and bound entities these are, from {@link handleDatasetAttached} to
126
+ * {@link handleDatasetDetached}. Null while none is attached.
127
+ * @type {import("../ecs/EntityComponentDataset.js").EntityComponentDataset|null}
128
+ */
129
+ #dataset = null;
124
130
  /** @type {Map<number, ParticleEmitterEntry>} */
125
131
  #entries = new Map();
126
132
  /**
@@ -342,8 +348,8 @@ export class GPUParticleEmitterSystem extends System {
342
348
  *
343
349
  * Refused with a warning when the entity has no Transform64 or the field is declared at another
344
350
  * width than the channel writes; a refused binding is not retried until the request changes.
345
- * The binding holds until {@link unbind_global_field}, the entity's removal, or
346
- * {@link shutdown}. It is runtime state and is not saved.
351
+ * The binding holds until {@link unbind_global_field}, the entity's removal, the detach of the
352
+ * dataset it is an entity of, or {@link shutdown}. It is runtime state and is not saved.
347
353
  *
348
354
  * @param {string} name
349
355
  * @param {number} entity an entity with a Transform64
@@ -435,7 +441,7 @@ export class GPUParticleEmitterSystem extends System {
435
441
  this.#let_go(scene_context, binding, false);
436
442
  };
437
443
 
438
- this.entityManager.dataset.addEntityEventListener(entity, EventType.EntityRemoved, binding.on_removed);
444
+ this.#dataset.addEntityEventListener(entity, EventType.EntityRemoved, binding.on_removed);
439
445
  }
440
446
 
441
447
  bound.set(field, binding);
@@ -486,7 +492,7 @@ export class GPUParticleEmitterSystem extends System {
486
492
  this.#let_go(scene_context, binding, false);
487
493
  };
488
494
 
489
- this.entityManager.dataset.addEntityEventListener(entity, EventType.EntityRemoved, binding.on_removed);
495
+ this.#dataset.addEntityEventListener(entity, EventType.EntityRemoved, binding.on_removed);
490
496
  }
491
497
 
492
498
  global_bound.set(name, binding);
@@ -503,7 +509,7 @@ export class GPUParticleEmitterSystem extends System {
503
509
  * @returns {boolean} whether it is live; a refusal is reported with a warning
504
510
  */
505
511
  #hold(scene_context, binding, apply) {
506
- const dataset = this.entityManager.dataset;
512
+ const dataset = this.#dataset;
507
513
  const entity = binding.entity;
508
514
 
509
515
  if (!dataset.entityExists(entity) || dataset.getComponent(entity, Transform64) === undefined) {
@@ -540,7 +546,7 @@ export class GPUParticleEmitterSystem extends System {
540
546
  }
541
547
 
542
548
  if (unlisten && binding.on_removed !== null) {
543
- this.entityManager.dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
549
+ this.#dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
544
550
  }
545
551
 
546
552
  scene_context.rows.release(binding.entity);
@@ -558,7 +564,7 @@ export class GPUParticleEmitterSystem extends System {
558
564
  #forget_bindings(entry) {
559
565
  for (const binding of entry.bound.values()) {
560
566
  if (binding.live && binding.on_removed !== null) {
561
- this.entityManager.dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
567
+ this.#dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
562
568
  }
563
569
  }
564
570
 
@@ -572,7 +578,7 @@ export class GPUParticleEmitterSystem extends System {
572
578
  #forget_global_bindings() {
573
579
  for (const binding of this.#global_bound.values()) {
574
580
  if (binding.live && binding.on_removed !== null) {
575
- this.entityManager.dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
581
+ this.#dataset.removeEntityEventListener(binding.entity, EventType.EntityRemoved, binding.on_removed);
576
582
  }
577
583
  }
578
584
 
@@ -609,17 +615,6 @@ export class GPUParticleEmitterSystem extends System {
609
615
  async startup(entityManager) {
610
616
  this.entityManager = entityManager;
611
617
 
612
- // the scene's rows are this dataset's entities; the first system to place one says so
613
- const dataset = entityManager.dataset;
614
- const scene = this.#scene;
615
-
616
- assert.ok(
617
- scene.dataset === null || scene.dataset === undefined || scene.dataset === dataset,
618
- 'the scene is bound to another dataset'
619
- );
620
-
621
- scene.dataset = dataset;
622
-
623
618
  if (!this.#assets.hasLoaderForType(GameAssetType.Image)) {
624
619
  await this.#assets.registerLoader(GameAssetType.Image, new ImageRGBADataLoader());
625
620
  }
@@ -636,6 +631,63 @@ export class GPUParticleEmitterSystem extends System {
636
631
  this.#extension = null;
637
632
  }
638
633
 
634
+ this.#detach_dataset();
635
+
636
+ // and those asked for while no dataset was attached
637
+ this.#global_bindings.clear();
638
+
639
+ this.#detach();
640
+
641
+ this.#texture?.destroy();
642
+ this.#texture = null;
643
+ this.#view = null;
644
+ this.#device = null;
645
+ this.#uploaded_version = -1;
646
+ this.#bursts.length = 0;
647
+
648
+ this.#managed_atlas.reset();
649
+ this.#create_defaults();
650
+ }
651
+
652
+ /**
653
+ * @param {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} dataset
654
+ */
655
+ handleDatasetAttached(dataset) {
656
+ this.#detach_dataset();
657
+
658
+ // the scene's rows are this dataset's entities; the first system to place one says so
659
+ const scene = this.#scene;
660
+
661
+ assert.ok(
662
+ scene.dataset === null || scene.dataset === undefined || scene.dataset === dataset,
663
+ 'the scene is bound to another dataset'
664
+ );
665
+
666
+ scene.dataset = dataset;
667
+
668
+ this.#dataset = dataset;
669
+ }
670
+
671
+ /**
672
+ * @param {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} dataset
673
+ */
674
+ handleDatasetDetached(dataset) {
675
+ this.#detach_dataset();
676
+ }
677
+
678
+ /**
679
+ * Let go of the dataset: every entity's emitter and row, the global fields' transform bindings
680
+ * and the requests for them, the bursts not yet drained — all of these name its entities, and
681
+ * the next dataset issues the same ids to others — and the scene's name for it.
682
+ */
683
+ #detach_dataset() {
684
+ const dataset = this.#dataset;
685
+
686
+ if (dataset === null) {
687
+ return;
688
+ }
689
+
690
+ // the manager unlinks every entity before it detaches; anything left goes the same way
639
691
  for (const entity of Array.from(this.#entries.keys())) {
640
692
  this.#drop(entity);
641
693
  }
@@ -660,17 +712,13 @@ export class GPUParticleEmitterSystem extends System {
660
712
  this.#global_bindings_context = null;
661
713
  this.#global_bindings.clear();
662
714
 
663
- this.#detach();
664
-
665
- this.#texture?.destroy();
666
- this.#texture = null;
667
- this.#view = null;
668
- this.#device = null;
669
- this.#uploaded_version = -1;
670
715
  this.#bursts.length = 0;
671
716
 
672
- this.#managed_atlas.reset();
673
- this.#create_defaults();
717
+ if (this.#scene.dataset === dataset) {
718
+ this.#scene.dataset = null;
719
+ }
720
+
721
+ this.#dataset = null;
674
722
  }
675
723
 
676
724
  /**
@@ -704,7 +752,7 @@ export class GPUParticleEmitterSystem extends System {
704
752
  */
705
753
  entry.on_transform_changed = () => this.#place(entry);
706
754
 
707
- this.entityManager.dataset.addEntityEventListener(
755
+ this.#dataset.addEntityEventListener(
708
756
  entity, TRANSFORM64_EVENT_CHANGE, entry.on_transform_changed
709
757
  );
710
758
 
@@ -830,7 +878,11 @@ export class GPUParticleEmitterSystem extends System {
830
878
  }
831
879
 
832
880
  this.#register(particles, frame.view.scene);
833
- this.#bind(particles, frame.view.scene);
881
+
882
+ if (this.#dataset !== null) {
883
+ // a transform binding names an entity of the attached dataset
884
+ this.#bind(particles, frame.view.scene);
885
+ }
834
886
 
835
887
  this.#upload(renderer.graphics);
836
888
 
@@ -993,7 +1045,7 @@ export class GPUParticleEmitterSystem extends System {
993
1045
  does for a primitive. Nothing draws differently for it: what it buys is that a walk over
994
1046
  the registry is readable in a debugger.
995
1047
  */
996
- const name = this.entityManager.dataset.getComponent(entry.entity, Name);
1048
+ const name = this.#dataset.getComponent(entry.entity, Name);
997
1049
 
998
1050
  emitter.name = name === undefined || name === null
999
1051
  ? `particles/entity ${entry.entity}`
@@ -1076,7 +1128,7 @@ export class GPUParticleEmitterSystem extends System {
1076
1128
  }
1077
1129
 
1078
1130
  if (entry.on_transform_changed !== null) {
1079
- this.entityManager.dataset.removeEntityEventListener(
1131
+ this.#dataset.removeEntityEventListener(
1080
1132
  entity, TRANSFORM64_EVENT_CHANGE, entry.on_transform_changed
1081
1133
  );
1082
1134
 
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
3
+ */
1
4
  /**
2
5
  * Mirrors light entities into Shade's scene.
3
6
  *
@@ -36,6 +39,7 @@ export class LightSystem extends System<any> {
36
39
  unlink(component: Light, transform: Transform64, entity: number): void;
37
40
  #private;
38
41
  }
42
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
39
43
  import { System } from "../ecs/System.js";
40
44
  import { Transform64 } from "../ecs/transform/Transform64.js";
41
45
  import { Light } from "../graphics/ecs/light/Light.js";
@@ -1 +1 @@
1
- {"version":3,"file":"LightSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/LightSystem.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH;IAgBI;;;OAGG;IACH,oDAUC;IADG,oDAAwC;IAG5C,2CAeC;IAED,4CAIC;IAED;;;;OAIG;IACH,gBAJW,KAAK,aACL,WAAW,UACX,MAAM,QAwEhB;IAED;;;;OAIG;IACH,kBAJW,KAAK,aACL,WAAW,UACX,MAAM,QAIhB;;CA4BJ;uBA5LsB,kBAAkB;4BACb,iCAAiC;sBACvC,gCAAgC"}
1
+ {"version":3,"file":"LightSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/LightSystem.js"],"names":[],"mappings":"AAWA;;GAEG;AAEH;;;;;;;;;;;;;;GAcG;AACH;IAgBI;;;OAGG;IACH,oDAUC;IADG,oDAAwC;IAG5C,2CAIC;IAED,4CAIC;IA0BD;;;;OAIG;IACH,gBAJW,KAAK,aACL,WAAW,UACX,MAAM,QAwEhB;IAED;;;;OAIG;IACH,kBAJW,KAAK,aACL,WAAW,UACX,MAAM,QAIhB;;CA4BJ;qCAtMY,OAAO,kCAAkC,EAAE,sBAAsB;uBAPvD,kBAAkB;4BACb,iCAAiC;sBACvC,gCAAgC"}