@react-three/tsl 10.0.0-canary.bf4b0be → 10.0.0-canary.c61791f

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/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { RootState, useStore } from '@react-three/fiber/extension';
2
2
  import * as three_webgpu from 'three/webgpu';
3
3
  import { Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, RenderPipeline, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4 } from 'three/webgpu';
4
+ import { Fn } from 'three/tsl';
4
5
 
5
6
  //* Buffer Types (useBuffers) ========================================
6
7
 
@@ -57,6 +58,40 @@ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
57
58
  */
58
59
  type NodeStore = Record<string, NodeLike | NodeRecord>
59
60
 
61
+ /** What `Fn()` returns (its members are what matters here, not its signature). */
62
+ type FnNodeLike = ReturnType<typeof Fn>
63
+
64
+ /**
65
+ * What an unregistered node read is: `useNodes().wobble`, `useNodes('fx').blur`, a creator's
66
+ * `nodes.wobble`, `state.nodes.wobble` in `useFrame`.
67
+ *
68
+ * Why it is loose: the read goes through a string name, and TypeScript cannot know what the entry
69
+ * under that name holds: a float, a vec3, a texture sample, or an `Fn()` to call. three's types
70
+ * only give operator methods to a node whose node type is known, and only an `Fn()` can be called,
71
+ * so the broad `NodeLike` allowed neither and every read needed a cast.
72
+ *
73
+ * So this has every member that any of three's nodes or an `Fn()` has, each typed `any`, and can
74
+ * be called. `nodes.wobble.mul(2)`, `material.colorNode = nodes.wobble` and `nodes.rimLightFn()`
75
+ * compile, and a misspelt member is still an error. It is a deliberate simplification: results of
76
+ * its own methods and calls are `any`.
77
+ *
78
+ * A single `as` gives it an exact type: `nodes.wobble as Node<'vec3'>`, `nodes.fn as typeof fn`.
79
+ * For exact types without casts, register the nodes (`nodes` / `nodeScopes` in `Register`) or pass
80
+ * a schema to the reader: `useNodes<{ blur: Node<'vec4'> }>('fx')`, `nodes.scope<Schema>('fx')`.
81
+ */
82
+ interface LooseNode extends TSLLooseMembers<Node<TSLNodeTypeName> | FnNodeLike> {
83
+ (...args: any[]): any
84
+ }
85
+
86
+ /**
87
+ * A root entry of an unregistered node map: a node (its members) or a scope of nodes (any other
88
+ * name), since the type cannot tell which a name holds.
89
+ */
90
+ type LooseNodeEntry = LooseNode & { readonly [name: string]: LooseNode }
91
+
92
+ /** An unregistered node map read: `state.nodes`, `useNodes()`. */
93
+ type LooseNodeStore = Record<string, LooseNodeEntry>
94
+
60
95
  //* Storage Types (useGPUStorage) ========================================
61
96
 
62
97
  /**
@@ -93,17 +128,23 @@ type StorageStore = Record<string, StorageLike | StorageRecord>
93
128
  */
94
129
  interface TSLRootState {
95
130
  /**
96
- * TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms(). Typed by name
97
- * once you register them (see `Register`), so `useFrame(({ uniforms }) => uniforms.uTime.value)`
98
- * needs no cast.
131
+ * TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms(). Each read is a
132
+ * `LooseUniformNode`, usable without casts, or typed by name once you register them (see
133
+ * `Register`), so `useFrame(({ uniforms }) => uniforms.uTime.value)` needs no cast either way.
99
134
  */
100
135
  uniforms: AppUniforms
101
- /** TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() */
102
- nodes: NodeStore
103
- /** Buffers - root-level buffers + scoped sub-objects. Use useBuffers() */
104
- buffers: BufferStore
105
- /** GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() */
106
- gpuStorage: StorageStore
136
+ /**
137
+ * TSL nodes - root-level nodes + scoped sub-objects. Use useNodes(). Each read is a `LooseNode`,
138
+ * usable without casts, or typed by name once you register your nodes (see `Register`).
139
+ */
140
+ nodes: AppNodes
141
+ /** Buffers - root-level buffers + scoped sub-objects. Use useBuffers(). Typed by name once registered */
142
+ buffers: AppBuffers
143
+ /**
144
+ * GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage().
145
+ * Typed by name once registered
146
+ */
147
+ gpuStorage: AppGPUStorage
107
148
  /** Internal: bumped by hot reloads and rebuilds to re-run creators */
108
149
  _hmrVersion: number
109
150
  /** The canvas's RenderPipeline, once useRenderPipeline created one. Per canvas, not shared. */
@@ -113,17 +154,11 @@ interface TSLRootState {
113
154
  }
114
155
 
115
156
  // Every fiber entry shares one core, and so one RootState: augmenting it through the root entry
116
- // reaches /legacy, /webgpu and /extension as well.
157
+ // reaches /legacy and /extension as well.
117
158
  declare module '@react-three/fiber' {
118
159
  interface RootState extends TSLRootState {}
119
160
  }
120
161
 
121
- // /webgpu exports WebGPURootState as RootState. Augmenting the base state it extends reaches both,
122
- // and also the stores (useStore(), get(), primaryStore) typed with the base.
123
- declare module '@react-three/fiber/webgpu' {
124
- interface BaseRootState extends TSLRootState {}
125
- }
126
-
127
162
  declare module '@react-three/fiber/extension' {
128
163
  interface RootState extends TSLRootState {}
129
164
  }
@@ -149,6 +184,16 @@ declare global {
149
184
  /** Node type accepted by broad dynamic node-store readers. */
150
185
  type TSLNodeType = three_webgpu.Node | CallableTSLNode
151
186
 
187
+ /**
188
+ * What TSL's constant constructors return: `int(1)`, `vec2(0, 1)`, `color('red')` and friends
189
+ * wrap a ConstNode in a VarNode. three's `uniform()` unwraps exactly this shape to
190
+ * `UniformNode<TNodeType, TValue>`, and so do the mappings below.
191
+ */
192
+ type TSLConstNode<TNodeType, TValue> = three_webgpu.VarNode<
193
+ TNodeType,
194
+ three_webgpu.ConstNode<TNodeType, TValue>
195
+ >
196
+
152
197
  /**
153
198
  * Derive Three's shader node type from an existing node or a supported raw input.
154
199
  * Existing InputNode generics take precedence over structural value normalization.
@@ -159,44 +204,48 @@ declare global {
159
204
  ? TNodeType
160
205
  : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
161
206
  ? TNodeType
162
- : T extends number
163
- ? 'float'
164
- : T extends boolean
165
- ? 'bool'
166
- : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
167
- ? 'color'
168
- : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
169
- ? 'vec4'
170
- : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
171
- ? 'vec3'
172
- : T extends three_webgpu.Vector2 | { x: number; y: number }
173
- ? 'vec2'
174
- : T extends three_webgpu.Matrix4
175
- ? 'mat4'
176
- : T extends three_webgpu.Matrix3
177
- ? 'mat3'
178
- : T extends three_webgpu.Matrix2
179
- ? 'mat2'
180
- : unknown
207
+ : T extends TSLConstNode<infer TNodeType, infer _TValue>
208
+ ? TNodeType
209
+ : T extends number
210
+ ? 'float'
211
+ : T extends boolean
212
+ ? 'bool'
213
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
214
+ ? 'color'
215
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
216
+ ? 'vec4'
217
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
218
+ ? 'vec3'
219
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
220
+ ? 'vec2'
221
+ : T extends three_webgpu.Matrix4
222
+ ? 'mat4'
223
+ : T extends three_webgpu.Matrix3
224
+ ? 'mat3'
225
+ : T extends three_webgpu.Matrix2
226
+ ? 'mat2'
227
+ : unknown
181
228
 
182
229
  /** Derive the normalized JavaScript value stored by a uniform node. */
183
230
  type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
184
231
  ? TValue
185
232
  : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
186
233
  ? TValue
187
- : T extends string | { r: number; g: number; b: number }
188
- ? three_webgpu.Color
189
- : T extends { x: number; y: number; z: number; w: number }
190
- ? three_webgpu.Vector4
191
- : T extends { x: number; y: number; z: number }
192
- ? three_webgpu.Vector3
193
- : T extends { x: number; y: number }
194
- ? three_webgpu.Vector2
195
- : T extends number
196
- ? number
197
- : T extends boolean
198
- ? boolean
199
- : T
234
+ : T extends TSLConstNode<infer _TNodeType, infer TValue>
235
+ ? TValue
236
+ : T extends string | { r: number; g: number; b: number }
237
+ ? three_webgpu.Color
238
+ : T extends { x: number; y: number; z: number; w: number }
239
+ ? three_webgpu.Vector4
240
+ : T extends { x: number; y: number; z: number }
241
+ ? three_webgpu.Vector3
242
+ : T extends { x: number; y: number }
243
+ ? three_webgpu.Vector2
244
+ : T extends number
245
+ ? number
246
+ : T extends boolean
247
+ ? boolean
248
+ : T
200
249
 
201
250
  /** Three's exact UniformNode with shader and value generics derived from an input. */
202
251
  type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
@@ -219,6 +268,69 @@ declare global {
219
268
  */
220
269
  type UniformStore = Record<string, UniformNode | UniformRecord>
221
270
 
271
+ //* Loose reads ==============================
272
+
273
+ /** Every shader node type three's TSL declarations type separately. */
274
+ type TSLNodeTypeName =
275
+ | 'float'
276
+ | 'int'
277
+ | 'uint'
278
+ | 'bool'
279
+ | 'vec2'
280
+ | 'vec3'
281
+ | 'vec4'
282
+ | 'ivec2'
283
+ | 'ivec3'
284
+ | 'ivec4'
285
+ | 'uvec2'
286
+ | 'uvec3'
287
+ | 'uvec4'
288
+ | 'bvec2'
289
+ | 'bvec3'
290
+ | 'bvec4'
291
+ | 'color'
292
+ | 'mat2'
293
+ | 'mat3'
294
+ | 'mat4'
295
+
296
+ /** Every member of every constituent of `T`, each typed `any`. */
297
+ type TSLLooseMembers<T> = { [K in T extends unknown ? keyof T : never]: any }
298
+
299
+ /**
300
+ * What an unregistered uniform read is: `useUniforms().uTime`, `useUniforms('fx').blur`,
301
+ * `useUniform('uTime')`, a creator's `uniforms.uTime`, `state.uniforms.uTime` in `useFrame`.
302
+ *
303
+ * Why it is loose: the read goes through a string name, and TypeScript cannot know what a
304
+ * runtime entry under that name holds. three's types only give the operator methods (`.mul`,
305
+ * `.add`, swizzles, `.toVar()`, ...) to a node whose node type is known, so `UniformNode<unknown>`
306
+ * had none of them and every read needed a cast.
307
+ *
308
+ * So this has every member that any of three's uniform nodes has (float, vec3, color, mat4, ...),
309
+ * each typed `any`. Every operator, TSL function and material slot accepts it, and a misspelt member
310
+ * (`.valeu`) is still an error. It is a deliberate simplification: results of its own methods are
311
+ * `any`, and nothing checks that `cross()` gets a vec3.
312
+ *
313
+ * It converts to an exact type with a single `as`, since every member is `any`:
314
+ * `uniforms.uColor as UniformNode<'color', Color>`, or `as Node<'vec3'>`. A node typed as a float
315
+ * uniform would cover the operators with exact result types, but three's node types are not
316
+ * comparable to one another, so it could only be cast through `unknown`.
317
+ *
318
+ * Exact types without casts: register the uniforms (`Register` in `@react-three/tsl`, which also
319
+ * catches typos in the name), or pass a schema to the reader (`useUniforms<{ blur: number }>('fx')`,
320
+ * `useUniform<Color>('uColor')`, `uniforms.scope<{ uHealth: UniformNode<'float', number> }>('player')`).
321
+ */
322
+ interface LooseUniformNode extends TSLLooseMembers<three_webgpu.UniformNode<TSLNodeTypeName, any>> {}
323
+
324
+ /**
325
+ * A root entry of an unregistered uniform map: a uniform (its members) or a scope of uniforms (any
326
+ * other name), since the type cannot tell which a name holds. `uniforms.uTime.mul(2)` and
327
+ * `uniforms.player.uHealth` both read.
328
+ */
329
+ type LooseUniformEntry = LooseUniformNode & { readonly [name: string]: LooseUniformNode }
330
+
331
+ /** An unregistered uniform map read: `state.uniforms`, `useUniforms()`. */
332
+ type LooseUniformStore = Record<string, LooseUniformEntry>
333
+
222
334
  /**
223
335
  * Helper to safely access a uniform node from the store.
224
336
  * Use this when accessing state.uniforms to get proper typing.
@@ -300,13 +412,18 @@ declare global {
300
412
  /**
301
413
  * State passed to pipeline callbacks after the active pipeline has been created.
302
414
  *
415
+ * The same state `useNodes` / `useLocalNodes` creators get: `uniforms`, `nodes`, `buffers`,
416
+ * `gpuStorage` and `textures` are the wrapped views, entries staged earlier in the render
417
+ * included. Reads through them are tracked, so a read resource that appears, is replaced or is
418
+ * removed re-runs the callbacks.
419
+ *
303
420
  * `passes.scenePass` is required here: the hook installs the default scene pass before either
304
421
  * callback runs, so callbacks can use it without a guard or a cast.
305
422
  *
306
423
  * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
307
424
  * the legacy renderer before either callback can run, so a callback never sees WebGL.
308
425
  */
309
- type RenderPipelineCallbackState = RootState & {
426
+ type RenderPipelineCallbackState = CreatorState & {
310
427
  renderPipeline: ThreeRenderPipeline
311
428
  passes: PassRecord & { scenePass: ScenePassNode }
312
429
  renderer: three_webgpu.WebGPURenderer
@@ -317,7 +434,7 @@ declare global {
317
434
  * What a callback may return to register entries into `state.passes`.
318
435
  *
319
436
  * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
320
- * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
437
+ * created, and `rebuild()`, `reset()` and unmount dispose that cached pass. A callback overwriting the
321
438
  * store entry would leave the store pointing at a node the hook never disposes, and the hook
322
439
  * disposing a pass nothing references. So returning it is a type error.
323
440
  */
@@ -329,15 +446,31 @@ declare global {
329
446
  /** Main callback - runs second to configure outputNode, create effect passes */
330
447
  type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
331
448
 
449
+ /** Options for a configuring useRenderPipeline call */
450
+ interface RenderPipelineOptions {
451
+ /**
452
+ * Keep the pipeline rendering after the component unmounts, until another component configures
453
+ * the canvas's pipeline, `reset()`, or the canvas unmounts. Off by default: an owner frees its
454
+ * pipeline and scene pass when it unmounts. A remount is a new owner with a new pipeline either way.
455
+ */
456
+ persist?: boolean
457
+ }
458
+
332
459
  /** The imperative half of useRenderPipeline's return value, present in every state */
333
460
  interface UseRenderPipelineActions {
334
461
  /** Current passes from state */
335
462
  passes: PassRecord
336
- /** Clear all passes from state */
463
+ /** Clear the passes record. From a reader, acts on the pipeline that is rendering. */
337
464
  clearPasses: () => void
338
- /** Reset RenderPipeline entirely (clears PP + passes) */
465
+ /**
466
+ * Free the pipeline and its scene pass now. The previous owner takes over, or the canvas
467
+ * goes back to plain rendering. From a reader, acts on the pipeline that is rendering.
468
+ */
339
469
  reset: () => void
340
- /** Re-run setup/main callbacks with current closure values */
470
+ /**
471
+ * Re-run setup/main callbacks with current closure values, against a fresh scene pass. From
472
+ * a reader, rebuilds the pipeline that is rendering.
473
+ */
341
474
  rebuild: () => void
342
475
  }
343
476
 
@@ -357,9 +490,9 @@ declare global {
357
490
  renderPipeline: ThreeRenderPipeline
358
491
  }
359
492
  | {
360
- /** False until the pipeline has been created */
493
+ /** False until a configuring call has created the pipeline */
361
494
  isReady: false
362
- /** Not initialized yet, or torn down by reset() */
495
+ /** No owner yet, or torn down by reset() or the owner unmounting */
363
496
  renderPipeline: null
364
497
  }
365
498
  )
@@ -381,10 +514,18 @@ type ResourceLeafGuard<T> = (value: unknown) => value is T;
381
514
  *
382
515
  * @example
383
516
  * ```tsx
517
+ * // With uniforms registered (see `Register` and the Typed Resources guide), reads are typed by name
384
518
  * useLocalNodes(({ uniforms }) => ({
385
- * wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
386
- * playerHealth: uniforms.scope('player').uHealth // Explicit scope access
387
- * }))
519
+ * wobble: sin(uniforms.uTime.mul(2)),
520
+ * playerHealth: uniforms.scope('player').uHealth, // or uniforms.player.uHealth
521
+ * }), [])
522
+ *
523
+ * // Without registration a read is loose: TSL takes it as is. A scope schema makes it exact.
524
+ * useLocalNodes(({ uniforms }) => ({ wobble: sin(uniforms.uTime.mul(2)) }), [])
525
+ * useLocalNodes(({ uniforms }) => {
526
+ * const player = uniforms.scope<{ uHealth: UniformNode<'float', number> }>('player')
527
+ * return { damage: player.uHealth.mul(2) }
528
+ * }, [])
388
529
  * ```
389
530
  */
390
531
 
@@ -393,16 +534,19 @@ type ResourceLeafGuard<T> = (value: unknown) => value is T;
393
534
  * Property access returns `T` (assumes leaf node).
394
535
  * Use `.scope(key)` for nested object access.
395
536
  *
537
+ * `TLeaf` is what a scope schema must hold (`scope<{ uHealth: UniformNode<'float', number> }>()`),
538
+ * `TRead` what a leaf reads as without one. They differ for uniforms and nodes, whose unregistered
539
+ * reads are the loose `LooseUniformNode` / `LooseNode` (see those types for why).
396
540
  */
397
- type ScopedStoreMethods<TLeaf> = {
541
+ type ScopedStoreMethods<TLeaf, TRead extends TLeaf = TLeaf> = {
398
542
  /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
399
- scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
543
+ scope<TScope extends Record<string, TLeaf> = Record<string, TRead>>(key: string): ScopedStoreType<TLeaf, TScope, TRead>;
400
544
  /** Check if a key exists in the store */
401
545
  has(key: string): boolean;
402
546
  /** Get all keys in the store */
403
547
  keys(): string[];
404
548
  };
405
- type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
549
+ type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>, TRead extends TLeaf = TLeaf> = Readonly<TEntries> & ScopedStoreMethods<TLeaf, TRead>;
406
550
  interface ScopedStoreData<TLeaf> {
407
551
  [key: string]: TLeaf | ScopedStoreData<TLeaf>;
408
552
  }
@@ -419,18 +563,18 @@ declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf:
419
563
  type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
420
564
  /** Type-safe uniform access - property access returns UniformNode, typed by name when registered */
421
565
  uniforms: CreatorUniforms;
422
- /** Type-safe node access for real, callable, and legacy structural nodes */
423
- nodes: ScopedStoreType<NodeLike>;
424
- /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
425
- buffers: ScopedStoreType<BufferLike>;
426
- /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
427
- gpuStorage: ScopedStoreType<StorageLike>;
566
+ /** Node access: each read a `LooseNode` (callable, every operator), typed by name when registered */
567
+ nodes: CreatorNodes;
568
+ /** Buffer access: typed by name when registered, BufferLike (typed arrays, attributes, nodes) otherwise */
569
+ buffers: CreatorBuffers;
570
+ /** GPU storage access: typed by name when registered, StorageLike (storage textures, nodes) otherwise */
571
+ gpuStorage: CreatorGPUStorage;
428
572
  };
429
573
 
430
574
  /**
431
- * @fileoverview Typed uniforms by registration (the TanStack Router `Register` pattern).
575
+ * @fileoverview Typed TSL resources by registration (the TanStack Router `Register` pattern).
432
576
  *
433
- * Nothing registered: every type below falls back to the loose shapes the hooks have always had.
577
+ * Nothing registered: every type below falls back to loose reads (`LooseUniformNode`, `LooseNode`).
434
578
  * Registered once, anywhere in the app:
435
579
  *
436
580
  * ```ts
@@ -450,14 +594,25 @@ type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStora
450
594
  *
451
595
  * then `useUniforms().uTime`, `useUniforms('player').uHealth`, `useUniform('uTime')`,
452
596
  * `useFrame(({ uniforms }) => uniforms.uTime)`, `useThree((s) => s.uniforms.uTime)` and a creator's
453
- * `({ uniforms }) => uniforms.uTime` are typed by name, with no generics.
597
+ * `({ uniforms }) => uniforms.uTime` are typed by name, with no generics. Nodes register the same
598
+ * way, by their node types: `nodes: { wobble: Node<'float'>; rimLight: typeof rimLightFn }` and
599
+ * `nodeScopes: { fx: { blur: Node<'vec4'> } }`, and so do buffers (`buffers` / `bufferScopes`) and
600
+ * GPU storage (`gpuStorage` / `gpuStorageScopes`). Docs: docs/webgpu/typed-resources.mdx.
601
+ *
602
+ * Unregistered reads are loose: `LooseUniformNode` / `LooseNode`, which every operator accepts and
603
+ * a single `as` makes exact (see those types for why).
454
604
  */
455
605
 
456
606
  /**
457
- * Augment this to type uniforms by name. Recognised keys:
607
+ * Augment this to type TSL resources by name. Recognised keys:
458
608
  * - `uniforms`: the root-level uniform inputs (e.g. `typeof globalUniforms`)
459
- * - `scopes`: named scopes and their inputs (e.g. `{ player: typeof playerUniforms }`)
460
- * - `strict`: `false` makes unregistered root keys loose instead of errors (default: strict)
609
+ * - `scopes`: named uniform scopes and their inputs (e.g. `{ player: typeof playerUniforms }`)
610
+ * - `nodes`: the root-level nodes by node type (e.g. `{ wobble: Node<'float'>; rim: typeof rimFn }`)
611
+ * - `nodeScopes`: named node scopes and their nodes (e.g. `{ fx: { blur: Node<'vec4'> } }`)
612
+ * - `buffers` / `bufferScopes`: buffers by name (e.g. `{ positions: StorageBufferNode<'vec3'> }`)
613
+ * - `gpuStorage` / `gpuStorageScopes`: GPU storage by name (e.g. `{ heightMap: StorageTexture }`)
614
+ * - `strict`: `false` makes unregistered root keys loose instead of errors (default: strict), for
615
+ * every resource family alike
461
616
  */
462
617
  interface Register {
463
618
  }
@@ -482,9 +637,11 @@ type TypedUniforms = UniformNodesFor<RegisteredUniforms> & {
482
637
  };
483
638
  /**
484
639
  * What `state.uniforms` and `useUniforms()` are: the registered shape (strict by default, so a typo
485
- * is an error), or today's loose `UniformStore` when nothing is registered.
640
+ * is an error), or the loose `LooseUniformStore` when nothing is registered. With `strict: false`
641
+ * an unregistered root key reads loose too. A loose read is a `LooseUniformNode`: every operator and
642
+ * material slot accepts it, and a single `as` gives it an exact type (see that type for why).
486
643
  */
487
- type AppUniforms = IsRegistered extends true ? IsStrict extends true ? TypedUniforms : TypedUniforms & UniformStore : UniformStore;
644
+ type AppUniforms = IsRegistered extends true ? IsStrict extends true ? TypedUniforms : TypedUniforms & LooseUniformStore : LooseUniformStore;
488
645
  /** Creator input at root level: new keys are free, registered keys must keep their registered type. */
489
646
  type RootUniformInput = Partial<RegisteredUniforms> & UniformInputRecord;
490
647
  /** Creator input for scope `S`: checked against the registered scope, free for any other scope. */
@@ -494,13 +651,101 @@ type RegisteredScopeUniforms<S extends keyof RegisteredScopes> = UniformNodesFor
494
651
  /** A registered root uniform's node. */
495
652
  type RegisteredUniform<K extends keyof RegisteredUniforms> = UniformNodesFor<RegisteredUniforms>[K];
496
653
  /**
497
- * `uniforms` in a creator (`useNodes(({ uniforms }) => ...)`). Unregistered: any name is a
498
- * `UniformNode`, as before. Registered: typed by name like `state.uniforms`, and `.scope(name)` is
654
+ * `uniforms` in a creator (`useNodes(({ uniforms }) => ...)`). Unregistered: any name reads as a
655
+ * `LooseUniformNode` (or, by dot access, a scope of them), and `.scope(name)` as a record of them
656
+ * unless given a schema. Registered: typed by name like `state.uniforms`, and `.scope(name)` is
499
657
  * typed for registered scopes.
500
658
  */
501
659
  type CreatorUniforms = IsRegistered extends true ? {
502
- scope<S extends keyof RegisteredScopes & string>(key: S): ScopedStoreType<UniformNode, RegisteredScopeUniforms<S>>;
503
- } & Readonly<AppUniforms> & ScopedStoreMethods<UniformNode> : ScopedStoreType<UniformNode>;
660
+ scope<S extends keyof RegisteredScopes & string>(key: S): ScopedStoreType<UniformNode, RegisteredScopeUniforms<S>, LooseUniformNode>;
661
+ } & Readonly<AppUniforms> & ScopedStoreMethods<UniformNode, LooseUniformNode> : ScopedStoreType<UniformNode, LooseUniformStore, LooseUniformNode>;
662
+ /** The registered root-level nodes, or `{}` when none are registered. */
663
+ type RegisteredNodes = Register extends {
664
+ nodes: infer N extends NodeRecord;
665
+ } ? N : {};
666
+ /** The registered node scopes and their nodes, or `{}` when none are registered. */
667
+ type RegisteredNodeScopes = Register extends {
668
+ nodeScopes: infer S extends Record<string, NodeRecord>;
669
+ } ? S : {};
670
+ type IsNodesRegistered = Register extends {
671
+ nodes: any;
672
+ } | {
673
+ nodeScopes: any;
674
+ } ? true : false;
675
+ type TypedNodes = RegisteredNodes & RegisteredNodeScopes;
676
+ /**
677
+ * What `state.nodes` and `useNodes()` are: the registered shape (strict by default, so a typo is an
678
+ * error), or the loose `LooseNodeStore` when no nodes are registered. With `strict: false` an
679
+ * unregistered root key reads loose too.
680
+ */
681
+ type AppNodes = IsNodesRegistered extends true ? IsStrict extends true ? TypedNodes : TypedNodes & LooseNodeStore : LooseNodeStore;
682
+ /** Creator output at root level: new keys are free, registered keys must keep their registered type. */
683
+ type RootNodeInput = Partial<RegisteredNodes> & NodeRecord;
684
+ /** Creator output for scope `S`: checked against the registered scope, free for any other scope. */
685
+ type ScopeNodeInput<S extends string> = S extends keyof RegisteredNodeScopes ? Partial<RegisteredNodeScopes[S]> : unknown;
686
+ /**
687
+ * `nodes` in a creator. Unregistered: any name reads as a `LooseNode` (or, by dot access, a scope of
688
+ * them). Registered: typed by name like `state.nodes`, and `.scope(name)` is typed for registered
689
+ * scopes.
690
+ */
691
+ type CreatorNodes = IsNodesRegistered extends true ? {
692
+ scope<S extends keyof RegisteredNodeScopes & string>(key: S): ScopedStoreType<NodeLike, RegisteredNodeScopes[S], LooseNode>;
693
+ } & Readonly<AppNodes> & ScopedStoreMethods<NodeLike, LooseNode> : ScopedStoreType<NodeLike, LooseNodeStore, LooseNode>;
694
+ /** A node reader's result for an explicit schema `T`, or loose nodes when none was given. */
695
+ type ReadNodes<T extends NodeRecord> = NodeRecord extends T ? Record<string, LooseNode> : T;
696
+ /** The registered root-level buffers, or `{}` when none are registered. */
697
+ type RegisteredBuffers = Register extends {
698
+ buffers: infer B extends BufferRecord;
699
+ } ? B : {};
700
+ /** The registered buffer scopes and their buffers, or `{}` when none are registered. */
701
+ type RegisteredBufferScopes = Register extends {
702
+ bufferScopes: infer S extends Record<string, BufferRecord>;
703
+ } ? S : {};
704
+ type IsBuffersRegistered = Register extends {
705
+ buffers: any;
706
+ } | {
707
+ bufferScopes: any;
708
+ } ? true : false;
709
+ type TypedBuffers = RegisteredBuffers & RegisteredBufferScopes;
710
+ /** What `state.buffers` and `useBuffers()` are: the registered shape, or `BufferStore` when none are. */
711
+ type AppBuffers = IsBuffersRegistered extends true ? IsStrict extends true ? TypedBuffers : TypedBuffers & BufferStore : BufferStore;
712
+ /** Creator output at root level: new keys are free, registered keys must keep their registered type. */
713
+ type RootBufferInput = Partial<RegisteredBuffers> & BufferRecord;
714
+ /** Creator output for scope `S`: checked against the registered scope, free for any other scope. */
715
+ type ScopeBufferInput<S extends string> = S extends keyof RegisteredBufferScopes ? Partial<RegisteredBufferScopes[S]> : unknown;
716
+ /** `buffers` in a creator: typed by name when registered, `BufferLike` reads otherwise. */
717
+ type CreatorBuffers = IsBuffersRegistered extends true ? {
718
+ scope<S extends keyof RegisteredBufferScopes & string>(key: S): ScopedStoreType<BufferLike, RegisteredBufferScopes[S]>;
719
+ } & Readonly<AppBuffers> & ScopedStoreMethods<BufferLike> : ScopedStoreType<BufferLike>;
720
+ /** The registered root-level GPU storage, or `{}` when none is registered. */
721
+ type RegisteredGPUStorage = Register extends {
722
+ gpuStorage: infer G extends StorageRecord;
723
+ } ? G : {};
724
+ /** The registered GPU storage scopes and their entries, or `{}` when none are registered. */
725
+ type RegisteredGPUStorageScopes = Register extends {
726
+ gpuStorageScopes: infer S extends Record<string, StorageRecord>;
727
+ } ? S : {};
728
+ type IsGPUStorageRegistered = Register extends {
729
+ gpuStorage: any;
730
+ } | {
731
+ gpuStorageScopes: any;
732
+ } ? true : false;
733
+ type TypedGPUStorage = RegisteredGPUStorage & RegisteredGPUStorageScopes;
734
+ /** What `state.gpuStorage` and `useGPUStorage()` are: the registered shape, or `StorageStore`. */
735
+ type AppGPUStorage = IsGPUStorageRegistered extends true ? IsStrict extends true ? TypedGPUStorage : TypedGPUStorage & StorageStore : StorageStore;
736
+ /** Creator output at root level: new keys are free, registered keys must keep their registered type. */
737
+ type RootGPUStorageInput = Partial<RegisteredGPUStorage> & StorageRecord;
738
+ /** Creator output for scope `S`: checked against the registered scope, free for any other scope. */
739
+ type ScopeGPUStorageInput<S extends string> = S extends keyof RegisteredGPUStorageScopes ? Partial<RegisteredGPUStorageScopes[S]> : unknown;
740
+ /** `gpuStorage` in a creator: typed by name when registered, `StorageLike` reads otherwise. */
741
+ type CreatorGPUStorage = IsGPUStorageRegistered extends true ? {
742
+ scope<S extends keyof RegisteredGPUStorageScopes & string>(key: S): ScopedStoreType<StorageLike, RegisteredGPUStorageScopes[S]>;
743
+ } & Readonly<AppGPUStorage> & ScopedStoreMethods<StorageLike> : ScopedStoreType<StorageLike>;
744
+ /**
745
+ * A reader's result for an explicit schema `T`, or loose uniforms when none was given (`T` is then
746
+ * its constraint, `UniformInputRecord`): `useUniforms<{ blur: number }>('fx')` vs `useUniforms('fx')`.
747
+ */
748
+ type ReadUniforms<T extends UniformInputRecord> = UniformInputRecord extends T ? Record<string, LooseUniformNode> : UniformNodesFor<T>;
504
749
 
505
750
  /** Uniforms that exist on every primary canvas from the start. See configureTSL. */
506
751
  interface TSLConfig {
@@ -544,7 +789,7 @@ declare function useUniforms<T extends RootUniformInput>(uniforms: T): UniformsW
544
789
  declare function useUniforms<T extends UniformInputRecord, S extends string>(uniforms: T & ScopeUniformInput<S>, scope: S): UniformsWithUtils<UniformNodesFor<T>>;
545
790
  declare function useUniforms(): UniformsWithUtils<AppUniforms>;
546
791
  declare function useUniforms<S extends keyof RegisteredScopes & string>(scope: S): UniformsWithUtils<RegisteredScopeUniforms<S>>;
547
- declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
792
+ declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<ReadUniforms<T>>;
548
793
  /**
549
794
  * Global rebuildUniforms function for HMR integration.
550
795
  * Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
@@ -566,8 +811,10 @@ declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?:
566
811
  * - UniformNode: existing uniforms (reused as-is)
567
812
  */
568
813
  type UniformValue = number | boolean | string | Vector2 | Vector3 | Vector4 | Color | Matrix2 | Matrix3 | Matrix4 | Node | UniformNode;
814
+ /** `useUniform<T>(name)`'s result: exact for an explicit `T`, a `LooseUniformNode` without one. */
815
+ type ReadUniform<T extends UniformValue> = UniformValue extends T ? LooseUniformNode : UniformNodeFor<T>;
569
816
  declare function useUniform<K extends keyof RegisteredUniforms & string>(name: K): RegisteredUniform<K>;
570
- declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
817
+ declare function useUniform<T extends UniformValue = UniformValue>(name: string): ReadUniform<T>;
571
818
  declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
572
819
 
573
820
  /**
@@ -597,12 +844,12 @@ type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
597
844
  clearNodes: ClearNodesFn;
598
845
  rebuildNodes: RebuildNodesFn;
599
846
  };
600
- declare function useNodes(): NodesWithUtils<NodeStore>;
601
- declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
602
- declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
603
- declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
604
- declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
605
- declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
847
+ declare function useNodes(): NodesWithUtils<AppNodes>;
848
+ declare function useNodes<S extends keyof RegisteredNodeScopes & string>(scope: S): NodesWithUtils<RegisteredNodeScopes[S]>;
849
+ declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<ReadNodes<T>>;
850
+ declare function useNodes<T extends RootNodeInput>(creator: NodeCreator<T>): NodesWithUtils<T>;
851
+ declare function useNodes<T extends NodeRecord, S extends string>(creator: (state: CreatorState) => T & ScopeNodeInput<S>, scope: S): NodesWithUtils<T>;
852
+ declare function useNodes<S extends string | undefined>(creatorOrScope: NodeCreator<NodeRecord> | string | undefined, scope: S & (string extends S ? unknown : never)): NodesWithUtils<Record<string, unknown>>;
606
853
  /**
607
854
  * Global rebuildNodes function for HMR integration.
608
855
  * Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
@@ -619,32 +866,81 @@ declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: str
619
866
  /** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
620
867
  type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
621
868
  /**
622
- * Creates local values that rebuild when uniforms, nodes, or textures change.
869
+ * The install step an install-form creator returns: it runs after commit (as a layout effect) and
870
+ * may return a cleanup, which runs before the next install and on unmount.
871
+ */
872
+ type LocalNodeInstall = () => void | (() => void);
873
+ /** A creator that builds during render and returns an install step instead of a record. */
874
+ type LocalNodeInstaller = (state: CreatorState) => LocalNodeInstall;
875
+ /**
876
+ * Creates component-local values from the rendering context and the shared TSL resources.
877
+ *
878
+ * Unlike `useNodes`, this does NOT register to the global store — nothing is published during
879
+ * render or commit. The creator runs in the render phase and is pure computation.
880
+ *
881
+ * **When the creator re-runs** is controlled by the optional `deps` array, mirroring `useMemo`:
882
+ *
883
+ * | Call | Ordinary component renders |
884
+ * | -------------------------------- | ----------------------------------------------------------- |
885
+ * | `useLocalNodes(creator)` | Re-evaluate every render, even with a `useCallback` creator |
886
+ * | `useLocalNodes(creator, [])` | Reuse the result |
887
+ * | `useLocalNodes(creator, [a, b])` | Reuse until a declared dependency changes by `Object.is` |
888
+ *
889
+ * Independently of `deps`, three things re-run the creator: a change to a shared resource the
890
+ * creator READ (replaced, removed, or appearing where it read nothing), a change of the owning
891
+ * (primary) store, and an HMR / `rebuild*` invalidation. Registrations the creator did not read
892
+ * change nothing, and writing `.value` on a uniform it read is not a change. `[]` therefore means
893
+ * "no JavaScript construction inputs", not "never rebuild". Whenever it re-runs, the creator from
894
+ * the CURRENT render is used; creator identity itself is never a rebuild trigger once an array is
895
+ * supplied.
896
+ *
897
+ * Only reads the creator makes before it returns are tracked. Inside `Fn(() => …)` the body runs
898
+ * later, while three builds the shader, so read the resource in the creator and close over it.
623
899
  *
624
- * Unlike `useNodes`, this does NOT register to the global store.
625
- * Use for component-specific nodes/values that depend on shared resources.
900
+ * `[]` is the normal case. A value that changes (a color prop, a slider) belongs in a uniform: the
901
+ * graph references the `UniformNode`, so updating its `.value` needs no rebuild and must not be a
902
+ * dependency. Declare only inputs that decide the graph's structure and cannot be uniforms: which
903
+ * node to use, a loop count, whether a branch exists.
904
+ *
905
+ * **Install form.** To put a node onto a Three object (`scene.fogNode`, `scene.backgroundNode`),
906
+ * return a function instead of a record. The creator still builds during render; the returned
907
+ * function runs after commit and may return a cleanup, which runs before the next install and on
908
+ * unmount. Mutating a Three object inside the creator itself is unsafe: React can discard a
909
+ * render, and StrictMode renders twice. The hook returns nothing in this form.
910
+ *
911
+ * ```tsx
912
+ * useLocalNodes(({ scene, uniforms }) => {
913
+ * const fogNode = fog(uniforms.fogColor, rangeFogFactor(uniforms.near, uniforms.far))
914
+ * return () => {
915
+ * scene.fogNode = fogNode
916
+ * return () => { scene.fogNode = null }
917
+ * }
918
+ * }, [])
919
+ * ```
626
920
  *
627
921
  * @example
628
922
  * ```tsx
629
- * // Destructure what you need from state
923
+ * // Resource-driven composition: no surrounding JS inputs. `uniforms.uTime` is typed by name when
924
+ * // the app registers its uniforms (see `Register`), and a loose node TSL accepts as is otherwise.
630
925
  * const { wobble, uTime } = useLocalNodes(({ uniforms, nodes }) => ({
631
926
  * wobble: sin(uniforms.uTime.mul(2)),
632
- * uTime: uniforms.uTime, // can return uniforms too
633
- * }))
634
- *
635
- * // Or access anything else from RootState
636
- * const { scaled } = useLocalNodes(({ camera, nodes }) => ({
637
- * scaled: nodes.basePos.mul(camera.zoom),
638
- * }))
639
- *
640
- * // Type-safe uniform access
641
- * const { colorNode } = useLocalNodes(({ uniforms }) => {
642
- * const uValue = uniforms.myUniform as UniformNode<number>
643
- * return { colorNode: mix(colorA, colorB, uValue) }
644
- * })
927
+ * uTime: uniforms.uTime, // can return uniforms too
928
+ * }), [])
929
+ *
930
+ * // `pattern` picks which node the graph is built from: a structural input.
931
+ * const { result } = useLocalNodes(({ nodes }) => ({
932
+ * result: pattern === 'noise' ? nodes.noise : nodes.stripes,
933
+ * }), [pattern])
934
+ *
935
+ * // An unregistered uniform works as is; one `as` gives its exact type where that matters
936
+ * const { colorNode, facing } = useLocalNodes(({ uniforms }) => {
937
+ * const uDir = uniforms.uDir as UniformNode<'vec3', Vector3> // cross() wants a vec3
938
+ * return { colorNode: mix(colorA, colorB, uniforms.myUniform), facing: cross(uDir, normalView) }
939
+ * }, [])
645
940
  * ```
646
941
  */
647
- declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
942
+ declare function useLocalNodes(creator: LocalNodeInstaller, deps?: React.DependencyList): void;
943
+ declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>, deps?: React.DependencyList): T;
648
944
 
649
945
  /**
650
946
  * A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
@@ -670,11 +966,13 @@ type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordTyp
670
966
  rebuildBuffers: RebuildBuffersFn;
671
967
  disposeBuffers: DisposeBuffersFn;
672
968
  };
673
- declare function useBuffers(): BuffersWithUtils<BufferStore>;
969
+ declare function useBuffers(): BuffersWithUtils<AppBuffers>;
970
+ declare function useBuffers<S extends keyof RegisteredBufferScopes & string>(scope: S): BuffersWithUtils<RegisteredBufferScopes[S]>;
674
971
  declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
675
972
  declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
676
- declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
677
- declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
973
+ declare function useBuffers<T extends RootBufferInput>(creator: BufferCreator<T>): BuffersWithUtils<T>;
974
+ declare function useBuffers<T extends Record<string, BufferLike>, S extends string>(creator: (state: CreatorState) => T & ScopeBufferInput<S>, scope: S): BuffersWithUtils<T>;
975
+ declare function useBuffers<S extends string | undefined>(creator: BufferCreator<BufferRecord>, scope: S & (string extends S ? unknown : never)): BuffersWithUtils<BufferRecord>;
678
976
  /**
679
977
  * Global rebuildBuffers function for HMR integration.
680
978
  * Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
@@ -712,11 +1010,13 @@ type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecord
712
1010
  rebuildStorage: RebuildStorageFn;
713
1011
  disposeStorage: DisposeStorageFn;
714
1012
  };
715
- declare function useGPUStorage(): StorageWithUtils<StorageStore>;
1013
+ declare function useGPUStorage(): StorageWithUtils<AppGPUStorage>;
1014
+ declare function useGPUStorage<S extends keyof RegisteredGPUStorageScopes & string>(scope: S): StorageWithUtils<RegisteredGPUStorageScopes[S]>;
716
1015
  declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
717
1016
  declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
718
- declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
719
- declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
1017
+ declare function useGPUStorage<T extends RootGPUStorageInput>(creator: StorageCreator<T>): StorageWithUtils<T>;
1018
+ declare function useGPUStorage<T extends Record<string, StorageLike>, S extends string>(creator: (state: CreatorState) => T & ScopeGPUStorageInput<S>, scope: S): StorageWithUtils<T>;
1019
+ declare function useGPUStorage<S extends string | undefined>(creator: StorageCreator<StorageRecord>, scope: S & (string extends S ? unknown : never)): StorageWithUtils<StorageRecord>;
720
1020
  /**
721
1021
  * Global rebuildStorage function for HMR integration.
722
1022
  * Invalidates cached storage and increments _hmrVersion to trigger re-creation.
@@ -734,11 +1034,15 @@ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: s
734
1034
  * Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
735
1035
  *
736
1036
  * Features:
737
- * - Creates RenderPipeline instance if not exists
738
- * - Creates default scenePass (no MRT) automatically
739
- * - Callbacks receive full RootState for flexibility
740
- * - No auto-cleanup on unmount - use reset() for explicit cleanup
741
- * - Scene/camera changes trigger scenePass recreation
1037
+ * - A call with a callback owns the canvas's pipeline: it creates the pipeline and a default
1038
+ * scenePass (no MRT), and frees both when it unmounts (opt out with `persist`)
1039
+ * - A call without callbacks only reads: it never creates, keeps alive or frees the pipeline
1040
+ * - The most recently mounted owner renders; when it unmounts, the previous owner takes over again
1041
+ * - StrictMode and Fast Refresh remounts reuse the graph instead of rebuilding it
1042
+ * - Callbacks receive the same state as creators (`uniforms`, `nodes`, ... wrapped, including
1043
+ * entries staged earlier in the render), and their reads are tracked as in useLocalNodes: a read
1044
+ * resource that appears, is replaced or is removed re-runs them
1045
+ * - Callbacks re-run on a hot update (`_hmrVersion`), on scene/camera change and on rebuild()
742
1046
  * - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
743
1047
  * strand its render target (and MRT attachments) on the GPU
744
1048
  * - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
@@ -746,6 +1050,7 @@ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: s
746
1050
  *
747
1051
  * @param mainCB - Main callback to configure outputNode and create effect passes
748
1052
  * @param setupCB - Optional setup callback to configure MRT on scenePass
1053
+ * @param options - `persist: true` keeps the pipeline after the component unmounts
749
1054
  * @returns { passes, renderPipeline, clearPasses, reset, rebuild }
750
1055
  *
751
1056
  * @example
@@ -771,7 +1076,7 @@ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: s
771
1076
  * const { renderPipeline, passes } = useRenderPipeline()
772
1077
  * ```
773
1078
  */
774
- declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
1079
+ declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback, options?: RenderPipelineOptions): UseRenderPipelineReturn;
775
1080
 
776
1081
  export { configureTSL, createScopedStore, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, useBuffers, useGPUStorage, useLocalNodes, useNodes, useRenderPipeline, useUniform, useUniforms };
777
- export type { AppUniforms, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, CreatorState, DisposeBuffersFn, DisposeStorageFn, LocalNodeCreator, NodeCreator, NodeLike, NodeRecord, NodeStore, NodesWithUtils, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, Register, RegisteredScopeUniforms, RegisteredScopes, RegisteredUniform, RegisteredUniforms, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RootUniformInput, ScopeUniformInput, ScopedStoreType, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, TSLConfig, TSLNode, TSLNodeLike, TSLRootState, UniformCreator, UniformValue, UniformsWithUtils };
1082
+ export type { AppBuffers, AppGPUStorage, AppNodes, AppUniforms, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, CreatorState, DisposeBuffersFn, DisposeStorageFn, FnNodeLike, LocalNodeCreator, LocalNodeInstall, LocalNodeInstaller, LooseNode, LooseNodeEntry, LooseNodeStore, NodeCreator, NodeLike, NodeRecord, NodeStore, NodesWithUtils, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, Register, RegisteredBufferScopes, RegisteredBuffers, RegisteredGPUStorage, RegisteredGPUStorageScopes, RegisteredNodeScopes, RegisteredNodes, RegisteredScopeUniforms, RegisteredScopes, RegisteredUniform, RegisteredUniforms, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RootBufferInput, RootGPUStorageInput, RootNodeInput, RootUniformInput, ScopeBufferInput, ScopeGPUStorageInput, ScopeNodeInput, ScopeUniformInput, ScopedStoreType, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, TSLConfig, TSLNode, TSLNodeLike, TSLRootState, UniformCreator, UniformValue, UniformsWithUtils };