@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
@@ -9,6 +9,10 @@ import { Light } from "../graphics/ecs/light/Light.js";
9
9
  import { LightType } from "../graphics/ecs/light/LightType.js";
10
10
  import { TRANSFORM64_EVENT_CHANGE } from "../ecs/transform/TRANSFORM64_EVENT_CHANGE.js";
11
11
 
12
+ /**
13
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
14
+ */
15
+
12
16
  /**
13
17
  * Mirrors light entities into Shade's scene.
14
18
  *
@@ -59,8 +63,20 @@ export class LightSystem extends System {
59
63
  async startup(entityManager) {
60
64
  this.entityManager = entityManager;
61
65
 
66
+ this.#graphics.set_scene(this.#scene);
67
+ }
68
+
69
+ async shutdown(entityManager) {
70
+ for (const entity of Array.from(this.#entries.keys())) {
71
+ this.#drop(entity);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @param {EntityComponentDataset} dataset
77
+ */
78
+ handleDatasetAttached(dataset) {
62
79
  // the scene's rows are this dataset's entities; the first system to place one says so
63
- const dataset = entityManager.dataset;
64
80
  const scene = this.#scene;
65
81
 
66
82
  assert.ok(
@@ -69,13 +85,14 @@ export class LightSystem extends System {
69
85
  );
70
86
 
71
87
  scene.dataset = dataset;
72
-
73
- this.#graphics.set_scene(scene);
74
88
  }
75
89
 
76
- async shutdown(entityManager) {
77
- for (const entity of Array.from(this.#entries.keys())) {
78
- this.#drop(entity);
90
+ /**
91
+ * @param {EntityComponentDataset} dataset
92
+ */
93
+ handleDatasetDetached(dataset) {
94
+ if (this.#scene.dataset === dataset) {
95
+ this.#scene.dataset = null;
79
96
  }
80
97
  }
81
98
 
@@ -31,7 +31,6 @@ export class MeshSkinSystem extends System<any> {
31
31
  * @returns {Scene}
32
32
  */
33
33
  get scene(): import("../../shade/renderer/scene/Scene.js").Scene;
34
- startup(entityManager: any): Promise<void>;
35
34
  shutdown(entityManager: any): Promise<void>;
36
35
  /**
37
36
  * @param {MeshSkin} skin
@@ -48,6 +47,7 @@ export class MeshSkinSystem extends System<any> {
48
47
  #private;
49
48
  }
50
49
  export type GPUSceneContext = import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext;
50
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
51
51
  export type GraphicsEngine = import("./GraphicsEngine.js").GraphicsEngine;
52
52
  export type Scene = import("../../shade/renderer/scene/Scene.js").Scene;
53
53
  import { System } from "../ecs/System.js";
@@ -1 +1 @@
1
- {"version":3,"file":"MeshSkinSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/MeshSkinSystem.js"],"names":[],"mappings":"AAmDA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAsCI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAYf;IADG,0DAA8C;IAGlD;;OAEG;IACH,iEAEC;IAED,2CAeC;IAED,4CAUC;IAED;;;;OAIG;IACH,WAJW,QAAQ,YACR,cAAc,UACd,MAAM,QAehB;IAED;;;;OAIG;IACH,aAJW,QAAQ,YACR,cAAc,UACd,MAAM,QAIhB;;CA8HJ;8BApTY,OAAO,+CAA+C,EAAE,eAAe;6BACvE,OAAO,qBAAqB,EAAE,cAAc;oBAC5C,OAAO,qCAAqC,EAAE,KAAK;uBATzC,kBAAkB;+BAEV,2CAA2C;yBADjD,qCAAqC"}
1
+ {"version":3,"file":"MeshSkinSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/MeshSkinSystem.js"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IA8CI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAYf;IADG,0DAA8C;IAGlD;;OAEG;IACH,iEAEC;IAED,4CAEC;IA0DD;;;;OAIG;IACH,WAJW,QAAQ,YACR,cAAc,UACd,MAAM,QAehB;IAED;;;;OAIG;IACH,aAJW,QAAQ,YACR,cAAc,UACd,MAAM,QAIhB;;CAmIJ;8BAjWY,OAAO,+CAA+C,EAAE,eAAe;qCACvE,OAAO,kCAAkC,EAAE,sBAAsB;6BACjE,OAAO,qBAAqB,EAAE,cAAc;oBAC5C,OAAO,qCAAqC,EAAE,KAAK;uBAVzC,kBAAkB;+BAEV,2CAA2C;yBADjD,qCAAqC"}
@@ -7,6 +7,7 @@ import { RowChains } from "./RowChains.js";
7
7
 
8
8
  /**
9
9
  * @typedef {import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext} GPUSceneContext
10
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
10
11
  * @typedef {import("./GraphicsEngine.js").GraphicsEngine} GraphicsEngine
11
12
  * @typedef {import("../../shade/renderer/scene/Scene.js").Scene} Scene
12
13
  */
@@ -103,7 +104,15 @@ export class MeshSkinSystem extends System {
103
104
  #unregistered = [];
104
105
 
105
106
  /**
106
- * The joints' chains. Null until the system has a dataset.
107
+ * The dataset whose skins are deformed, from {@link handleDatasetAttached} to
108
+ * {@link handleDatasetDetached}. Null while none is attached.
109
+ *
110
+ * @type {EntityComponentDataset|null}
111
+ */
112
+ #dataset = null;
113
+
114
+ /**
115
+ * The joints' chains. Null while no dataset is attached.
107
116
  *
108
117
  * @type {RowChains|null}
109
118
  */
@@ -132,11 +141,17 @@ export class MeshSkinSystem extends System {
132
141
  return this.#scene;
133
142
  }
134
143
 
135
- async startup(entityManager) {
136
- this.entityManager = entityManager;
144
+ async shutdown(entityManager) {
145
+ this.#detach();
146
+ }
147
+
148
+ /**
149
+ * @param {EntityComponentDataset} dataset
150
+ */
151
+ handleDatasetAttached(dataset) {
152
+ this.#detach();
137
153
 
138
154
  // the scene's rows are this dataset's entities; the first system to place one says so
139
- const dataset = entityManager.dataset;
140
155
  const scene = this.#scene;
141
156
 
142
157
  assert.ok(
@@ -146,10 +161,29 @@ export class MeshSkinSystem extends System {
146
161
 
147
162
  scene.dataset = dataset;
148
163
 
164
+ this.#dataset = dataset;
149
165
  this.#chains = new RowChains(dataset);
150
166
  }
151
167
 
152
- async shutdown(entityManager) {
168
+ /**
169
+ * @param {EntityComponentDataset} dataset
170
+ */
171
+ handleDatasetDetached(dataset) {
172
+ this.#detach();
173
+ }
174
+
175
+ /**
176
+ * Let go of the dataset: every skin's registration, the chains, and the scene's name for it. The
177
+ * next update binds whatever is attached next as a new context.
178
+ */
179
+ #detach() {
180
+ const dataset = this.#dataset;
181
+
182
+ if (dataset === null) {
183
+ return;
184
+ }
185
+
186
+ // the manager unlinks every entity before it detaches; anything left goes the same way
153
187
  for (const entity of Array.from(this.#entries.keys())) {
154
188
  this.#drop(entity);
155
189
  }
@@ -157,6 +191,12 @@ export class MeshSkinSystem extends System {
157
191
  this.#chains.destroy();
158
192
  this.#chains = null;
159
193
 
194
+ if (this.#scene.dataset === dataset) {
195
+ this.#scene.dataset = null;
196
+ }
197
+
198
+ this.#dataset = null;
199
+
160
200
  this.#context = null;
161
201
  this.#unregistered.length = 0;
162
202
  }
@@ -196,6 +236,11 @@ export class MeshSkinSystem extends System {
196
236
  * @param {number} time_delta_seconds
197
237
  */
198
238
  update(time_delta_seconds) {
239
+ if (this.#dataset === null) {
240
+ // nothing to deform
241
+ return;
242
+ }
243
+
199
244
  const context = this.#graphics.scene_context(this.#scene);
200
245
 
201
246
  if (context === null) {
@@ -86,6 +86,7 @@ export class MeshSystem extends System<any> {
86
86
  unlink(model: SGMesh, transform: Transform64, entity: number): void;
87
87
  #private;
88
88
  }
89
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
89
90
  export type SceneBundle = import("../../shade/renderer/loader/SceneBundle.js").SceneBundle;
90
91
  export type Prefab = import("./prefab/Prefab.js").Prefab;
91
92
  export type PrefabInstance = import("./prefab/PrefabInstance.js").PrefabInstance;
@@ -1 +1 @@
1
- {"version":3,"file":"MeshSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/MeshSystem.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAmDI;;;;OAIG;IACH,sBAJW,cAAc,SACd,KAAK,eACI,MAAM,KAAG,QAAQ,WAAW,CAAC,EAchD;IADG,qDAAyC;IAG7C;;OAEG;IACH,mBAEC;IAED;;;;;;;;;;;;;;OAcG;IACH,oBAJW,MAAM,GACJ,cAAc,GAAC,IAAI,CAW/B;IAED;;;;;;;;OAQG;IACH,yBAJW,MAAM,GACJ,UAAU,CAWtB;IAED;;;;;;;;;;;;OAYG;IACH,6BALW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,UACvC,MAAM,GACJ,OAAO,CAwCnB;IAED,2CAeC;IAED,4CAMC;IA8BD;;;;OAIG;IACH,YAJW,MAAM,aACN,WAAW,UACX,MAAM,QAkBhB;IAED;;;;OAIG;IACH,cAJW,MAAM,aACN,WAAW,UACX,MAAM,QAIhB;;CA8EJ;0BAvYY,OAAO,4CAA4C,EAAE,WAAW;qBAChE,OAAO,oBAAoB,EAAE,MAAM;6BACnC,OAAO,4BAA4B,EAAE,cAAc;6BACnD,OAAO,qBAAqB,EAAE,cAAc;uBAXlC,kBAAkB;4BACb,iCAAiC;uBAEtC,6CAA6C;sBAJ9C,qCAAqC"}
1
+ {"version":3,"file":"MeshSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/MeshSystem.js"],"names":[],"mappings":"AAkDA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAmDI;;;;OAIG;IACH,sBAJW,cAAc,SACd,KAAK,eACI,MAAM,KAAG,QAAQ,WAAW,CAAC,EAchD;IADG,qDAAyC;IAG7C;;OAEG;IACH,mBAEC;IAED;;;;;;;;;;;;;;OAcG;IACH,oBAJW,MAAM,GACJ,cAAc,GAAC,IAAI,CAW/B;IAED;;;;;;;;OAQG;IACH,yBAJW,MAAM,GACJ,UAAU,CAWtB;IAED;;;;;;;;;;;;OAYG;IACH,6BALW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,UACvC,MAAM,GACJ,OAAO,CAwCnB;IAED,2CAIC;IAED,4CAMC;IAsDD;;;;OAIG;IACH,YAJW,MAAM,aACN,WAAW,UACX,MAAM,QAkBhB;IAED;;;;OAIG;IACH,cAJW,MAAM,aACN,WAAW,UACX,MAAM,QAIhB;;CA8EJ;qCArZY,OAAO,kCAAkC,EAAE,sBAAsB;0BACjE,OAAO,4CAA4C,EAAE,WAAW;qBAChE,OAAO,oBAAoB,EAAE,MAAM;6BACnC,OAAO,4BAA4B,EAAE,cAAc;6BACnD,OAAO,qBAAqB,EAAE,cAAc;uBAZlC,kBAAkB;4BACb,iCAAiC;uBAEtC,6CAA6C;sBAJ9C,qCAAqC"}
@@ -10,6 +10,7 @@ import { prefab_compile } from "./prefab/prefab_compile.js";
10
10
  import { prefab_instance_destroy, prefab_instantiate } from "./prefab/prefab_instantiate.js";
11
11
 
12
12
  /**
13
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
13
14
  * @typedef {import("../../shade/renderer/loader/SceneBundle.js").SceneBundle} SceneBundle
14
15
  * @typedef {import("./prefab/Prefab.js").Prefab} Prefab
15
16
  * @typedef {import("./prefab/PrefabInstance.js").PrefabInstance} PrefabInstance
@@ -243,8 +244,22 @@ export class MeshSystem extends System {
243
244
  async startup(entityManager) {
244
245
  this.entityManager = entityManager;
245
246
 
247
+ this.#graphics.set_scene(this.#scene);
248
+ }
249
+
250
+ async shutdown(entityManager) {
251
+ for (const entity of Array.from(this.#entries.keys())) {
252
+ this.#drop(entity);
253
+ }
254
+
255
+ this.#models.clear();
256
+ }
257
+
258
+ /**
259
+ * @param {EntityComponentDataset} dataset
260
+ */
261
+ handleDatasetAttached(dataset) {
246
262
  // the scene's rows are this dataset's entities; the first system to place one says so
247
- const dataset = entityManager.dataset;
248
263
  const scene = this.#scene;
249
264
 
250
265
  assert.ok(
@@ -253,16 +268,15 @@ export class MeshSystem extends System {
253
268
  );
254
269
 
255
270
  scene.dataset = dataset;
256
-
257
- this.#graphics.set_scene(scene);
258
271
  }
259
272
 
260
- async shutdown(entityManager) {
261
- for (const entity of Array.from(this.#entries.keys())) {
262
- this.#drop(entity);
273
+ /**
274
+ * @param {EntityComponentDataset} dataset
275
+ */
276
+ handleDatasetDetached(dataset) {
277
+ if (this.#scene.dataset === dataset) {
278
+ this.#scene.dataset = null;
263
279
  }
264
-
265
- this.#models.clear();
266
280
  }
267
281
 
268
282
  /**
@@ -27,6 +27,10 @@
27
27
  * replaced, waits: {@link update} notices the scene's GPU context arriving or changing and attaches
28
28
  * everything it holds to it. Nothing about the entity is lost meanwhile — the component and the
29
29
  * transform are the truth, and the rows are written from them.
30
+ *
31
+ * **The primitives are the attached dataset's.** The system names the dataset to the scene when the
32
+ * entity manager attaches it, and lets go of it when it is detached; while none is attached there is
33
+ * nothing to place.
30
34
  */
31
35
  export class ShadedGeometrySystem extends System<any> {
32
36
  /**
@@ -39,7 +43,6 @@ export class ShadedGeometrySystem extends System<any> {
39
43
  * @returns {Scene}
40
44
  */
41
45
  get scene(): import("../../shade/renderer/scene/Scene.js").Scene;
42
- startup(entityManager: any): Promise<void>;
43
46
  shutdown(entityManager: any): Promise<void>;
44
47
  /**
45
48
  * @param {ShadedGeometry} geometry
@@ -56,6 +59,7 @@ export class ShadedGeometrySystem extends System<any> {
56
59
  #private;
57
60
  }
58
61
  export type GPUSceneContext = import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext;
62
+ export type EntityComponentDataset = import("../ecs/EntityComponentDataset.js").EntityComponentDataset;
59
63
  export type GraphicsEngine = import("./GraphicsEngine.js").GraphicsEngine;
60
64
  export type Scene = import("../../shade/renderer/scene/Scene.js").Scene;
61
65
  import { System } from "../ecs/System.js";
@@ -1 +1 @@
1
- {"version":3,"file":"ShadedGeometrySystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/ShadedGeometrySystem.js"],"names":[],"mappings":"AAgDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAwCI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAYf;IADG,6DAAiD;IAGrD;;OAEG;IACH,iEAEC;IAED,2CAeC;IAED,4CAUC;IA4CD;;;;OAIG;IACH,eAJW,cAAc,aACd,WAAW,UACX,MAAM,QAgDhB;IAED;;;;OAIG;IACH,iBAJW,cAAc,aACd,WAAW,UACX,MAAM,QAOhB;;CAuDJ;8BAhUY,OAAO,+CAA+C,EAAE,eAAe;6BACvE,OAAO,qBAAqB,EAAE,cAAc;oBAC5C,OAAO,qCAAqC,EAAE,KAAK;uBAXzC,kBAAkB;4BACb,iCAAiC;+BAG9B,2CAA2C"}
1
+ {"version":3,"file":"ShadedGeometrySystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/ShadedGeometrySystem.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IAgDI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAYf;IADG,6DAAiD;IAGrD;;OAEG;IACH,iEAEC;IAED,4CAEC;IAyGD;;;;OAIG;IACH,eAJW,cAAc,aACd,WAAW,UACX,MAAM,QAgDhB;IAED;;;;OAIG;IACH,iBAJW,cAAc,aACd,WAAW,UACX,MAAM,QAOhB;;CAuDJ;8BAjXY,OAAO,+CAA+C,EAAE,eAAe;qCACvE,OAAO,kCAAkC,EAAE,sBAAsB;6BACjE,OAAO,qBAAqB,EAAE,cAAc;oBAC5C,OAAO,qCAAqC,EAAE,KAAK;uBAZzC,kBAAkB;4BACb,iCAAiC;+BAG9B,2CAA2C"}
@@ -9,6 +9,7 @@ import { RowChains } from "./RowChains.js";
9
9
 
10
10
  /**
11
11
  * @typedef {import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext} GPUSceneContext
12
+ * @typedef {import("../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset
12
13
  * @typedef {import("./GraphicsEngine.js").GraphicsEngine} GraphicsEngine
13
14
  * @typedef {import("../../shade/renderer/scene/Scene.js").Scene} Scene
14
15
  */
@@ -75,6 +76,10 @@ class Entry {
75
76
  * replaced, waits: {@link update} notices the scene's GPU context arriving or changing and attaches
76
77
  * everything it holds to it. Nothing about the entity is lost meanwhile — the component and the
77
78
  * transform are the truth, and the rows are written from them.
79
+ *
80
+ * **The primitives are the attached dataset's.** The system names the dataset to the scene when the
81
+ * entity manager attaches it, and lets go of it when it is detached; while none is attached there is
82
+ * nothing to place.
78
83
  */
79
84
  export class ShadedGeometrySystem extends System {
80
85
  /**
@@ -108,9 +113,17 @@ export class ShadedGeometrySystem extends System {
108
113
  */
109
114
  #unattached = [];
110
115
 
116
+ /**
117
+ * The dataset whose primitives are placed, from {@link handleDatasetAttached} to
118
+ * {@link handleDatasetDetached}. Null while none is attached.
119
+ *
120
+ * @type {EntityComponentDataset|null}
121
+ */
122
+ #dataset = null;
123
+
111
124
  /**
112
125
  * Each primitive's chain: its own row and the rows of the entities above it, followed as they
113
- * move. Null until the system has a dataset.
126
+ * move. Null while no dataset is attached.
114
127
  *
115
128
  * @type {RowChains|null}
116
129
  */
@@ -139,11 +152,17 @@ export class ShadedGeometrySystem extends System {
139
152
  return this.#scene;
140
153
  }
141
154
 
142
- async startup(entityManager) {
143
- this.entityManager = entityManager;
155
+ async shutdown(entityManager) {
156
+ this.#detach();
157
+ }
158
+
159
+ /**
160
+ * @param {EntityComponentDataset} dataset
161
+ */
162
+ handleDatasetAttached(dataset) {
163
+ this.#detach();
144
164
 
145
165
  // the scene's rows are this dataset's entities; the first system to place one says so
146
- const dataset = entityManager.dataset;
147
166
  const scene = this.#scene;
148
167
 
149
168
  assert.ok(
@@ -153,10 +172,29 @@ export class ShadedGeometrySystem extends System {
153
172
 
154
173
  scene.dataset = dataset;
155
174
 
175
+ this.#dataset = dataset;
156
176
  this.#chains = new RowChains(dataset);
157
177
  }
158
178
 
159
- async shutdown(entityManager) {
179
+ /**
180
+ * @param {EntityComponentDataset} dataset
181
+ */
182
+ handleDatasetDetached(dataset) {
183
+ this.#detach();
184
+ }
185
+
186
+ /**
187
+ * Let go of the dataset: every primitive's rows, the chains, and the scene's name for it. The
188
+ * next update binds whatever is attached next as a new context.
189
+ */
190
+ #detach() {
191
+ const dataset = this.#dataset;
192
+
193
+ if (dataset === null) {
194
+ return;
195
+ }
196
+
197
+ // the manager unlinks every entity before it detaches; anything left goes the same way
160
198
  for (const entity of Array.from(this.#entries.keys())) {
161
199
  this.#drop(entity);
162
200
  }
@@ -164,6 +202,12 @@ export class ShadedGeometrySystem extends System {
164
202
  this.#chains.destroy();
165
203
  this.#chains = null;
166
204
 
205
+ if (this.#scene.dataset === dataset) {
206
+ this.#scene.dataset = null;
207
+ }
208
+
209
+ this.#dataset = null;
210
+
167
211
  this.#context = null;
168
212
  this.#unattached.length = 0;
169
213
  }
@@ -174,6 +218,11 @@ export class ShadedGeometrySystem extends System {
174
218
  * @param {number} time_delta_seconds
175
219
  */
176
220
  update(time_delta_seconds) {
221
+ if (this.#dataset === null) {
222
+ // nothing to place
223
+ return;
224
+ }
225
+
177
226
  const context = this.#graphics.scene_context(this.#scene);
178
227
 
179
228
  if (context === null) {
@@ -245,7 +294,7 @@ export class ShadedGeometrySystem extends System {
245
294
  }
246
295
  };
247
296
 
248
- const dataset = this.entityManager.dataset;
297
+ const dataset = this.#dataset;
249
298
 
250
299
  dataset.addEntityEventListener(entity, TRANSFORM64_EVENT_CHANGE, entry.on_world_changed);
251
300
  dataset.addEntityEventListener(entity, SHADED_GEOMETRY_EVENT_CHANGE, entry.on_changed);
@@ -307,7 +356,7 @@ export class ShadedGeometrySystem extends System {
307
356
 
308
357
  this.#entries.delete(entity);
309
358
 
310
- const dataset = this.entityManager.dataset;
359
+ const dataset = this.#dataset;
311
360
 
312
361
  dataset.removeEntityEventListener(entity, TRANSFORM64_EVENT_CHANGE, entry.on_world_changed);
313
362
  dataset.removeEntityEventListener(entity, SHADED_GEOMETRY_EVENT_CHANGE, entry.on_changed);
@@ -63,6 +63,9 @@ export class WaterSystem extends System<any> {
63
63
  get queries(): GPUWaterQueries;
64
64
  startup(entityManager: any): Promise<void>;
65
65
  shutdown(): Promise<void>;
66
+ /** The scene's rows are this dataset's entities; the first system to place one says so. */
67
+ handleDatasetAttached(dataset: any): void;
68
+ handleDatasetDetached(dataset: any): void;
66
69
  link(water: any, geometry: any, transform: any, entity: any): void;
67
70
  unlink(water: any, geometry: any, transform: any, entity: any): void;
68
71
  update(dt: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"WaterSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/WaterSystem.js"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;GAeG;AACH;IAEI;;;;OAIG;IACH,iCAFW,OAAO,gDAAgD,EAAE,eAAe,QAIlF;IAqGD,uCAYC;IA/GD,6EAAqD;IACrD,4HAEkF;IA4DlF;;;;;;;;;;;MAAkD;IAClD,6BAAmC;IACnC,6CAAqD;IACrD,iBAAmC;IACnC,qCAA8D;IAE9D,0BAGC;IAJD,mBAAiC;IAMjC;;;;;;;;;;OAUG;IACH,yBAEC;IAED;;;;;OAKG;IACH,+BAEC;IAgBD,2CAOC;IAED,0BAOC;IAED,mEAsBC;IAQD,qEAiBC;IAED,sBA+BC;IA0ED;;;;OAIG;IACH,qEAUC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,sBARW,MAAM,YACN,UAAU,MAAM,CAAC,SACjB,MAAM,aACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CA+ClB;IAED;;;;;;;;;;;;;OAaG;IACH,sBARW,MAAM,aACN,UAAU,MAAM,CAAC,SACjB,MAAM,aACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CAgClB;IAuND,iCAQC;IACD,yBAGC;;CACJ;AAED;IAEI,yBAAsD;IAAvB,YAAoB;IACnD,yBAA4C;CAC/C;AACD;IAEI,yBAAsD;IAAvB,YAAoB;IACnD,yBAAoD;CACvD;uBAvtBsB,kBAAkB;4BAEb,iCAAiC;gCAI7B,kDAAkD;kBARhE,gCAAgC;uBACe,qCAAqC;4CAS1D,iDAAiD;kCAY3D,2CAA2C;gCAT7C,uDAAuD;iCAFtD,gDAAgD;gCACtB,qDAAqD;gCAGhF,mDAAmD"}
1
+ {"version":3,"file":"WaterSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/WaterSystem.js"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;GAeG;AACH;IAEI;;;;OAIG;IACH,iCAFW,OAAO,gDAAgD,EAAE,eAAe,QAIlF;IAqGD,uCAYC;IA/GD,6EAAqD;IACrD,4HAEkF;IA4DlF;;;;;;;;;;;MAAkD;IAClD,6BAAmC;IACnC,6CAAqD;IACrD,iBAAmC;IACnC,qCAA8D;IAE9D,0BAGC;IAJD,mBAAiC;IAMjC;;;;;;;;;;OAUG;IACH,yBAEC;IAED;;;;;OAKG;IACH,+BAEC;IAgBD,2CAKC;IAED,0BAOC;IAED,2FAA2F;IAC3F,0CAGC;IAED,0CAEC;IAED,mEAsBC;IAQD,qEAiBC;IAED,sBA+BC;IA0ED;;;;OAIG;IACH,qEAUC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,sBARW,MAAM,YACN,UAAU,MAAM,CAAC,SACjB,MAAM,aACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CA+ClB;IAED;;;;;;;;;;;;;OAaG;IACH,sBARW,MAAM,aACN,UAAU,MAAM,CAAC,SACjB,MAAM,aACN,MAAM,UACN,YAAY,iBACZ,MAAM,GACJ,MAAM,CAgClB;IAuND,iCAQC;IACD,yBAGC;;CACJ;AAED;IAEI,yBAAsD;IAAvB,YAAoB;IACnD,yBAA4C;CAC/C;AACD;IAEI,yBAAsD;IAAvB,YAAoB;IACnD,yBAAoD;CACvD;uBA/tBsB,kBAAkB;4BAEb,iCAAiC;gCAI7B,kDAAkD;kBARhE,gCAAgC;uBACe,qCAAqC;4CAS1D,iDAAiD;kCAY3D,2CAA2C;gCAT7C,uDAAuD;iCAFtD,gDAAgD;gCACtB,qDAAqD;gCAGhF,mDAAmD"}
@@ -193,8 +193,6 @@ export class WaterSystem extends System {
193
193
 
194
194
  async startup(entityManager) {
195
195
  this.entityManager = entityManager;
196
- assert.ok(this.#scene.dataset == null || this.#scene.dataset === entityManager.dataset, 'scene belongs to another dataset');
197
- this.#scene.dataset = entityManager.dataset;
198
196
  this.#graphics.add_transparency_channel(this.#renderer);
199
197
  this.#extensions = [this.#graphics.add_extension(new WaterExtension(this)),
200
198
  this.#graphics.add_extension(new WaterSurfaceExtension(this))];
@@ -209,6 +207,16 @@ export class WaterSystem extends System {
209
207
  this.#renderer.dispose(); this.#waves.dispose(); this.#context = null;
210
208
  }
211
209
 
210
+ /** The scene's rows are this dataset's entities; the first system to place one says so. */
211
+ handleDatasetAttached(dataset) {
212
+ assert.ok(this.#scene.dataset == null || this.#scene.dataset === dataset, 'scene belongs to another dataset');
213
+ this.#scene.dataset = dataset;
214
+ }
215
+
216
+ handleDatasetDetached(dataset) {
217
+ if (this.#scene.dataset === dataset) { this.#scene.dataset = null; }
218
+ }
219
+
212
220
  link(water, geometry, transform, entity) {
213
221
  // queue: splashes not yet staged, four numbers each (local x, z, radius, kick); staged: the batch on the
214
222
  // GPU row until a submitted frame spends it
@@ -27,22 +27,30 @@ export class AnimationClipsSink {
27
27
  */
28
28
  constructor(graphics: GraphicsEngine, scene: Scene);
29
29
  /**
30
- * Bind the scene to the dataset and start tracking row chains for keyed nodes.
30
+ * Whether the driver has a dataset attached.
31
+ *
32
+ * @returns {boolean}
33
+ */
34
+ get attached(): boolean;
35
+ /**
36
+ * Bind the scene to the dataset the driver was attached to, and start tracking row chains for
37
+ * keyed nodes.
31
38
  *
32
39
  * @param {EntityComponentDataset} dataset
33
40
  */
34
- startup(dataset: EntityComponentDataset): void;
41
+ attach_dataset(dataset: EntityComponentDataset): void;
35
42
  /**
36
- * Release the GPU registration and playback state of one {@link AnimationClips} during system
37
- * shutdown, leaving row-chain teardown to {@link shutdown}.
43
+ * Release the GPU registration and playback state of one {@link AnimationClips} as the dataset
44
+ * goes, leaving row-chain teardown to {@link detach_dataset}.
38
45
  *
39
46
  * @param {AnimationClips} clips
40
47
  */
41
- unbind_on_shutdown(clips: AnimationClips): void;
48
+ unbind_on_detach(clips: AnimationClips): void;
42
49
  /**
43
- * Tear down the row chains on system shutdown.
50
+ * Tear down the row chains and the scene's name for the dataset, as the driver's dataset is
51
+ * detached. Nothing happens while none is attached.
44
52
  */
45
- shutdown(): void;
53
+ detach_dataset(): void;
46
54
  /**
47
55
  * Bind the row chains to the current GPU context's rows and answer that context.
48
56
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AnimationClipsSink.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics3/animation/AnimationClipsSink.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH;IAoBI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAQf;IAED;;;;OAIG;IACH,iBAFW,sBAAsB,QAchC;IAED;;;;;OAKG;IACH,0BAFW,cAAc,QAMxB;IAED;;OAEG;IACH,iBAGC;IAED;;;;;;;OAOG;IACH,gBAFa,eAAe,GAAC,IAAI,CAShC;IAED;;;;;;;;OAQG;IACH,YAFW,cAAc,QAUxB;IAED;;;;;;OAMG;IACH,eAFW,cAAc,QAYxB;IAED;;;;;;;OAOG;IACH,YAJW,cAAc,WACd,eAAe,GAAC,IAAI,iBACpB,OAAO,QAmBjB;;CAyBJ;qCAtMY,OAAO,qCAAqC,EAAE,sBAAsB;8BACpE,OAAO,kDAAkD,EAAE,eAAe;oBAC1E,OAAO,wCAAwC,EAAE,KAAK;6BACtD,OAAO,sBAAsB,EAAE,cAAc;6BAC7C,OAAO,qBAAqB,EAAE,cAAc"}
1
+ {"version":3,"file":"AnimationClipsSink.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics3/animation/AnimationClipsSink.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH;IA4BI;;;OAGG;IACH,sBAHW,cAAc,SACd,KAAK,EAQf;IAED;;;;OAIG;IACH,wBAEC;IAED;;;;;OAKG;IACH,wBAFW,sBAAsB,QAiBhC;IAED;;;;;OAKG;IACH,wBAFW,cAAc,QAMxB;IAED;;;OAGG;IACH,uBAeC;IAED;;;;;;;OAOG;IACH,gBAFa,eAAe,GAAC,IAAI,CAShC;IAED;;;;;;;;OAQG;IACH,YAFW,cAAc,QAUxB;IAED;;;;;;OAMG;IACH,eAFW,cAAc,QAYxB;IAED;;;;;;;OAOG;IACH,YAJW,cAAc,WACd,eAAe,GAAC,IAAI,iBACpB,OAAO,QAmBjB;;CAyBJ;qCAxOY,OAAO,qCAAqC,EAAE,sBAAsB;8BACpE,OAAO,kDAAkD,EAAE,eAAe;oBAC1E,OAAO,wCAAwC,EAAE,KAAK;6BACtD,OAAO,sBAAsB,EAAE,cAAc;6BAC7C,OAAO,qBAAqB,EAAE,cAAc"}
@@ -40,7 +40,15 @@ export class AnimationClipsSink {
40
40
  #scene;
41
41
 
42
42
  /**
43
- * The chains of the nodes the clips key. Null until the driver has a dataset.
43
+ * The driver's dataset, from {@link attach_dataset} to {@link detach_dataset}. Null while none
44
+ * is attached.
45
+ *
46
+ * @type {EntityComponentDataset|null}
47
+ */
48
+ #dataset = null;
49
+
50
+ /**
51
+ * The chains of the nodes the clips key. Null while no dataset is attached.
44
52
  *
45
53
  * @type {RowChains|null}
46
54
  */
@@ -59,11 +67,23 @@ export class AnimationClipsSink {
59
67
  }
60
68
 
61
69
  /**
62
- * Bind the scene to the dataset and start tracking row chains for keyed nodes.
70
+ * Whether the driver has a dataset attached.
71
+ *
72
+ * @returns {boolean}
73
+ */
74
+ get attached() {
75
+ return this.#dataset !== null;
76
+ }
77
+
78
+ /**
79
+ * Bind the scene to the dataset the driver was attached to, and start tracking row chains for
80
+ * keyed nodes.
63
81
  *
64
82
  * @param {EntityComponentDataset} dataset
65
83
  */
66
- startup(dataset) {
84
+ attach_dataset(dataset) {
85
+ this.detach_dataset();
86
+
67
87
  // the scene's rows are this dataset's entities; the first system to place one says so
68
88
  const scene = this.#scene;
69
89
 
@@ -74,27 +94,41 @@ export class AnimationClipsSink {
74
94
 
75
95
  scene.dataset = dataset;
76
96
 
97
+ this.#dataset = dataset;
77
98
  this.#chains = new RowChains(dataset);
78
99
  }
79
100
 
80
101
  /**
81
- * Release the GPU registration and playback state of one {@link AnimationClips} during system
82
- * shutdown, leaving row-chain teardown to {@link shutdown}.
102
+ * Release the GPU registration and playback state of one {@link AnimationClips} as the dataset
103
+ * goes, leaving row-chain teardown to {@link detach_dataset}.
83
104
  *
84
105
  * @param {AnimationClips} clips
85
106
  */
86
- unbind_on_shutdown(clips) {
107
+ unbind_on_detach(clips) {
87
108
  this.#release_registration(clips);
88
109
 
89
110
  clips.unbind();
90
111
  }
91
112
 
92
113
  /**
93
- * Tear down the row chains on system shutdown.
114
+ * Tear down the row chains and the scene's name for the dataset, as the driver's dataset is
115
+ * detached. Nothing happens while none is attached.
94
116
  */
95
- shutdown() {
117
+ detach_dataset() {
118
+ const dataset = this.#dataset;
119
+
120
+ if (dataset === null) {
121
+ return;
122
+ }
123
+
96
124
  this.#chains.destroy();
97
125
  this.#chains = null;
126
+
127
+ if (this.#scene.dataset === dataset) {
128
+ this.#scene.dataset = null;
129
+ }
130
+
131
+ this.#dataset = null;
98
132
  }
99
133
 
100
134
  /**
@@ -10,8 +10,9 @@
10
10
  * match the live `(network_id=5, generation=3)` slot, so use-after-free can
11
11
  * be detected at parse time on the receiving peer.
12
12
  *
13
- * Storage is two parallel typed arrays indexed by `network_id`, plus a small
14
- * free-list of reusable IDs. No JS object per slot.
13
+ * Storage is three parallel typed arrays indexed by `network_id` (entity,
14
+ * generation, index in the free list), plus a free-list of reusable IDs.
15
+ * No JS object per slot.
15
16
  *
16
17
  * @author Alex Goldring
17
18
  * @copyright Company Named Limited (c) 2026
@@ -33,8 +34,10 @@ export class ReplicationSlotTable {
33
34
  allocate(entity_id: number): number;
34
35
  /**
35
36
  * Allocate using an explicit network_id (for the receiving peer that takes its
36
- * IDs from the wire). Bumps the slot's generation if it was reused. Throws
37
- * if the slot is currently in use.
37
+ * IDs from the wire). The id may be one this peer freed and the sender has
38
+ * since recycled; it is taken off the free list, so {@link allocate} will not
39
+ * hand it out. The slot keeps the generation {@link free} gave it. Throws if
40
+ * the slot is currently in use.
38
41
  *
39
42
  * @param {number} network_id
40
43
  * @param {number} entity_id
@@ -42,7 +45,8 @@ export class ReplicationSlotTable {
42
45
  allocate_at(network_id: number, entity_id: number): void;
43
46
  /**
44
47
  * Free the slot for `network_id`. Bumps the slot's generation. Slot becomes
45
- * available for re-allocation.
48
+ * available for re-allocation. Freeing a slot that is not in use, including
49
+ * one past the table's storage, does nothing.
46
50
  *
47
51
  * @param {number} network_id
48
52
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ReplicationSlotTable.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/state/ReplicationSlotTable.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH;IAkBI;;OAEG;IACH,mCAFW;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,EA8BvC;IAED;;;;;;OAMG;IACH,oBAHW,MAAM,GACJ,MAAM,CAqBlB;IAED;;;;;;;OAOG;IACH,wBAHW,MAAM,aACN,MAAM,QAoBhB;IAED;;;;;OAKG;IACH,iBAFW,MAAM,QAYhB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;OAGG;IACH,cAFa,MAAM,CAIlB;;CAkBJ"}
1
+ {"version":3,"file":"ReplicationSlotTable.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/state/ReplicationSlotTable.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAmBI;;OAEG;IACH,mCAFW;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,EAqCvC;IAED;;;;;;OAMG;IACH,oBAHW,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;;OASG;IACH,wBAHW,MAAM,aACN,MAAM,QA2BhB;IAED;;;;;;OAMG;IACH,iBAFW,MAAM,QAgBhB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;OAGG;IACH,cAFa,MAAM,CAIlB;;CAsBJ"}