rhodonite 0.22.1 → 0.22.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/VERSION-FILE CHANGED
@@ -1,2 +1,2 @@
1
- v0.22.1-1-g3c9f63c3b-dirty
1
+ v0.22.2-1-g4a2246a4e-dirty
2
2
  main
@@ -31,6 +31,12 @@ export declare class SceneGraphComponent extends Component {
31
31
  private __isGizmoChild;
32
32
  private __physicsComponentCountInSubtree;
33
33
  private static __hierarchyVersion;
34
+ /**
35
+ * Validity epoch of the per-node `__aabbDirtyChainEpoch` marks. Advancing it invalidates all marks at
36
+ * once; this is required whenever an AABB-dirty flag is cleared or a parent-child link changes, since
37
+ * either can break the "this node and all ancestors are AABB-dirty" guarantee of a mark.
38
+ */
39
+ private static __aabbDirtyChainEpoch;
34
40
  private _worldMatrix;
35
41
  private _worldMatrixRest;
36
42
  private _normalMatrix;
@@ -47,6 +53,16 @@ export declare class SceneGraphComponent extends Component {
47
53
  private __worldMergedAABBWithSkeletal;
48
54
  private __worldMergedAABB;
49
55
  private __isWorldAABBDirty;
56
+ /**
57
+ * Epoch at which this node was last visited by {@link setWorldAABBDirtyParentRecursively}.
58
+ * While it equals the static epoch, this node and all of its ancestors are known to be AABB-dirty,
59
+ * so an upward propagation reaching this node can stop here.
60
+ */
61
+ private __aabbDirtyChainEpoch;
62
+ /** `__worldMatrixVersion` when logicForce last ran; while unchanged, $logic has nothing to update. */
63
+ private __settledWorldMatrixVersion;
64
+ /** Component creation count when logicForce last ran (a mesh may have been attached since). */
65
+ private __settledComponentCreationCount;
50
66
  private _isVisible;
51
67
  private _isBillboard;
52
68
  private __aabbGizmo?;
@@ -223,6 +239,10 @@ export declare class SceneGraphComponent extends Component {
223
239
  * @returns The hierarchy version counter
224
240
  */
225
241
  static get hierarchyVersion(): number;
242
+ /**
243
+ * Advances the hierarchy version after a parent-child relationship changed.
244
+ */
245
+ private static __bumpHierarchyVersion;
226
246
  static get componentTID(): 4;
227
247
  /**
228
248
  * Gets the component type identifier for this instance.
@@ -257,7 +277,12 @@ export declare class SceneGraphComponent extends Component {
257
277
  */
258
278
  setWorldMatrixDirtyRecursively(): void;
259
279
  /**
260
- * Recursively marks the world AABB as dirty up the parent hierarchy.
280
+ * Marks the world AABB of this node and all of its ancestors as dirty.
281
+ *
282
+ * The walk stops at the first node already marked in the current epoch: that node and all of its
283
+ * ancestors are known to be dirty. Many nodes of the same subtree changing in one frame (e.g. every
284
+ * joint of an animated skeleton) therefore cost O(number of distinct ancestors) in total instead of
285
+ * O(changed nodes * depth).
261
286
  */
262
287
  setWorldAABBDirtyParentRecursively(): void;
263
288
  /**
@@ -15,7 +15,14 @@ export declare class ComponentRepository {
15
15
  private __renderingComponentTIDs;
16
16
  static readonly invalidComponentSID = -1;
17
17
  private __engine;
18
+ private __componentCreationCount;
18
19
  constructor(engine: Engine);
20
+ /**
21
+ * Number of components created in this repository so far, of any type.
22
+ * Consumers compare it with a remembered value to detect that components were attached to entities.
23
+ * @internal
24
+ */
25
+ get _componentCreationCount(): number;
19
26
  /**
20
27
  * Registers a component class with the repository.
21
28
  * This method associates a component class with its unique ComponentTID for later instantiation.
@@ -79,13 +79,19 @@ export declare function buildLightClustersOnCpu(dst: Float32Array, viewOffset: n
79
79
  */
80
80
  export declare function sphereIntersectsLightCluster(dst: Float32Array, viewOffset: number, layout: LightClusterViewLayout, x: number, y: number, z: number, cx: number, cy: number, cz: number, r: number): boolean;
81
81
  /**
82
- * The reference implementation of the cluster lookup of the shaders (`getLightList`).
82
+ * The reference implementation of the cluster lookup of the shaders (`getLightList` in opticalDefinition.glsl /
83
+ * .wgsl), used by the tests and by CPU-side code that needs the cluster of a position.
84
+ *
85
+ * It reads the same header rows as the shaders, so a change to one form must be made to the other.
83
86
  *
84
87
  * @returns The cluster index, or -1 when the position uses the all-light list (behind the eye plane or overflow).
85
88
  */
86
89
  export declare function computeLightClusterIndex(dst: Float32Array, viewOffset: number, px: number, py: number, pz: number): number;
87
90
  /**
88
91
  * Reads the light entries of a cluster built by `buildLightClustersOnCpu` (or by the compute shader).
92
+ *
93
+ * This follows the same two-level lookup as the shaders: the table entry gives the vec4 offset and the entry count
94
+ * of the cluster, and the entries themselves are read from the index list from that offset.
89
95
  */
90
96
  export declare function readLightClusterEntries(dst: Float32Array, viewOffset: number, layout: LightClusterViewLayout, clusterIndex: number): number[];
91
97
  /**
@@ -58,10 +58,17 @@ export declare const LightClusterLayout: {
58
58
  export declare function getLightListCapacity(maxLightListLength: number): number;
59
59
  /**
60
60
  * Returns the array length (in vec4) of the `clusteredLightData` global property.
61
+ *
62
+ * The light entries are read 4 at a time (`entries[n >> 2][n & 3]` in the shaders), so the list is rounded up to
63
+ * whole vec4s: the last vec4 can hold fewer than 4 lights.
61
64
  */
62
65
  export declare function getLightClusterGlobalPropertyLength(maxLightListLength: number): number;
63
66
  /**
64
67
  * Packs a light component SID and a shadow slot into a light entry.
68
+ *
69
+ * The SID is stored in the low 16 bits and `shadowSlot + 1` above them, so -1 (no shadow slot) is representable
70
+ * without a sign. The shaders unpack the same way: `(entry & 0xFFFF, (entry >> 16) - 1)`.
71
+ * The value stays below 2^24, so a float32 stores it exactly.
65
72
  */
66
73
  export declare function packLightEntry(lightComponentSid: number, shadowSlot: number): number;
67
74
  /**
@@ -92,6 +99,10 @@ export declare function getLightClusterViewLayout(gridSize: readonly [number, nu
92
99
  /**
93
100
  * Splits the byte range `[start, end)` into the parts outside the excluded ranges.
94
101
  *
102
+ * The rendering strategies use this to upload the whole GPU instance data in one call while leaving out the
103
+ * regions owned by the light cluster system: the cluster tables are large, are unchanged for many frames and
104
+ * may be written by compute shaders, so they are uploaded (or not uploaded) separately as dirty ranges.
105
+ *
95
106
  * @param excluded - Ranges `[start, end)` sorted by their start
96
107
  * @returns The remaining ranges `[start, end)` in ascending order
97
108
  */
@@ -37,6 +37,17 @@ export type LightClusterGpuBuildParams = {
37
37
  *
38
38
  * The data lives in the GPU instance data, so it is uploaded by the rendering strategy. `dataVersion` changes
39
39
  * whenever this system writes the data, and the strategies upload the data when it changes.
40
+ *
41
+ * ## Reading guide (the order of the code below)
42
+ * 1. `update()` is the frame entry point, called by `Engine` after the Logic stage.
43
+ * 2. `__collectLights()` turns the light components into the all-light list (`__entries`) and the light spheres
44
+ * (`__spheres`), and detects whether anything changed since the previous frame.
45
+ * 3. `__writeGlobalData()` publishes the all-light list in the `clusteredLightData` global property.
46
+ * 4. `__collectCameras()` / `__assignViews()` choose the cameras whose fragments use clusters, allocate their
47
+ * view regions (header + cluster table + light index list) and build them (`LightClusterBuilder.ts` on the CPU,
48
+ * `WebGpuLightClusterBuilder.ts` on the GPU).
49
+ * 5. The fragment shaders (`opticalDefinition.glsl` / `.wgsl`, `getLightList`) look up the cluster of a fragment
50
+ * and read its light list. The layout of both the list and the view region is in `LightClusterLayout.ts`.
40
51
  */
41
52
  export declare class LightClusterSystem {
42
53
  private __engine;
@@ -142,6 +153,13 @@ export declare class LightClusterSystem {
142
153
  * @returns true if the lists changed since the previous frame
143
154
  */
144
155
  private __collectLights;
156
+ /**
157
+ * Writes the all-light list into the `clusteredLightData` global property.
158
+ *
159
+ * The layout is documented in LightClusterLayout.ts: (allCount, globalCount, localCount, sphereBase) followed by
160
+ * the entries, 4 per vec4. The shaders read the counts from the header: `globalCount` is how many entries they
161
+ * read from the all-light list, and the rest of the list of a clustered fragment comes from the view region.
162
+ */
145
163
  private __writeGlobalData;
146
164
  /**
147
165
  * Lists the cameras of the render passes that may draw lit materials, in the order of the render passes.
@@ -166,6 +184,10 @@ export declare class LightClusterSystem {
166
184
  private __prepareViewBuild;
167
185
  /**
168
186
  * Allocates a region in the GPU instance data. Returns undefined (and disables the clusters) when it fails.
187
+ *
188
+ * The region is ordinary GPU instance data: the WebGL2 data texture / the WebGPU storage buffer. That is why the
189
+ * shaders can read the table with the same `fetchElement` / `get_clusteredLightData` accessor as any other data,
190
+ * and why the strategies have to skip it in the generic upload (see `_getExcludedByteRanges`).
169
191
  */
170
192
  private __allocate;
171
193
  }