@react-three/fiber 10.0.0-canary.d6fdf72 → 10.0.0-canary.d91831d

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.
@@ -1,5 +1,6 @@
1
+ import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
1
2
  import * as three_webgpu from 'three/webgpu';
2
- import { RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera, WebGPURendererParameters } from 'three/webgpu';
3
+ import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera, Matrix2, WebGPURendererParameters } from 'three/webgpu';
3
4
  import { Inspector } from 'three/addons/inspector/Inspector.js';
4
5
  import * as THREE$1 from 'three';
5
6
  import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
@@ -7,25 +8,12 @@ import * as React$1 from 'react';
7
8
  import { ReactNode, Component, RefObject, JSX } from 'react';
8
9
  import { StoreApi } from 'zustand';
9
10
  import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
11
+ import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
12
+ export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
10
13
  import { Options } from 'react-use-measure';
11
14
  import * as react_jsx_runtime from 'react/jsx-runtime';
12
- import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
13
15
  import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
14
16
 
15
- function _mergeNamespaces(n, m) {
16
- m.forEach(function (e) {
17
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
18
- if (k !== 'default' && !(k in n)) {
19
- var d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: function () { return e[k]; }
23
- });
24
- }
25
- });
26
- });
27
- return Object.freeze(n);
28
- }
29
17
 
30
18
  /**
31
19
  * @fileoverview Internal Three.js re-exports - WEBGPU ONLY ENTRY
@@ -39,6 +27,8 @@ function _mergeNamespaces(n, m) {
39
27
  declare const R3F_BUILD_LEGACY = false;
40
28
  declare const R3F_BUILD_WEBGPU = true;
41
29
 
30
+ /** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
31
+ declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
42
32
  declare const WebGLRenderer: {
43
33
  new (): {};
44
34
  };
@@ -47,17 +37,8 @@ type WebGLShadowMap = never;
47
37
 
48
38
  declare const WebGLRenderTarget: any;
49
39
 
50
- var THREE = /*#__PURE__*/_mergeNamespaces({
51
- __proto__: null,
52
- Inspector: Inspector,
53
- R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
54
- R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
55
- RenderTargetCompat: RenderTarget,
56
- WebGLRenderTarget: WebGLRenderTarget,
57
- WebGLRenderer: WebGLRenderer,
58
- WebGLRendererParameters: WebGLRendererParameters,
59
- WebGLShadowMap: WebGLShadowMap
60
- }, [three_webgpu]);
40
+ declare const WebGLCubeRenderTarget: any;
41
+
61
42
 
62
43
  //* Utility Types ==============================
63
44
 
@@ -294,228 +275,33 @@ interface VisibilityEntry {
294
275
  }
295
276
 
296
277
  //* Scheduler Types (useFrame) ==============================
278
+ //
279
+ // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
280
+ // This file re-exports them and layers r3f's RootState-aware frame state on top,
281
+ // so existing `#types` imports across the codebase keep resolving unchanged.
297
282
 
298
283
 
299
284
 
300
- // Public Options --------------------------------
301
-
302
- /**
303
- * Options for useFrame hook
304
- */
305
- interface UseFrameNextOptions {
306
- /** Optional stable id for the job. Auto-generated if not provided */
307
- id?: string
308
- /** Named phase to run in. Default: 'update' */
309
- phase?: string
310
- /** Run before this phase or job id */
311
- before?: string | string[]
312
- /** Run after this phase or job id */
313
- after?: string | string[]
314
- /** Priority within phase. Higher runs first. Default: 0 */
315
- priority?: number
316
- /** Max frames per second for this job */
317
- fps?: number
318
- /** If true, skip frames when behind. If false, try to catch up. Default: true */
319
- drop?: boolean
320
- /** Enable/disable without unregistering. Default: true */
321
- enabled?: boolean
322
- }
323
-
324
- /** Alias for UseFrameNextOptions */
325
- type UseFrameOptions = UseFrameNextOptions
326
-
327
- /**
328
- * Options for addPhase
329
- */
330
- interface AddPhaseOptions {
331
- /** Insert this phase before the specified phase */
332
- before?: string
333
- /** Insert this phase after the specified phase */
334
- after?: string
335
- }
336
-
337
- // Frame State --------------------------------
338
-
339
- /**
340
- * Timing-only state for independent/outside mode (no RootState)
341
- */
342
- interface FrameTimingState {
343
- /** High-resolution timestamp from RAF (ms) */
344
- time: number
345
- /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
346
- delta: number
347
- /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
348
- elapsed: number
349
- /** Incrementing frame counter */
350
- frame: number
351
- }
285
+ // Frame State (r3f-specific) --------------------------------
352
286
 
353
287
  /**
354
- * State passed to useFrame callbacks (extends RootState with timing)
288
+ * State passed to useFrame callbacks (extends RootState with timing).
355
289
  */
356
290
  interface FrameNextState extends RootState, FrameTimingState {}
357
291
 
358
292
  /** Alias for FrameNextState */
359
293
  type FrameState = FrameNextState
360
294
 
361
- // Root Options --------------------------------
362
-
363
- /**
364
- * Options for registerRoot
365
- */
366
- interface RootOptions {
367
- /** State provider for callbacks. Optional in independent mode. */
368
- getState?: () => any
369
- /** Error handler for job errors. Falls back to console.error if not provided. */
370
- onError?: (error: Error) => void
371
- }
372
-
373
- // Callback Types --------------------------------
295
+ // Callback Types (r3f-specific) --------------------------------
374
296
 
375
297
  /**
376
- * Callback function for useFrame
298
+ * Callback function for useFrame. Receives the full r3f RootState plus timing.
377
299
  */
378
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
300
+ type FrameNextCallback = FrameCallback$1<RootState>
379
301
 
380
302
  /** Alias for FrameNextCallback */
381
303
  type FrameCallback = FrameNextCallback
382
304
 
383
- // Controls returned from useFrame --------------------------------
384
-
385
- /**
386
- * Controls object returned from useFrame hook
387
- */
388
- interface FrameNextControls {
389
- /** The job's unique ID */
390
- id: string
391
- /** Access to the global scheduler for frame loop control */
392
- scheduler: SchedulerApi
393
- /** Manually step this job only (bypasses FPS limiting) */
394
- step(timestamp?: number): void
395
- /** Manually step ALL jobs in the scheduler */
396
- stepAll(timestamp?: number): void
397
- /** Pause this job (set enabled=false) */
398
- pause(): void
399
- /** Resume this job (set enabled=true) */
400
- resume(): void
401
- /** Reactive paused state - automatically triggers re-render when changed */
402
- isPaused: boolean
403
- }
404
-
405
- /** Alias for FrameNextControls */
406
- type FrameControls = FrameNextControls
407
-
408
- // Scheduler Interface --------------------------------
409
-
410
- /**
411
- * Public interface for the global Scheduler
412
- */
413
- interface SchedulerApi {
414
- //* Phase Management --------------------------------
415
-
416
- /** Add a named phase to the scheduler */
417
- addPhase(name: string, options?: AddPhaseOptions): void
418
- /** Get the ordered list of phase names */
419
- readonly phases: string[]
420
- /** Check if a phase exists */
421
- hasPhase(name: string): boolean
422
-
423
- //* Root Management --------------------------------
424
-
425
- /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
426
- registerRoot(id: string, options?: RootOptions): () => void
427
- /** Unregister a root */
428
- unregisterRoot(id: string): void
429
- /** Generate a unique root ID */
430
- generateRootId(): string
431
- /** Get the number of registered roots */
432
- getRootCount(): number
433
- /** Check if any root is registered and ready */
434
- readonly isReady: boolean
435
- /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
436
- onRootReady(callback: () => void): () => void
437
-
438
- //* Job Registration --------------------------------
439
-
440
- /** Register a job with the scheduler (returns unsubscribe function) */
441
- register(
442
- callback: FrameNextCallback,
443
- options?: {
444
- id?: string
445
- rootId?: string
446
- phase?: string
447
- before?: string | string[]
448
- after?: string | string[]
449
- priority?: number
450
- fps?: number
451
- drop?: boolean
452
- enabled?: boolean
453
- },
454
- ): () => void
455
- /** Update a job's options */
456
- updateJob(
457
- id: string,
458
- options: {
459
- priority?: number
460
- fps?: number
461
- drop?: boolean
462
- enabled?: boolean
463
- phase?: string
464
- before?: string | string[]
465
- after?: string | string[]
466
- },
467
- ): void
468
- /** Unregister a job by ID */
469
- unregister(id: string, rootId?: string): void
470
- /** Get the number of registered jobs */
471
- getJobCount(): number
472
- /** Get all job IDs */
473
- getJobIds(): string[]
474
-
475
- //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
476
-
477
- /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
478
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
479
-
480
- //* Idle Callbacks (for legacy addTail) --------------------------------
481
-
482
- /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
483
- onIdle(callback: (timestamp: number) => void): () => void
484
-
485
- //* Frame Loop Control --------------------------------
486
-
487
- /** Start the scheduler loop */
488
- start(): void
489
- /** Stop the scheduler loop */
490
- stop(): void
491
- /** Check if the scheduler is running */
492
- readonly isRunning: boolean
493
- /** Get/set the frameloop mode ('always', 'demand', 'never') */
494
- frameloop: Frameloop
495
- /** Independent mode - runs without Canvas, callbacks receive timing-only state */
496
- independent: boolean
497
-
498
- //* Manual Stepping --------------------------------
499
-
500
- /** Manually step all jobs once (for frameloop='never' or testing) */
501
- step(timestamp?: number): void
502
- /** Manually step a single job by ID */
503
- stepJob(id: string, timestamp?: number): void
504
- /** Request frame(s) to be rendered (for frameloop='demand') */
505
- invalidate(frames?: number): void
506
-
507
- //* Per-Job Control --------------------------------
508
-
509
- /** Check if a job is paused */
510
- isJobPaused(id: string): boolean
511
- /** Pause a job */
512
- pauseJob(id: string): void
513
- /** Resume a job */
514
- resumeJob(id: string): void
515
- /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
516
- subscribeJobState(id: string, listener: () => void): () => void
517
- }
518
-
519
305
  //* Buffer Types (useBuffers) ========================================
520
306
 
521
307
  /**
@@ -540,6 +326,7 @@ type BufferLike =
540
326
  | Uint16Array
541
327
  | Int16Array
542
328
  | THREE$1.BufferAttribute // Base class for all buffer attributes
329
+ | THREE$1.InterleavedBufferAttribute
543
330
  | Node // TSL buffer nodes (instancedArray, storage)
544
331
 
545
332
  /** Flat record of buffer-like values (no nested scopes) */
@@ -551,6 +338,25 @@ type BufferRecord = Record<string, BufferLike>
551
338
  */
552
339
  type BufferStore = Record<string, BufferLike | BufferRecord>
553
340
 
341
+ //* Node Types (useNodes) ========================================
342
+
343
+ /**
344
+ * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
345
+ * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
346
+ * code passes through. Creators are constrained to this same type, so the shape a creator returns
347
+ * and the shape the store holds are one type by construction.
348
+ */
349
+ type NodeLike = TSLNodeType | LegacyTSLNodeLike
350
+
351
+ /** Flat record of TSL nodes (no nested scopes) */
352
+ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
353
+
354
+ /**
355
+ * Node store that can contain both root-level nodes and scoped node objects.
356
+ * Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
357
+ */
358
+ type NodeStore = Record<string, NodeLike | NodeRecord>
359
+
554
360
  //* Storage Types (useGPUStorage) ========================================
555
361
 
556
362
  /**
@@ -565,7 +371,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
565
371
  * ```
566
372
  */
567
373
  type StorageLike =
568
- | StorageTexture // GPU storage texture
374
+ | StorageTexture // 2D GPU storage texture
375
+ | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
376
+ | StorageArrayTexture // 2D-array GPU storage texture
569
377
  | Data3DTexture // 3D texture (can be used as storage)
570
378
  | Node // TSL storage texture nodes (storageTexture)
571
379
 
@@ -684,14 +492,31 @@ interface InternalState {
684
492
  /** Container for child attachment (scene for root, original container for portals) */
685
493
  container?: THREE$1.Object3D
686
494
  /**
687
- * CanvasTarget for multi-canvas WebGPU rendering.
688
- * Created for all WebGPU canvases to support renderer sharing.
495
+ * The CanvasTarget this root sizes and renders through.
496
+ *
497
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
498
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
499
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
500
+ * and the canvas-target job makes it the renderer's active one before this root renders.
501
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
689
502
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
690
503
  */
691
504
  canvasTarget?: CanvasTarget
505
+ /**
506
+ * Set when this root's canvas target has been resized and the backend's cached render pass
507
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
508
+ *
509
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
510
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
511
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
512
+ * invalidate some other canvas's descriptor instead.
513
+ *
514
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
515
+ */
516
+ canvasTargetSizeDirty?: boolean
692
517
  /**
693
518
  * Whether multi-canvas rendering is active.
694
- * True when any canvas uses `target` prop to share a renderer.
519
+ * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
695
520
  * When true, setCanvasTarget is called before each render.
696
521
  */
697
522
  isMultiCanvas?: boolean
@@ -789,8 +614,8 @@ interface RootState {
789
614
  setSize: (width?: number, height?: number, top?: number, left?: number) => void
790
615
  /** Shortcut to manual setting the pixel ratio */
791
616
  setDpr: (dpr: Dpr) => void
792
- /** Shortcut to setting frameloop flags */
793
- setFrameloop: (frameloop: Frameloop) => void
617
+ /** Shortcut to setting frameloop flags. No args resets to 'always'. */
618
+ setFrameloop: (frameloop?: Frameloop) => void
794
619
  /** Set error state to propagate to error boundary */
795
620
  setError: (error: Error | null) => void
796
621
  /** Current error state (null when no error) */
@@ -798,7 +623,7 @@ interface RootState {
798
623
  /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
799
624
  uniforms: UniformStore
800
625
  /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
801
- nodes: Record<string, any>
626
+ nodes: NodeStore
802
627
  /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
803
628
  buffers: BufferStore
804
629
  /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
@@ -808,9 +633,9 @@ interface RootState {
808
633
  /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
809
634
  _textureRefs: Map<string, number>
810
635
  /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
811
- renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
636
+ renderPipeline: ThreeRenderPipeline | null
812
637
  /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
813
- passes: Record<string, any>
638
+ passes: PassRecord
814
639
  /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
815
640
  _hmrVersion: number
816
641
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
@@ -898,12 +723,19 @@ type DefaultRendererProps = {
898
723
  */
899
724
  interface CanvasSchedulerConfig {
900
725
  /**
901
- * Render this canvas after another canvas completes.
902
- * Pass the `id` of another canvas.
726
+ * Run this Canvas root before the referenced Canvas root id(s).
903
727
  */
904
- after?: string
728
+ before?: string | string[]
729
+ /**
730
+ * Run this Canvas root after the referenced Canvas root id(s).
731
+ */
732
+ after?: string | string[]
905
733
  /**
906
- * Limit this canvas's render rate (frames per second).
734
+ * Numeric root order. Lower values run first.
735
+ */
736
+ order?: number
737
+ /**
738
+ * Limit this Canvas's default render job (frames per second).
907
739
  */
908
740
  fps?: number
909
741
  }
@@ -990,14 +822,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
990
822
  performance?: Partial<Omit<Performance, 'regress'>>
991
823
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
992
824
  dpr?: Dpr
993
- /** Props that go into the default raycaster */
994
- raycaster?: Partial<THREE$1.Raycaster>
825
+ /**
826
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
827
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
828
+ */
829
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
995
830
  /** A `THREE.Scene` instance or props that go into the default scene */
996
831
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
997
832
  /** A `THREE.Camera` instance or props that go into the default camera */
998
833
  camera?: CameraProps
999
834
  /** An R3F event manager to manage elements' pointer events */
1000
- events?: (store: RootStore) => EventManager<HTMLElement>
835
+ events?: (store: RootStore) => EventManager<Element>
1001
836
  /** Callback after the canvas has rendered (but not yet committed) */
1002
837
  onCreated?: (state: RootState) => void
1003
838
  /** Response for pointer clicks that have missed any target */
@@ -1101,8 +936,6 @@ interface Instance<O = any> {
1101
936
  attach?: AttachType<O>
1102
937
  previousAttach?: any
1103
938
  isHidden: boolean
1104
- /** Deferred ref props to apply in commitMount */
1105
- deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
1106
939
  /** Set of props that have been applied via once() */
1107
940
  appliedOnce?: Set<string>
1108
941
  }
@@ -1228,7 +1061,7 @@ interface CanvasProps
1228
1061
  */
1229
1062
  resize?: Options
1230
1063
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1231
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1064
+ eventSource?: Element | React$1.RefObject<Element | null>
1232
1065
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1233
1066
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1234
1067
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1336,70 +1169,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1336
1169
 
1337
1170
  type RenderTargetOptions = RenderTargetOptions$1
1338
1171
 
1339
- //* Global Types ==============================
1172
+ //* Global TSL Types ==============================
1340
1173
 
1341
1174
  declare global {
1342
- /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
1343
- interface UniformNode<T = unknown> extends Node {
1344
- value: T
1345
- }
1346
-
1347
1175
  /**
1348
- * ShaderCallable - the return type of Fn()
1349
- * A callable shader function node that can be invoked with parameters.
1350
- * The function returns a ShaderNodeObject when called.
1351
- *
1352
- * @example
1353
- * ```tsx
1354
- * // Define a shader function
1355
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1356
- * return mix(color1, color2, factor)
1357
- * })
1358
- *
1359
- * // Type when retrieving from nodes store
1360
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1361
- *
1362
- * // Or with specific return type
1363
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1364
- * ```
1176
+ * Broad callable-node fallback for dynamic store readers.
1177
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1365
1178
  */
1366
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1179
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1180
+ readonly shaderNode: unknown
1181
+ readonly id: number
1182
+ }
1367
1183
 
1368
- /**
1369
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1370
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1371
- *
1372
- * @example
1373
- * ```tsx
1374
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1375
- * ```
1376
- */
1377
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1184
+ /** Legacy structural node accepted when at least one historical marker exists. */
1185
+ type LegacyTSLNodeLike = {
1186
+ label?: ((label: string) => unknown) | string
1187
+ setName?: (name: string) => unknown
1188
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1189
+
1190
+ /** Node type accepted by broad dynamic node-store readers. */
1191
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1378
1192
 
1379
1193
  /**
1380
- * TSLNodeType - Union of all common TSL node types
1381
- * Used by ScopedStore to properly type node access from the store.
1382
- *
1383
- * Includes:
1384
- * - Node: base Three.js node type
1385
- * - ShaderCallable: function nodes created with Fn()
1386
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1387
- *
1388
- * @example
1389
- * ```tsx
1390
- * // In useLocalNodes, nodes are typed as TSLNodeType
1391
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1392
- * positionNode: nodes.myPosition, // Works - Node is in union
1393
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1394
- * }))
1395
- *
1396
- * // Can narrow with type guard or assertion when needed
1397
- * if (typeof blendColorFn === 'function') {
1398
- * blendColorFn(someColor, 0.5)
1399
- * }
1400
- * ```
1194
+ * Derive Three's shader node type from an existing node or a supported raw input.
1195
+ * Existing InputNode generics take precedence over structural value normalization.
1196
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1197
+ * InputNode base with its concrete InputNode specialization.
1401
1198
  */
1402
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1199
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1200
+ ? TNodeType
1201
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1202
+ ? TNodeType
1203
+ : T extends number
1204
+ ? 'float'
1205
+ : T extends boolean
1206
+ ? 'bool'
1207
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1208
+ ? 'color'
1209
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1210
+ ? 'vec4'
1211
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1212
+ ? 'vec3'
1213
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1214
+ ? 'vec2'
1215
+ : T extends three_webgpu.Matrix4
1216
+ ? 'mat4'
1217
+ : T extends three_webgpu.Matrix3
1218
+ ? 'mat3'
1219
+ : T extends three_webgpu.Matrix2
1220
+ ? 'mat2'
1221
+ : unknown
1222
+
1223
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1224
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1225
+ ? TValue
1226
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1227
+ ? TValue
1228
+ : T extends string | { r: number; g: number; b: number }
1229
+ ? three_webgpu.Color
1230
+ : T extends { x: number; y: number; z: number; w: number }
1231
+ ? three_webgpu.Vector4
1232
+ : T extends { x: number; y: number; z: number }
1233
+ ? three_webgpu.Vector3
1234
+ : T extends { x: number; y: number }
1235
+ ? three_webgpu.Vector2
1236
+ : T extends number
1237
+ ? number
1238
+ : T extends boolean
1239
+ ? boolean
1240
+ : T
1241
+
1242
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1243
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1244
+
1245
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1246
+ type UniformNodesFor<T extends UniformInputRecord> = {
1247
+ [K in keyof T]: UniformNodeFor<T[K]>
1248
+ }
1249
+
1250
+ /** Backward-compatible single-parameter uniform alias. */
1251
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1403
1252
 
1404
1253
  /** Flat record of uniform nodes (no nested scopes) */
1405
1254
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1424,7 +1273,7 @@ declare global {
1424
1273
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1425
1274
  * Supports:
1426
1275
  * - Primitives: number, string (color), boolean
1427
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1276
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1428
1277
  * - Plain objects: { x, y, z, w } converted to vectors
1429
1278
  * - TSL nodes: color(), vec3(), float() for type casting
1430
1279
  * - UniformNode: existing uniforms (reused as-is)
@@ -1437,227 +1286,124 @@ declare global {
1437
1286
  | three_webgpu.Vector2
1438
1287
  | three_webgpu.Vector3
1439
1288
  | three_webgpu.Vector4
1289
+ | three_webgpu.Matrix2
1440
1290
  | three_webgpu.Matrix3
1441
1291
  | three_webgpu.Matrix4
1442
- | three_webgpu.Euler
1443
- | three_webgpu.Quaternion
1444
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1292
+ | { x: number; y: number }
1293
+ | { x: number; y: number; z: number }
1294
+ | { x: number; y: number; z: number; w: number }
1445
1295
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1446
- | Node // TSL nodes like color(), vec3(), float() for type casting
1296
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1447
1297
  | UniformNode
1448
1298
 
1449
1299
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1450
1300
  type UniformInputRecord = Record<string, UniformValue>
1451
1301
  }
1452
1302
 
1453
- //* Module Augmentation ==============================
1454
-
1455
- declare module 'three/tsl' {
1303
+ declare global {
1456
1304
  /**
1457
- * Fn with array parameter destructuring
1458
- * @example Fn(([uv, skew]) => { ... })
1305
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1306
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1307
+ * is r185, so the new name is the only one.
1459
1308
  */
1460
- export function Fn<R extends Node = Node>(
1461
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1462
- ): ShaderCallable<R>
1309
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1463
1310
 
1464
1311
  /**
1465
- * Fn with object parameter destructuring
1466
- * @example Fn(({ color, intensity }) => { ... })
1312
+ * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1313
+ * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1314
+ * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1467
1315
  */
1468
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1469
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1470
- ): ShaderCallable<R>
1316
+ type ScenePassNode = three_webgpu.PassNode
1471
1317
 
1472
1318
  /**
1473
- * Fn with array params + layout
1474
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1319
+ * Pass record - stores TSL pass nodes for render pipeline.
1320
+ *
1321
+ * `scenePass` is the only key the library owns. It is optional here because this is also the
1322
+ * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1323
+ * or `clearPasses()`. Inside the callbacks it is always present; see
1324
+ * {@link RenderPipelineCallbackState}.
1325
+ *
1326
+ * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1327
+ * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1328
+ * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1329
+ * site when you need a member, e.g. `passes.velocity as TextureNode`.
1330
+ *
1331
+ * The index signature admits `undefined` because a key may simply not be registered, and
1332
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1333
+ * optional property whose type excludes `undefined` from the index signature is an error
1334
+ * (TS2411) for every consumer compiling these declarations.
1475
1335
  */
1476
- export function Fn<R extends Node = Node>(
1477
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1478
- layout: { layout?: unknown },
1479
- ): ShaderCallable<R>
1336
+ interface PassRecord {
1337
+ scenePass?: ScenePassNode
1338
+ [key: string]: three_webgpu.Node | undefined
1339
+ }
1480
1340
 
1481
1341
  /**
1482
- * Fn with object params + layout
1342
+ * State passed to pipeline callbacks after the active pipeline has been created.
1343
+ *
1344
+ * `passes.scenePass` is required here: the hook installs the default scene pass before either
1345
+ * callback runs, so callbacks can use it without a guard or a cast.
1346
+ *
1347
+ * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1348
+ * the legacy renderer before either callback can run, so a callback never sees WebGL.
1483
1349
  */
1484
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1485
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1486
- layout: { layout?: unknown },
1487
- ): ShaderCallable<R>
1488
- }
1489
-
1490
- /**
1491
- * RenderPipeline Types for useRenderPipeline hook (WebGPU only)
1492
- */
1493
-
1494
-
1350
+ type RenderPipelineCallbackState = RootState & {
1351
+ renderPipeline: ThreeRenderPipeline
1352
+ passes: PassRecord & { scenePass: ScenePassNode }
1353
+ renderer: three_webgpu.WebGPURenderer
1354
+ isLegacy: false
1355
+ }
1495
1356
 
1496
- declare global {
1497
- /** Pass record - stores TSL pass nodes for render pipeline */
1498
- type PassRecord = Record<string, any>
1357
+ /**
1358
+ * What a callback may return to register entries into `state.passes`.
1359
+ *
1360
+ * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1361
+ * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1362
+ * store entry would leave the store pointing at a node the hook never disposes, and the hook
1363
+ * disposing a pass nothing references. So returning it is a type error.
1364
+ */
1365
+ type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1499
1366
 
1500
1367
  /** Setup callback - runs first to configure MRT, create additional passes */
1501
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1368
+ type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1502
1369
 
1503
1370
  /** Main callback - runs second to configure outputNode, create effect passes */
1504
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1371
+ type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1505
1372
 
1506
- /** Return type for useRenderPipeline hook */
1507
- interface UseRenderPipelineReturn {
1373
+ /** The imperative half of useRenderPipeline's return value, present in every state */
1374
+ interface UseRenderPipelineActions {
1508
1375
  /** Current passes from state */
1509
1376
  passes: PassRecord
1510
- /** RenderPipeline instance (null if not initialized) */
1511
- renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
1512
1377
  /** Clear all passes from state */
1513
1378
  clearPasses: () => void
1514
1379
  /** Reset RenderPipeline entirely (clears PP + passes) */
1515
1380
  reset: () => void
1516
1381
  /** Re-run setup/main callbacks with current closure values */
1517
1382
  rebuild: () => void
1518
- /** True when RenderPipeline is configured and ready */
1519
- isReady: boolean
1520
- }
1521
- }
1522
-
1523
- //* useFrameNext Types ==============================
1524
-
1525
-
1526
-
1527
- //* Global Type Declarations ==============================
1528
-
1529
- declare global {
1530
- // Job --------------------------------
1531
-
1532
- /**
1533
- * Internal job representation in the scheduler
1534
- */
1535
- interface Job {
1536
- /** Unique identifier */
1537
- id: string
1538
- /** The callback to execute */
1539
- callback: FrameNextCallback
1540
- /** Phase this job belongs to */
1541
- phase: string
1542
- /** Run before these phases/job ids */
1543
- before: Set<string>
1544
- /** Run after these phases/job ids */
1545
- after: Set<string>
1546
- /** Priority within phase (higher first) */
1547
- priority: number
1548
- /** Insertion order for deterministic tie-breaking */
1549
- index: number
1550
- /** Max FPS for this job (undefined = no limit) */
1551
- fps?: number
1552
- /** Drop frames when behind (true) or catch up (false) */
1553
- drop: boolean
1554
- /** Last run timestamp (ms) */
1555
- lastRun?: number
1556
- /** Whether job is enabled */
1557
- enabled: boolean
1558
- /** Internal flag: system jobs (like default render) don't block user render takeover */
1559
- system?: boolean
1560
- }
1561
-
1562
- // Phase Graph --------------------------------
1563
-
1564
- /**
1565
- * A node in the phase graph
1566
- */
1567
- interface PhaseNode {
1568
- /** Phase name */
1569
- name: string
1570
- /** Whether this was auto-generated from a before/after constraint */
1571
- isAutoGenerated: boolean
1572
- }
1573
-
1574
- /**
1575
- * Options for creating a job from hook options
1576
- */
1577
- interface JobOptions {
1578
- id?: string
1579
- phase?: string
1580
- before?: string | string[]
1581
- after?: string | string[]
1582
- priority?: number
1583
- fps?: number
1584
- drop?: boolean
1585
- enabled?: boolean
1586
- }
1587
-
1588
- // Frame Loop State --------------------------------
1589
-
1590
- /**
1591
- * Internal frame loop state
1592
- */
1593
- interface FrameLoopState {
1594
- /** Whether the loop is running */
1595
- running: boolean
1596
- /** Current RAF handle */
1597
- rafHandle: number | null
1598
- /** Last frame timestamp in ms (null = uninitialized) */
1599
- lastTime: number | null
1600
- /** Frame counter */
1601
- frameCount: number
1602
- /** Elapsed time since first frame in ms */
1603
- elapsedTime: number
1604
- /** createdAt timestamp in ms */
1605
- createdAt: number
1606
- }
1607
-
1608
- // Root Entry --------------------------------
1609
-
1610
- /**
1611
- * Internal representation of a registered root (Canvas).
1612
- * Tracks jobs and manages rebuild state for this root.
1613
- * @internal
1614
- */
1615
- interface RootEntry {
1616
- /** Unique identifier for this root */
1617
- id: string
1618
- /** Function to get the root's current state. Returns any to support independent mode. */
1619
- getState: () => any
1620
- /** Map of job IDs to Job objects */
1621
- jobs: Map<string, Job>
1622
- /** Cached sorted job list for execution order */
1623
- sortedJobs: Job[]
1624
- /** Whether sortedJobs needs rebuilding */
1625
- needsRebuild: boolean
1626
- }
1627
-
1628
- /**
1629
- * Internal representation of a global job (deprecated API).
1630
- * Global jobs run once per frame, not per-root.
1631
- * Used by legacy addEffect/addAfterEffect APIs.
1632
- * @internal
1633
- * @deprecated Use useFrame with phases instead
1634
- */
1635
- interface GlobalJob {
1636
- /** Unique identifier for this global job */
1637
- id: string
1638
- /** Callback invoked with RAF timestamp in ms */
1639
- callback: (timestamp: number) => void
1640
1383
  }
1641
1384
 
1642
- // HMR Support --------------------------------
1643
-
1644
1385
  /**
1645
- * Hot Module Replacement data structure for preserving scheduler state
1646
- * @internal
1647
- */
1648
- interface HMRData {
1649
- /** Shared data object for storing values across reloads */
1650
- data: Record<string, any>
1651
- /** Optional function to accept HMR updates */
1652
- accept?: () => void
1653
- }
1654
-
1655
- // Default Phases --------------------------------
1656
-
1657
- /**
1658
- * Default phase names for the scheduler
1386
+ * Return type for useRenderPipeline hook, discriminated on `isReady`.
1387
+ *
1388
+ * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1389
+ * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1390
+ * `clearPasses()` empties the record while leaving the pipeline in place.
1659
1391
  */
1660
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1392
+ type UseRenderPipelineReturn = UseRenderPipelineActions &
1393
+ (
1394
+ | {
1395
+ /** True when RenderPipeline is configured and ready */
1396
+ isReady: true
1397
+ /** RenderPipeline instance */
1398
+ renderPipeline: ThreeRenderPipeline
1399
+ }
1400
+ | {
1401
+ /** False until the pipeline has been created */
1402
+ isReady: false
1403
+ /** Not initialized yet, or torn down by reset() */
1404
+ renderPipeline: null
1405
+ }
1406
+ )
1661
1407
  }
1662
1408
 
1663
1409
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
@@ -1736,10 +1482,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1736
1482
 
1737
1483
  /**
1738
1484
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1739
- * since @types/three has broken inheritance for TSL node subclasses.
1485
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1486
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1740
1487
  */
1741
1488
  type NodeProps<P> = {
1742
- [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1489
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1743
1490
  }
1744
1491
 
1745
1492
  interface ReactProps<P> {
@@ -1760,11 +1507,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1760
1507
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1761
1508
  }
1762
1509
 
1510
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1511
+ type Object3DMethod = NonNullable<
1512
+ {
1513
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1514
+ }[keyof Object3D]
1515
+ >
1516
+
1763
1517
  type ThreeExports = typeof import('three/webgpu')
1764
1518
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1765
1519
 
1766
1520
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1767
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1521
+ /**
1522
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1523
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1524
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1525
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1526
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1527
+ */
1528
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
1529
+ object: object
1530
+ ref?: React.Ref<any>
1531
+ onUpdate?: (self: any) => void
1532
+ [prop: string]: unknown
1533
+ }
1768
1534
  // Conflicts with DOM types can be accessed through a three* prefix
1769
1535
  threeAudio: ThreeElementsImpl['audio']
1770
1536
  threeSource: ThreeElementsImpl['source']
@@ -1805,6 +1571,7 @@ type three_d_Matrix3 = Matrix3;
1805
1571
  type three_d_Matrix4 = Matrix4;
1806
1572
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1807
1573
  type three_d_NodeProps<P> = NodeProps<P>;
1574
+ type three_d_Object3DMethod = Object3DMethod;
1808
1575
  type three_d_Quaternion = Quaternion;
1809
1576
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1810
1577
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1819,7 +1586,7 @@ type three_d_Vector3 = Vector3;
1819
1586
  type three_d_Vector4 = Vector4;
1820
1587
  type three_d_VectorRepresentation = VectorRepresentation;
1821
1588
  declare namespace three_d {
1822
- export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1589
+ export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1823
1590
  }
1824
1591
 
1825
1592
  /**
@@ -1829,7 +1596,7 @@ declare namespace three_d {
1829
1596
  * a single WebGPURenderer using Three.js CanvasTarget API.
1830
1597
  *
1831
1598
  * Primary canvas: Has `id` prop, creates its own renderer, registers here
1832
- * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1599
+ * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1833
1600
  */
1834
1601
 
1835
1602
  interface PrimaryCanvasEntry {
@@ -1897,12 +1664,23 @@ type EnvironmentLoaderProps = {
1897
1664
  * const texture = useEnvironment({ preset: 'sunset' })
1898
1665
  * ```
1899
1666
  */
1900
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1667
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1901
1668
  declare namespace useEnvironment {
1902
1669
  var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1903
1670
  var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1904
1671
  }
1905
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1672
+ /**
1673
+ * Options accepted by `useEnvironment.preload`.
1674
+ *
1675
+ * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1676
+ * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1677
+ * advertise an option this function silently ignores.
1678
+ *
1679
+ * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1680
+ * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1681
+ * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1682
+ */
1683
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1906
1684
  type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1907
1685
 
1908
1686
  /**
@@ -1946,9 +1724,9 @@ type EnvironmentProps = {
1946
1724
  blur?: number;
1947
1725
  backgroundBlurriness?: number;
1948
1726
  backgroundIntensity?: number;
1949
- backgroundRotation?: Euler$3;
1727
+ backgroundRotation?: Euler;
1950
1728
  environmentIntensity?: number;
1951
- environmentRotation?: Euler$3;
1729
+ environmentRotation?: Euler;
1952
1730
  map?: Texture$1;
1953
1731
  preset?: PresetsType;
1954
1732
  scene?: Scene | React$1.RefObject<Scene>;
@@ -2032,7 +1810,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
2032
1810
  declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
2033
1811
  declare module '@react-three/fiber' {
2034
1812
  interface ThreeElements {
2035
- groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
1813
+ groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
2036
1814
  }
2037
1815
  }
2038
1816
  /**
@@ -2132,6 +1910,24 @@ declare module '@react-three/fiber' {
2132
1910
  */
2133
1911
  declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
2134
1912
 
1913
+ /**
1914
+ * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1915
+ *
1916
+ * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1917
+ * instance. Removing the old object from the interaction state and registering the new one from
1918
+ * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1919
+ * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1920
+ * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1921
+ * swap the user never asked to see (#3744).
1922
+ *
1923
+ * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1924
+ * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1925
+ *
1926
+ * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1927
+ * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1928
+ * cannot outlive the object it described.
1929
+ */
1930
+ declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
2135
1931
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
2136
1932
  declare function createEvents(store: RootStore): {
2137
1933
  handlePointer: (name: string) => (event: DomEvent) => void;
@@ -2139,7 +1935,7 @@ declare function createEvents(store: RootStore): {
2139
1935
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
2140
1936
  };
2141
1937
  /** Default R3F event manager for web */
2142
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1938
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
2143
1939
 
2144
1940
  /**
2145
1941
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -2152,419 +1948,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
2152
1948
  * Note: this hook's caller must be wrapped with `React.Suspense`
2153
1949
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
2154
1950
  */
2155
- declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
1951
+ declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
2156
1952
  declare namespace useLoader {
2157
- var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
2158
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
1953
+ var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike) => void;
1954
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
2159
1955
  var loader: typeof getLoader;
2160
1956
  }
2161
1957
 
2162
- /**
2163
- * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
2164
- *
2165
- * Features:
2166
- * - Single RAF loop for entire application
2167
- * - Root registration (multiple Canvas support)
2168
- * - Global phases for addEffect/addAfterEffect (deprecated)
2169
- * - Per-root job management with phases, priorities, FPS throttling
2170
- * - onIdle callbacks for addTail (deprecated)
2171
- * - Demand mode support via invalidate()
2172
- */
2173
- declare class Scheduler {
2174
- private static readonly INSTANCE_KEY;
2175
- private static get instance();
2176
- private static set instance(value);
2177
- /**
2178
- * Get the global scheduler instance (creates if doesn't exist).
2179
- * Uses HMR data to preserve instance across hot reloads.
2180
- * @returns {Scheduler} The singleton scheduler instance
2181
- */
2182
- static get(): Scheduler;
2183
- /**
2184
- * Reset the singleton instance. Stops the loop and clears all state.
2185
- * Primarily used for testing to ensure clean state between tests.
2186
- * @returns {void}
2187
- */
2188
- static reset(): void;
2189
- private roots;
2190
- private phaseGraph;
2191
- private loopState;
2192
- private stoppedTime;
2193
- private nextRootIndex;
2194
- private globalBeforeJobs;
2195
- private globalAfterJobs;
2196
- private nextGlobalIndex;
2197
- private idleCallbacks;
2198
- private nextJobIndex;
2199
- private jobStateListeners;
2200
- private pendingFrames;
2201
- private _frameloop;
2202
- private _independent;
2203
- private errorHandler;
2204
- private rootReadyCallbacks;
2205
- get phases(): string[];
2206
- get frameloop(): Frameloop;
2207
- set frameloop(mode: Frameloop);
2208
- get isRunning(): boolean;
2209
- get isReady(): boolean;
2210
- get independent(): boolean;
2211
- set independent(value: boolean);
2212
- constructor();
2213
- /**
2214
- * Register a root (Canvas) with the scheduler.
2215
- * The first root to register starts the RAF loop (if frameloop='always').
2216
- * @param {string} id - Unique identifier for this root
2217
- * @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
2218
- * @returns {() => void} Unsubscribe function to remove this root
2219
- */
2220
- registerRoot(id: string, options?: RootOptions): () => void;
2221
- /**
2222
- * Unregister a root from the scheduler.
2223
- * Cleans up all job state listeners for this root's jobs.
2224
- * The last root to unregister stops the RAF loop.
2225
- * @param {string} id - The root ID to unregister
2226
- * @returns {void}
2227
- */
2228
- unregisterRoot(id: string): void;
2229
- /**
2230
- * Subscribe to be notified when a root becomes available.
2231
- * Fires immediately if a root already exists.
2232
- * @param {() => void} callback - Function called when first root registers
2233
- * @returns {() => void} Unsubscribe function
2234
- */
2235
- onRootReady(callback: () => void): () => void;
2236
- /**
2237
- * Notify all registered root-ready callbacks.
2238
- * Called when the first root registers.
2239
- * @returns {void}
2240
- * @private
2241
- */
2242
- private notifyRootReady;
2243
- /**
2244
- * Ensure a default root exists for independent mode.
2245
- * Creates a minimal root with no state provider.
2246
- * @returns {void}
2247
- * @private
2248
- */
2249
- private ensureDefaultRoot;
2250
- /**
2251
- * Trigger error handling for job errors.
2252
- * Uses the bound error handler if available, otherwise logs to console.
2253
- * @param {Error} error - The error to handle
2254
- * @returns {void}
2255
- */
2256
- triggerError(error: Error): void;
2257
- /**
2258
- * Add a named phase to the scheduler's execution order.
2259
- * Marks all roots for rebuild to incorporate the new phase.
2260
- * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
2261
- * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
2262
- * @returns {void}
2263
- * @example
2264
- * scheduler.addPhase('physics', { before: 'update' });
2265
- * scheduler.addPhase('postprocess', { after: 'render' });
2266
- */
2267
- addPhase(name: string, options?: AddPhaseOptions): void;
2268
- /**
2269
- * Check if a phase exists in the scheduler.
2270
- * @param {string} name - The phase name to check
2271
- * @returns {boolean} True if the phase exists
2272
- */
2273
- hasPhase(name: string): boolean;
2274
- /**
2275
- * Register a global job that runs once per frame (not per-root).
2276
- * Used internally by deprecated addEffect/addAfterEffect APIs.
2277
- * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
2278
- * @param {string} id - Unique identifier for this global job
2279
- * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
2280
- * @returns {() => void} Unsubscribe function to remove this global job
2281
- * @deprecated Use useFrame with phases instead
2282
- */
2283
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
2284
- /**
2285
- * Register an idle callback that fires when the loop stops.
2286
- * Used internally by deprecated addTail API.
2287
- * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
2288
- * @returns {() => void} Unsubscribe function to remove this idle callback
2289
- * @deprecated Use demand mode with invalidate() instead
2290
- */
2291
- onIdle(callback: (timestamp: number) => void): () => void;
2292
- /**
2293
- * Notify all registered idle callbacks.
2294
- * Called when the loop stops in demand mode.
2295
- * @param {number} timestamp - The RAF timestamp when idle occurred
2296
- * @returns {void}
2297
- * @private
2298
- */
2299
- private notifyIdle;
2300
- /**
2301
- * Register a job (frame callback) with a specific root.
2302
- * This is the core registration method used by useFrame internally.
2303
- * @param {FrameNextCallback} callback - The function to call each frame
2304
- * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
2305
- * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
2306
- * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
2307
- * @param {string} [options.phase] - Execution phase (defaults to 'update')
2308
- * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
2309
- * @param {number} [options.fps] - FPS throttle limit
2310
- * @param {boolean} [options.drop] - Drop frames when behind (default true)
2311
- * @param {boolean} [options.enabled] - Whether job is active (default true)
2312
- * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
2313
- * @returns {() => void} Unsubscribe function to remove this job
2314
- */
2315
- register(callback: FrameNextCallback, options?: JobOptions & {
2316
- rootId?: string;
2317
- system?: boolean;
2318
- }): () => void;
2319
- /**
2320
- * Unregister a job by its ID.
2321
- * Searches all roots if rootId is not provided.
2322
- * @param {string} id - The job ID to unregister
2323
- * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
2324
- * @returns {void}
2325
- */
2326
- unregister(id: string, rootId?: string): void;
2327
- /**
2328
- * Update a job's options dynamically.
2329
- * Searches all roots to find the job by ID.
2330
- * Phase/constraint changes trigger a rebuild of the sorted job list.
2331
- * @param {string} id - The job ID to update
2332
- * @param {Partial<JobOptions>} options - The options to update
2333
- * @returns {void}
2334
- */
2335
- updateJob(id: string, options: Partial<JobOptions>): void;
2336
- /**
2337
- * Check if a job is currently paused (disabled).
2338
- * @param {string} id - The job ID to check
2339
- * @returns {boolean} True if the job exists and is paused
2340
- */
2341
- isJobPaused(id: string): boolean;
2342
- /**
2343
- * Subscribe to state changes for a specific job.
2344
- * Listener is called when job is paused or resumed.
2345
- * @param {string} id - The job ID to subscribe to
2346
- * @param {() => void} listener - Callback invoked on state changes
2347
- * @returns {() => void} Unsubscribe function
2348
- */
2349
- subscribeJobState(id: string, listener: () => void): () => void;
2350
- /**
2351
- * Notify all listeners that a job's state has changed.
2352
- * @param {string} id - The job ID that changed
2353
- * @returns {void}
2354
- * @private
2355
- */
2356
- private notifyJobStateChange;
2357
- /**
2358
- * Pause a job by ID (sets enabled=false).
2359
- * Notifies any subscribed state listeners.
2360
- * @param {string} id - The job ID to pause
2361
- * @returns {void}
2362
- */
2363
- pauseJob(id: string): void;
2364
- /**
2365
- * Resume a paused job by ID (sets enabled=true).
2366
- * Resets job timing to prevent frame accumulation.
2367
- * Notifies any subscribed state listeners.
2368
- * @param {string} id - The job ID to resume
2369
- * @returns {void}
2370
- */
2371
- resumeJob(id: string): void;
2372
- /**
2373
- * Start the requestAnimationFrame loop.
2374
- * Resets timing state (elapsedTime, frameCount) on start.
2375
- * No-op if already running.
2376
- * @returns {void}
2377
- */
2378
- start(): void;
2379
- /**
2380
- * Stop the requestAnimationFrame loop.
2381
- * Cancels any pending RAF callback.
2382
- * No-op if not running.
2383
- * @returns {void}
2384
- */
2385
- stop(): void;
2386
- /**
2387
- * Request frames to be rendered in demand mode.
2388
- * Accumulates pending frames (capped at 60) and starts the loop if not running.
2389
- * No-op if frameloop is not 'demand'.
2390
- * @param {number} [frames=1] - Number of frames to request
2391
- * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
2392
- * - `false` (default): Sets pending frames to the specified value (replaces existing count)
2393
- * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
2394
- * @returns {void}
2395
- * @example
2396
- * // Request a single frame render
2397
- * scheduler.invalidate();
2398
- *
2399
- * @example
2400
- * // Request 5 frames (e.g., for animations)
2401
- * scheduler.invalidate(5);
2402
- *
2403
- * @example
2404
- * // Set pending frames to exactly 3 (don't stack with existing)
2405
- * scheduler.invalidate(3, false);
2406
- *
2407
- * @example
2408
- * // Add 2 more frames to existing pending count
2409
- * scheduler.invalidate(2, true);
2410
- */
2411
- invalidate(frames?: number, stackFrames?: boolean): void;
2412
- /**
2413
- * Reset timing state for deterministic testing.
2414
- * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
2415
- * @returns {void}
2416
- */
2417
- resetTiming(): void;
2418
- /**
2419
- * Manually execute a single frame for all roots.
2420
- * Useful for frameloop='never' mode or testing scenarios.
2421
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2422
- * @returns {void}
2423
- * @example
2424
- * // Manual control mode
2425
- * scheduler.frameloop = 'never';
2426
- * scheduler.step(); // Execute one frame
2427
- */
2428
- step(timestamp?: number): void;
2429
- /**
2430
- * Manually execute a single job by its ID.
2431
- * Useful for testing individual job callbacks in isolation.
2432
- * @param {string} id - The job ID to step
2433
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2434
- * @returns {void}
2435
- */
2436
- stepJob(id: string, timestamp?: number): void;
2437
- /**
2438
- * Main RAF loop callback.
2439
- * Executes frame, handles demand mode, and schedules next frame.
2440
- * @param {number} timestamp - RAF timestamp in milliseconds
2441
- * @returns {void}
2442
- * @private
2443
- */
2444
- private loop;
2445
- /**
2446
- * Execute a single frame across all roots.
2447
- * Order: globalBefore → each root's jobs → globalAfter
2448
- * @param {number} timestamp - RAF timestamp in milliseconds
2449
- * @returns {void}
2450
- * @private
2451
- */
2452
- private executeFrame;
2453
- /**
2454
- * Run all global jobs from a job map.
2455
- * Catches and logs errors without stopping execution.
2456
- * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
2457
- * @param {number} timestamp - RAF timestamp in milliseconds
2458
- * @returns {void}
2459
- * @private
2460
- */
2461
- private runGlobalJobs;
2462
- /**
2463
- * Execute all jobs for a single root in sorted order.
2464
- * Rebuilds sorted job list if needed, then dispatches each job.
2465
- * Errors are caught and propagated via triggerError.
2466
- * @param {RootEntry} root - The root entry to tick
2467
- * @param {number} timestamp - RAF timestamp in milliseconds
2468
- * @param {number} delta - Time since last frame in seconds
2469
- * @returns {void}
2470
- * @private
2471
- */
2472
- private tickRoot;
2473
- /**
2474
- * Get the total number of registered jobs across all roots.
2475
- * Includes both per-root jobs and global before/after jobs.
2476
- * @returns {number} Total job count
2477
- */
2478
- getJobCount(): number;
2479
- /**
2480
- * Get all registered job IDs across all roots.
2481
- * Includes both per-root jobs and global before/after jobs.
2482
- * @returns {string[]} Array of all job IDs
2483
- */
2484
- getJobIds(): string[];
2485
- /**
2486
- * Get the number of registered roots (Canvas instances).
2487
- * @returns {number} Number of registered roots
2488
- */
2489
- getRootCount(): number;
2490
- /**
2491
- * Check if any user (non-system) jobs are registered in a specific phase.
2492
- * Used by the default render job to know if a user has taken over rendering.
2493
- *
2494
- * @param phase The phase to check
2495
- * @param rootId Optional root ID to check (checks all roots if not provided)
2496
- * @returns true if any user jobs exist in the phase
2497
- */
2498
- hasUserJobsInPhase(phase: string, rootId?: string): boolean;
2499
- /**
2500
- * Generate a unique root ID for automatic root registration.
2501
- * @returns {string} A unique root ID in the format 'root_N'
2502
- */
2503
- generateRootId(): string;
2504
- /**
2505
- * Generate a unique job ID.
2506
- * @returns {string} A unique job ID in the format 'job_N'
2507
- * @private
2508
- */
2509
- private generateJobId;
2510
- /**
2511
- * Normalize before/after constraints to a Set.
2512
- * Handles undefined, single string, or array inputs.
2513
- * @param {string | string[] | undefined} value - The constraint value(s)
2514
- * @returns {Set<string>} Normalized Set of constraint strings
2515
- * @private
2516
- */
2517
- private normalizeConstraints;
2518
- }
2519
- /**
2520
- * Get the global scheduler instance.
2521
- * Creates one if it doesn't exist.
2522
- */
2523
- declare const getScheduler: () => Scheduler;
2524
-
2525
- /**
2526
- * Frame hook with phase-based ordering, priority, and FPS throttling.
2527
- *
2528
- * Works both inside and outside Canvas context:
2529
- * - Inside Canvas: Full RootState (gl, scene, camera, etc.)
2530
- * - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
2531
- * - Outside Canvas (independent mode): Fires immediately with timing-only state
2532
- *
2533
- * Returns a controls object for manual stepping, pausing, and resuming.
2534
- *
2535
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
2536
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
2537
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
2538
- *
2539
- * @example
2540
- * // Simple priority (backwards compat)
2541
- * useFrame((state, delta) => { ... }, 5)
2542
- *
2543
- * @example
2544
- * // With phase-based ordering
2545
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
2546
- *
2547
- * @example
2548
- * // Outside Canvas - waits for Canvas to mount
2549
- * function UI() {
2550
- * useFrame((state, delta) => { syncUI(state.camera) });
2551
- * return <button>...</button>;
2552
- * }
2553
- *
2554
- * @example
2555
- * // Independent mode - no Canvas needed
2556
- * getScheduler().independent = true;
2557
- * useFrame((state, delta) => { updateGame(delta) });
2558
- *
2559
- * @example
2560
- * // Scheduler-only access (no callback)
2561
- * const { scheduler } = useFrame()
2562
- * scheduler.pauseJob('some-job-id')
2563
- *
2564
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
2565
- */
2566
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
2567
-
2568
1958
  declare const IsObject: (url: unknown) => url is Record<string, string>;
2569
1959
  type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2570
1960
  type TextureRecord<T> = T extends Record<string, string> ? {
@@ -2750,11 +2140,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
2750
2140
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2751
2141
  */
2752
2142
  declare function useStore(): RootStore;
2753
- /**
2754
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2755
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2756
- */
2757
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2758
2143
  /**
2759
2144
  * Exposes an object's {@link Instance}.
2760
2145
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2830,7 +2215,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2830
2215
  * Invalidates the view, requesting a frame to be rendered.
2831
2216
  * In demand mode, this triggers the scheduler to run frames.
2832
2217
  *
2833
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2218
+ * With a state argument, only that root's jobs run on the requested frames; other
2219
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2220
+ *
2221
+ * @param state - Optional root state; targets the invalidation at that root
2834
2222
  * @param frames - Number of frames to request (default: 1)
2835
2223
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2836
2224
  *
@@ -2841,14 +2229,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2841
2229
  * Advances the frameloop and runs render effects.
2842
2230
  * Useful for when manually rendering via `frameloop="never"`.
2843
2231
  *
2232
+ * With a state argument, only that root is stepped. Without one, every
2233
+ * registered root is stepped for backwards compatibility.
2234
+ *
2844
2235
  * @param timestamp - The timestamp to use for this frame
2845
2236
  * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2846
- * @param state - Ignored (kept for backwards compat)
2847
- * @param frame - Ignored (kept for backwards compat)
2237
+ * @param state - Optional root state; targets the manual step at that root
2848
2238
  *
2849
2239
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2850
2240
  */
2851
- declare function advance(timestamp: number): void;
2241
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2852
2242
 
2853
2243
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2854
2244
  declare function ReactReconciler<
@@ -3893,6 +3283,7 @@ declare namespace ReactReconciler {
3893
3283
 
3894
3284
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3895
3285
  declare function extend<T extends Catalogue>(objects: T): void;
3286
+ declare function extend(objects: Record<string, unknown>): void;
3896
3287
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3897
3288
 
3898
3289
  declare const isRenderer: (def: any) => boolean;
@@ -3919,11 +3310,6 @@ declare function flushSync<R>(fn: () => R): R;
3919
3310
  declare const context: React$1.Context<RootStore>;
3920
3311
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3921
3312
 
3922
- /**
3923
- * Safely flush async effects when testing, simulating a legacy root.
3924
- * @deprecated Import from React instead. import { act } from 'react'
3925
- */
3926
- declare const act: typeof React$1.act;
3927
3313
  /**
3928
3314
  * An SSR-friendly useLayoutEffect.
3929
3315
  *
@@ -4341,29 +3727,44 @@ declare const hasConstructor: (object: unknown) => object is {
4341
3727
  * Used to identify values that should be resolved from refs after mount.
4342
3728
  */
4343
3729
  declare const FROM_REF: unique symbol;
3730
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3731
+ interface FromRefMarker<T = unknown, R = T> {
3732
+ [FROM_REF]: React$1.RefObject<T | null>;
3733
+ /** Optional transform applied to the resolved ref before assignment. */
3734
+ transform?: (value: T) => R;
3735
+ }
4344
3736
  /**
4345
3737
  * Defers prop application until the referenced object is available.
4346
3738
  * Useful for props like `target` that need sibling refs to be populated.
4347
3739
  *
3740
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3741
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3742
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3743
+ * what gets assigned.
3744
+ *
4348
3745
  * @param ref - React ref object to resolve at mount time
4349
- * @returns A marker value that applyProps will resolve after mount
3746
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3747
+ * @returns A marker value that the reconciler resolves after mount
4350
3748
  *
4351
3749
  * @example
4352
3750
  * const targetRef = useRef<THREE.Object3D>(null)
4353
3751
  *
4354
3752
  * <group ref={targetRef} position={[-3, -2, -15]} />
4355
3753
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3754
+ *
3755
+ * @example
3756
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3757
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
4356
3758
  */
4357
3759
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3760
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
4358
3761
  /**
4359
3762
  * Type guard to check if a value is a fromRef marker.
4360
3763
  *
4361
3764
  * @param value - Value to check
4362
3765
  * @returns True if value is a fromRef marker
4363
3766
  */
4364
- declare function isFromRef(value: unknown): value is {
4365
- [FROM_REF]: React$1.RefObject<any>;
4366
- };
3767
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
4367
3768
 
4368
3769
  /**
4369
3770
  * Symbol marker for mount-only method calls.
@@ -4390,7 +3791,15 @@ declare const ONCE: unique symbol;
4390
3791
  * // No arguments
4391
3792
  * <geometry center={once()} />
4392
3793
  */
4393
- declare function once<T>(...args: T[]): T;
3794
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3795
+ /**
3796
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3797
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3798
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3799
+ *
3800
+ * The runtime value is always the marker object; only the declared type follows the prop.
3801
+ */
3802
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
4394
3803
  /**
4395
3804
  * Type guard to check if a value is a once marker.
4396
3805
  *
@@ -4401,11 +3810,8 @@ declare function isOnce(value: unknown): value is {
4401
3810
  [ONCE]: any[] | true;
4402
3811
  };
4403
3812
 
4404
- /**
4405
- * A DOM canvas which accepts threejs elements as children.
4406
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
4407
- */
4408
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3813
+ /** Distinguishes a resource leaf from a nested resource scope. */
3814
+ type ResourceLeafGuard<T> = (value: unknown) => value is T;
4409
3815
 
4410
3816
  /**
4411
3817
  * ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
@@ -4427,33 +3833,30 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
4427
3833
  * ```
4428
3834
  */
4429
3835
 
4430
- /** Keys reserved for methods (excluded from index signature) */
4431
- type MethodKeys = 'scope' | 'has' | 'keys';
4432
3836
  /**
4433
3837
  * Type-safe wrapper interface for accessing nested store data.
4434
3838
  * Property access returns `T` (assumes leaf node).
4435
3839
  * Use `.scope(key)` for nested object access.
4436
3840
  *
4437
- * Uses mapped type with key filtering to exclude method names from index signature,
4438
- * allowing methods to have their correct return types.
4439
3841
  */
4440
- type ScopedStoreType<T> = {
4441
- /** Direct property access returns the leaf type T (method keys excluded) */
4442
- readonly [K in string as K extends MethodKeys ? never : K]: T;
4443
- } & {
3842
+ type ScopedStoreMethods<TLeaf> = {
4444
3843
  /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
4445
- scope(key: string): ScopedStoreType<T>;
3844
+ scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
4446
3845
  /** Check if a key exists in the store */
4447
3846
  has(key: string): boolean;
4448
3847
  /** Get all keys in the store */
4449
3848
  keys(): string[];
4450
3849
  };
3850
+ type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
3851
+ interface ScopedStoreData<TLeaf> {
3852
+ [key: string]: TLeaf | ScopedStoreData<TLeaf>;
3853
+ }
4451
3854
  /**
4452
3855
  * Create a type-safe ScopedStore wrapper around store data.
4453
3856
  * @param data - The raw store data (uniforms or nodes from RootState)
4454
3857
  * @returns A ScopedStoreType wrapper with type-safe access
4455
3858
  */
4456
- declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
3859
+ declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
4457
3860
  /**
4458
3861
  * State type passed to creator functions with ScopedStore wrappers.
4459
3862
  * Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
@@ -4461,8 +3864,8 @@ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreTyp
4461
3864
  type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
4462
3865
  /** Type-safe uniform access - property access returns UniformNode */
4463
3866
  uniforms: ScopedStoreType<UniformNode>;
4464
- /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
4465
- nodes: ScopedStoreType<TSLNodeType>;
3867
+ /** Type-safe node access for real, callable, and legacy structural nodes */
3868
+ nodes: ScopedStoreType<NodeLike>;
4466
3869
  /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
4467
3870
  buffers: ScopedStoreType<BufferLike>;
4468
3871
  /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
@@ -4478,22 +3881,26 @@ type ClearUniformsFn = (scope?: string) => void;
4478
3881
  /** Function signature for rebuildUniforms util */
4479
3882
  type RebuildUniformsFn = (scope?: string) => void;
4480
3883
  /** Return type with utils included */
4481
- type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
3884
+ type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
4482
3885
  removeUniforms: RemoveUniformsFn;
4483
3886
  clearUniforms: ClearUniformsFn;
4484
3887
  rebuildUniforms: RebuildUniformsFn;
4485
3888
  };
4486
- declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
3889
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
3890
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
3891
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
3892
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
3893
+ declare function useUniforms(): UniformsWithUtils<UniformStore>;
4487
3894
  declare function useUniforms(scope: string): UniformsWithUtils;
4488
- declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformRecord<UniformNode>>;
4489
- declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4490
- declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
4491
- declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
3895
+ declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
4492
3896
  /**
4493
3897
  * Global rebuildUniforms function for HMR integration.
4494
- * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
3898
+ * Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
4495
3899
  * Call this when HMR is detected to refresh all uniform creators.
4496
3900
  *
3901
+ * Resolves to the primary store so shared TSL resources rebuild on the
3902
+ * authoritative store.
3903
+ *
4497
3904
  * @param store - The R3F store (from useStore or context)
4498
3905
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4499
3906
  */
@@ -4516,47 +3923,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
4516
3923
 
4517
3924
  /**
4518
3925
  * Supported uniform value types:
4519
- * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
3926
+ * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
4520
3927
  * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
4521
3928
  * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
4522
3929
  * - UniformNode: existing uniforms (reused as-is)
4523
3930
  */
4524
- type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
4525
- /**
4526
- * Widen literal types to their base types:
4527
- * - 0 → number
4528
- * - true → boolean
4529
- * - '#ff0000' → Color (string colors are converted to Color objects)
4530
- * - Node → Node (TSL nodes passed through for uniform type casting)
4531
- */
4532
- type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
4533
- declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
4534
- declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
3931
+ type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
3932
+ declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
3933
+ declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
4535
3934
 
4536
3935
  /**
4537
- * Minimal interface for TSL nodes.
4538
- * Used instead of Three.js's Node type because the @types/three definitions
4539
- * have inconsistencies where OperatorNode, ConstNode, etc. don't properly
4540
- * extend Node with all required properties.
3936
+ * Every node representation a creator may return. The definition lives with the store types as
3937
+ * `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
3938
+ * construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
3939
+ * `{ uuid, nodeType }` shape.
4541
3940
  */
4542
- interface TSLNodeLike {
4543
- uuid?: string;
4544
- nodeType?: string | null;
4545
- /** label method for chaining - sets the node's label and returns self */
4546
- label?: ((label: string) => TSLNodeLike) | string;
4547
- setName?: (name: string) => this;
4548
- }
4549
- /** TSL node type - alias for compatibility */
3941
+ type TSLNodeLike = NodeLike;
3942
+
3943
+ /** Backward-compatible alias covering every accepted node representation. */
4550
3944
  type TSLNode = TSLNodeLike;
4551
- /**
4552
- * A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
4553
- * Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
4554
- */
4555
- type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
4556
3945
  /**
4557
3946
  * Creator function that returns a record of nodes.
4558
- * Uses TSLNodeLike constraint to allow mixed node types
4559
- * (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
3947
+ * Exact creator return inference is preserved within the compatible node constraint.
4560
3948
  */
4561
3949
  type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
4562
3950
  /** Function signature for removeNodes util */
@@ -4566,20 +3954,25 @@ type ClearNodesFn = (scope?: string) => void;
4566
3954
  /** Function signature for rebuildNodes util */
4567
3955
  type RebuildNodesFn = (scope?: string) => void;
4568
3956
  /** Return type with utils included */
4569
- type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
3957
+ type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
4570
3958
  removeNodes: RemoveNodesFn;
4571
3959
  clearNodes: ClearNodesFn;
4572
3960
  rebuildNodes: RebuildNodesFn;
4573
3961
  };
4574
- declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
4575
- declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
4576
- declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
4577
- declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
3962
+ declare function useNodes(): NodesWithUtils<NodeStore>;
3963
+ declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
3964
+ declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
3965
+ declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
3966
+ declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
3967
+ declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
4578
3968
  /**
4579
3969
  * Global rebuildNodes function for HMR integration.
4580
- * Clears cached nodes and increments _hmrVersion to trigger re-creation.
3970
+ * Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
4581
3971
  * Call this when HMR is detected to refresh all node creators.
4582
3972
  *
3973
+ * Resolves to the primary store so shared TSL resources rebuild on the
3974
+ * authoritative store.
3975
+ *
4583
3976
  * @param store - The R3F store (from useStore or context)
4584
3977
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4585
3978
  */
@@ -4630,6 +4023,10 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
4630
4023
  */
4631
4024
  declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
4632
4025
 
4026
+ /**
4027
+ * A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
4028
+ */
4029
+ type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
4633
4030
  /**
4634
4031
  * Creator function that returns a record of buffers.
4635
4032
  * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
@@ -4644,26 +4041,34 @@ type RebuildBuffersFn = (scope?: string) => void;
4644
4041
  /** Function signature for disposeBuffers util - releases GPU resources */
4645
4042
  type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
4646
4043
  /** Return type with utils included */
4647
- type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
4044
+ type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
4648
4045
  removeBuffers: RemoveBuffersFn;
4649
4046
  clearBuffers: ClearBuffersFn;
4650
4047
  rebuildBuffers: RebuildBuffersFn;
4651
4048
  disposeBuffers: DisposeBuffersFn;
4652
4049
  };
4653
- declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
4050
+ declare function useBuffers(): BuffersWithUtils<BufferStore>;
4654
4051
  declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
4052
+ declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
4655
4053
  declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
4656
4054
  declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
4657
4055
  /**
4658
4056
  * Global rebuildBuffers function for HMR integration.
4659
- * Clears cached buffers and increments _hmrVersion to trigger re-creation.
4057
+ * Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
4660
4058
  * Call this when HMR is detected to refresh all buffer creators.
4661
4059
  *
4060
+ * Resolves to the primary store so shared TSL resources rebuild on the
4061
+ * authoritative store.
4062
+ *
4662
4063
  * @param store - The R3F store (from useStore or context)
4663
4064
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4664
4065
  */
4665
4066
  declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
4666
4067
 
4068
+ /**
4069
+ * A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
4070
+ */
4071
+ type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
4667
4072
  /**
4668
4073
  * Creator function that returns a record of GPU storage objects.
4669
4074
  * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
@@ -4678,26 +4083,47 @@ type RebuildStorageFn = (scope?: string) => void;
4678
4083
  /** Function signature for disposeStorage util - releases GPU resources */
4679
4084
  type DisposeStorageFn = (names: string | string[], scope?: string) => void;
4680
4085
  /** Return type with utils included */
4681
- type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
4086
+ type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
4682
4087
  removeStorage: RemoveStorageFn;
4683
4088
  clearStorage: ClearStorageFn;
4684
4089
  rebuildStorage: RebuildStorageFn;
4685
4090
  disposeStorage: DisposeStorageFn;
4686
4091
  };
4687
- declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
4092
+ declare function useGPUStorage(): StorageWithUtils<StorageStore>;
4688
4093
  declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
4094
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
4689
4095
  declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
4690
4096
  declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
4691
4097
  /**
4692
4098
  * Global rebuildStorage function for HMR integration.
4693
- * Clears cached storage and increments _hmrVersion to trigger re-creation.
4099
+ * Invalidates cached storage and increments _hmrVersion to trigger re-creation.
4694
4100
  * Call this when HMR is detected to refresh all storage creators.
4695
4101
  *
4102
+ * Resolves to the primary store so shared TSL resources rebuild on the
4103
+ * authoritative store.
4104
+ *
4696
4105
  * @param store - The R3F store (from useStore or context)
4697
4106
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4698
4107
  */
4699
4108
  declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
4700
4109
 
4110
+ /**
4111
+ * Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
4112
+ *
4113
+ * This file maintains backwards compatibility for existing webgpu imports.
4114
+ */
4115
+
4116
+ /**
4117
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4118
+ * Kept as an alias for backwards compatibility.
4119
+ */
4120
+ type TextureEntry = Texture$1;
4121
+ /**
4122
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4123
+ * Kept as an alias for backwards compatibility.
4124
+ */
4125
+ type TextureNode = Texture$1;
4126
+
4701
4127
  interface TextureOperations {
4702
4128
  add: (key: string, value: any) => void;
4703
4129
  addMultiple: (items: Map<string, any> | Record<string, any>) => void;
@@ -4715,6 +4141,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
4715
4141
  * - Callbacks receive full RootState for flexibility
4716
4142
  * - No auto-cleanup on unmount - use reset() for explicit cleanup
4717
4143
  * - Scene/camera changes trigger scenePass recreation
4144
+ * - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
4145
+ * strand its render target (and MRT attachments) on the GPU
4146
+ * - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
4147
+ * recompiles instead of silently keeping the first compiled graph
4718
4148
  *
4719
4149
  * @param mainCB - Main callback to configure outputNode and create effect passes
4720
4150
  * @param setupCB - Optional setup callback to configure MRT on scenePass
@@ -4792,5 +4222,32 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
4792
4222
  internal: WebGPUInternalState
4793
4223
  }
4794
4224
 
4795
- export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
4796
- export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureInput, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
4225
+ /**
4226
+ * @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
4227
+ *
4228
+ * This entry point is for apps that want to use ONLY WebGPURenderer.
4229
+ * Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
4230
+ * Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
4231
+ *
4232
+ * Usage:
4233
+ * import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
4234
+ */
4235
+
4236
+ /** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
4237
+ type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
4238
+ /** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
4239
+ type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
4240
+ declare const useThree: UseThreeWebGPU;
4241
+ declare const useFrame: UseFrameWebGPU;
4242
+
4243
+ /** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
4244
+ type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
4245
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
4246
+ onCreated?: (state: WebGPURootState) => void;
4247
+ };
4248
+
4249
+ /** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
4250
+ declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
4251
+
4252
+ export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
4253
+ export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, WebGPUCanvasProps as CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeLike, NodeProps, NodeRecord, NodeStore, NodesWithUtils, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TSLNodeLike, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };