@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,9 +8,10 @@ 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
17
  function _mergeNamespaces(n, m) {
@@ -39,6 +41,8 @@ function _mergeNamespaces(n, m) {
39
41
  declare const R3F_BUILD_LEGACY = false;
40
42
  declare const R3F_BUILD_WEBGPU = true;
41
43
 
44
+ /** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
45
+ declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
42
46
  declare const WebGLRenderer: {
43
47
  new (): {};
44
48
  };
@@ -47,16 +51,21 @@ type WebGLShadowMap = never;
47
51
 
48
52
  declare const WebGLRenderTarget: any;
49
53
 
54
+ declare const WebGLCubeRenderTarget: any;
55
+
50
56
  var THREE = /*#__PURE__*/_mergeNamespaces({
51
57
  __proto__: null,
58
+ CubeRenderTargetCompat: CubeRenderTarget,
52
59
  Inspector: Inspector,
53
60
  R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
54
61
  R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
55
62
  RenderTargetCompat: RenderTarget,
63
+ WebGLCubeRenderTarget: WebGLCubeRenderTarget,
56
64
  WebGLRenderTarget: WebGLRenderTarget,
57
65
  WebGLRenderer: WebGLRenderer,
58
66
  WebGLRendererParameters: WebGLRendererParameters,
59
- WebGLShadowMap: WebGLShadowMap
67
+ WebGLShadowMap: WebGLShadowMap,
68
+ loadInspector: loadInspector
60
69
  }, [three_webgpu]);
61
70
 
62
71
  //* Utility Types ==============================
@@ -294,228 +303,33 @@ interface VisibilityEntry {
294
303
  }
295
304
 
296
305
  //* Scheduler Types (useFrame) ==============================
306
+ //
307
+ // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
308
+ // This file re-exports them and layers r3f's RootState-aware frame state on top,
309
+ // so existing `#types` imports across the codebase keep resolving unchanged.
297
310
 
298
311
 
299
312
 
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
- }
313
+ // Frame State (r3f-specific) --------------------------------
352
314
 
353
315
  /**
354
- * State passed to useFrame callbacks (extends RootState with timing)
316
+ * State passed to useFrame callbacks (extends RootState with timing).
355
317
  */
356
318
  interface FrameNextState extends RootState, FrameTimingState {}
357
319
 
358
320
  /** Alias for FrameNextState */
359
321
  type FrameState = FrameNextState
360
322
 
361
- // Root Options --------------------------------
323
+ // Callback Types (r3f-specific) --------------------------------
362
324
 
363
325
  /**
364
- * Options for registerRoot
326
+ * Callback function for useFrame. Receives the full r3f RootState plus timing.
365
327
  */
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 --------------------------------
374
-
375
- /**
376
- * Callback function for useFrame
377
- */
378
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
328
+ type FrameNextCallback = FrameCallback$1<RootState>
379
329
 
380
330
  /** Alias for FrameNextCallback */
381
331
  type FrameCallback = FrameNextCallback
382
332
 
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
333
  //* Buffer Types (useBuffers) ========================================
520
334
 
521
335
  /**
@@ -540,6 +354,7 @@ type BufferLike =
540
354
  | Uint16Array
541
355
  | Int16Array
542
356
  | THREE$1.BufferAttribute // Base class for all buffer attributes
357
+ | THREE$1.InterleavedBufferAttribute
543
358
  | Node // TSL buffer nodes (instancedArray, storage)
544
359
 
545
360
  /** Flat record of buffer-like values (no nested scopes) */
@@ -551,6 +366,25 @@ type BufferRecord = Record<string, BufferLike>
551
366
  */
552
367
  type BufferStore = Record<string, BufferLike | BufferRecord>
553
368
 
369
+ //* Node Types (useNodes) ========================================
370
+
371
+ /**
372
+ * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
373
+ * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
374
+ * code passes through. Creators are constrained to this same type, so the shape a creator returns
375
+ * and the shape the store holds are one type by construction.
376
+ */
377
+ type NodeLike = TSLNodeType | LegacyTSLNodeLike
378
+
379
+ /** Flat record of TSL nodes (no nested scopes) */
380
+ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
381
+
382
+ /**
383
+ * Node store that can contain both root-level nodes and scoped node objects.
384
+ * Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
385
+ */
386
+ type NodeStore = Record<string, NodeLike | NodeRecord>
387
+
554
388
  //* Storage Types (useGPUStorage) ========================================
555
389
 
556
390
  /**
@@ -565,7 +399,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
565
399
  * ```
566
400
  */
567
401
  type StorageLike =
568
- | StorageTexture // GPU storage texture
402
+ | StorageTexture // 2D GPU storage texture
403
+ | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
404
+ | StorageArrayTexture // 2D-array GPU storage texture
569
405
  | Data3DTexture // 3D texture (can be used as storage)
570
406
  | Node // TSL storage texture nodes (storageTexture)
571
407
 
@@ -684,14 +520,31 @@ interface InternalState {
684
520
  /** Container for child attachment (scene for root, original container for portals) */
685
521
  container?: THREE$1.Object3D
686
522
  /**
687
- * CanvasTarget for multi-canvas WebGPU rendering.
688
- * Created for all WebGPU canvases to support renderer sharing.
523
+ * The CanvasTarget this root sizes and renders through.
524
+ *
525
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
526
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
527
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
528
+ * and the canvas-target job makes it the renderer's active one before this root renders.
529
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
689
530
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
690
531
  */
691
532
  canvasTarget?: CanvasTarget
533
+ /**
534
+ * Set when this root's canvas target has been resized and the backend's cached render pass
535
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
536
+ *
537
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
538
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
539
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
540
+ * invalidate some other canvas's descriptor instead.
541
+ *
542
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
543
+ */
544
+ canvasTargetSizeDirty?: boolean
692
545
  /**
693
546
  * Whether multi-canvas rendering is active.
694
- * True when any canvas uses `target` prop to share a renderer.
547
+ * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
695
548
  * When true, setCanvasTarget is called before each render.
696
549
  */
697
550
  isMultiCanvas?: boolean
@@ -789,8 +642,8 @@ interface RootState {
789
642
  setSize: (width?: number, height?: number, top?: number, left?: number) => void
790
643
  /** Shortcut to manual setting the pixel ratio */
791
644
  setDpr: (dpr: Dpr) => void
792
- /** Shortcut to setting frameloop flags */
793
- setFrameloop: (frameloop: Frameloop) => void
645
+ /** Shortcut to setting frameloop flags. No args resets to 'always'. */
646
+ setFrameloop: (frameloop?: Frameloop) => void
794
647
  /** Set error state to propagate to error boundary */
795
648
  setError: (error: Error | null) => void
796
649
  /** Current error state (null when no error) */
@@ -798,7 +651,7 @@ interface RootState {
798
651
  /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
799
652
  uniforms: UniformStore
800
653
  /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
801
- nodes: Record<string, any>
654
+ nodes: NodeStore
802
655
  /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
803
656
  buffers: BufferStore
804
657
  /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
@@ -808,9 +661,9 @@ interface RootState {
808
661
  /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
809
662
  _textureRefs: Map<string, number>
810
663
  /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
811
- renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
664
+ renderPipeline: ThreeRenderPipeline | null
812
665
  /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
813
- passes: Record<string, any>
666
+ passes: PassRecord
814
667
  /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
815
668
  _hmrVersion: number
816
669
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
@@ -898,12 +751,19 @@ type DefaultRendererProps = {
898
751
  */
899
752
  interface CanvasSchedulerConfig {
900
753
  /**
901
- * Render this canvas after another canvas completes.
902
- * Pass the `id` of another canvas.
754
+ * Run this Canvas root before the referenced Canvas root id(s).
903
755
  */
904
- after?: string
756
+ before?: string | string[]
905
757
  /**
906
- * Limit this canvas's render rate (frames per second).
758
+ * Run this Canvas root after the referenced Canvas root id(s).
759
+ */
760
+ after?: string | string[]
761
+ /**
762
+ * Numeric root order. Lower values run first.
763
+ */
764
+ order?: number
765
+ /**
766
+ * Limit this Canvas's default render job (frames per second).
907
767
  */
908
768
  fps?: number
909
769
  }
@@ -990,14 +850,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
990
850
  performance?: Partial<Omit<Performance, 'regress'>>
991
851
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
992
852
  dpr?: Dpr
993
- /** Props that go into the default raycaster */
994
- raycaster?: Partial<THREE$1.Raycaster>
853
+ /**
854
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
855
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
856
+ */
857
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
995
858
  /** A `THREE.Scene` instance or props that go into the default scene */
996
859
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
997
860
  /** A `THREE.Camera` instance or props that go into the default camera */
998
861
  camera?: CameraProps
999
862
  /** An R3F event manager to manage elements' pointer events */
1000
- events?: (store: RootStore) => EventManager<HTMLElement>
863
+ events?: (store: RootStore) => EventManager<Element>
1001
864
  /** Callback after the canvas has rendered (but not yet committed) */
1002
865
  onCreated?: (state: RootState) => void
1003
866
  /** Response for pointer clicks that have missed any target */
@@ -1101,8 +964,6 @@ interface Instance<O = any> {
1101
964
  attach?: AttachType<O>
1102
965
  previousAttach?: any
1103
966
  isHidden: boolean
1104
- /** Deferred ref props to apply in commitMount */
1105
- deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
1106
967
  /** Set of props that have been applied via once() */
1107
968
  appliedOnce?: Set<string>
1108
969
  }
@@ -1228,7 +1089,7 @@ interface CanvasProps
1228
1089
  */
1229
1090
  resize?: Options
1230
1091
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1231
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1092
+ eventSource?: Element | React$1.RefObject<Element | null>
1232
1093
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1233
1094
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1234
1095
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1336,70 +1197,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1336
1197
 
1337
1198
  type RenderTargetOptions = RenderTargetOptions$1
1338
1199
 
1339
- //* Global Types ==============================
1200
+ //* Global TSL Types ==============================
1340
1201
 
1341
1202
  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
1203
  /**
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
- * ```
1204
+ * Broad callable-node fallback for dynamic store readers.
1205
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1365
1206
  */
1366
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1207
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1208
+ readonly shaderNode: unknown
1209
+ readonly id: number
1210
+ }
1367
1211
 
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>
1212
+ /** Legacy structural node accepted when at least one historical marker exists. */
1213
+ type LegacyTSLNodeLike = {
1214
+ label?: ((label: string) => unknown) | string
1215
+ setName?: (name: string) => unknown
1216
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1217
+
1218
+ /** Node type accepted by broad dynamic node-store readers. */
1219
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1378
1220
 
1379
1221
  /**
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
- * ```
1222
+ * Derive Three's shader node type from an existing node or a supported raw input.
1223
+ * Existing InputNode generics take precedence over structural value normalization.
1224
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1225
+ * InputNode base with its concrete InputNode specialization.
1401
1226
  */
1402
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1227
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1228
+ ? TNodeType
1229
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1230
+ ? TNodeType
1231
+ : T extends number
1232
+ ? 'float'
1233
+ : T extends boolean
1234
+ ? 'bool'
1235
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1236
+ ? 'color'
1237
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1238
+ ? 'vec4'
1239
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1240
+ ? 'vec3'
1241
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1242
+ ? 'vec2'
1243
+ : T extends three_webgpu.Matrix4
1244
+ ? 'mat4'
1245
+ : T extends three_webgpu.Matrix3
1246
+ ? 'mat3'
1247
+ : T extends three_webgpu.Matrix2
1248
+ ? 'mat2'
1249
+ : unknown
1250
+
1251
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1252
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1253
+ ? TValue
1254
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1255
+ ? TValue
1256
+ : T extends string | { r: number; g: number; b: number }
1257
+ ? three_webgpu.Color
1258
+ : T extends { x: number; y: number; z: number; w: number }
1259
+ ? three_webgpu.Vector4
1260
+ : T extends { x: number; y: number; z: number }
1261
+ ? three_webgpu.Vector3
1262
+ : T extends { x: number; y: number }
1263
+ ? three_webgpu.Vector2
1264
+ : T extends number
1265
+ ? number
1266
+ : T extends boolean
1267
+ ? boolean
1268
+ : T
1269
+
1270
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1271
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1272
+
1273
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1274
+ type UniformNodesFor<T extends UniformInputRecord> = {
1275
+ [K in keyof T]: UniformNodeFor<T[K]>
1276
+ }
1277
+
1278
+ /** Backward-compatible single-parameter uniform alias. */
1279
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1403
1280
 
1404
1281
  /** Flat record of uniform nodes (no nested scopes) */
1405
1282
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1424,7 +1301,7 @@ declare global {
1424
1301
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1425
1302
  * Supports:
1426
1303
  * - Primitives: number, string (color), boolean
1427
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1304
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1428
1305
  * - Plain objects: { x, y, z, w } converted to vectors
1429
1306
  * - TSL nodes: color(), vec3(), float() for type casting
1430
1307
  * - UniformNode: existing uniforms (reused as-is)
@@ -1437,227 +1314,124 @@ declare global {
1437
1314
  | three_webgpu.Vector2
1438
1315
  | three_webgpu.Vector3
1439
1316
  | three_webgpu.Vector4
1317
+ | three_webgpu.Matrix2
1440
1318
  | three_webgpu.Matrix3
1441
1319
  | 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
1320
+ | { x: number; y: number }
1321
+ | { x: number; y: number; z: number }
1322
+ | { x: number; y: number; z: number; w: number }
1445
1323
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1446
- | Node // TSL nodes like color(), vec3(), float() for type casting
1324
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1447
1325
  | UniformNode
1448
1326
 
1449
1327
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1450
1328
  type UniformInputRecord = Record<string, UniformValue>
1451
1329
  }
1452
1330
 
1453
- //* Module Augmentation ==============================
1454
-
1455
- declare module 'three/tsl' {
1331
+ declare global {
1456
1332
  /**
1457
- * Fn with array parameter destructuring
1458
- * @example Fn(([uv, skew]) => { ... })
1333
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1334
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1335
+ * is r185, so the new name is the only one.
1459
1336
  */
1460
- export function Fn<R extends Node = Node>(
1461
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1462
- ): ShaderCallable<R>
1337
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1463
1338
 
1464
1339
  /**
1465
- * Fn with object parameter destructuring
1466
- * @example Fn(({ color, intensity }) => { ... })
1340
+ * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1341
+ * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1342
+ * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1467
1343
  */
1468
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1469
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1470
- ): ShaderCallable<R>
1344
+ type ScenePassNode = three_webgpu.PassNode
1471
1345
 
1472
1346
  /**
1473
- * Fn with array params + layout
1474
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1347
+ * Pass record - stores TSL pass nodes for render pipeline.
1348
+ *
1349
+ * `scenePass` is the only key the library owns. It is optional here because this is also the
1350
+ * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1351
+ * or `clearPasses()`. Inside the callbacks it is always present; see
1352
+ * {@link RenderPipelineCallbackState}.
1353
+ *
1354
+ * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1355
+ * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1356
+ * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1357
+ * site when you need a member, e.g. `passes.velocity as TextureNode`.
1358
+ *
1359
+ * The index signature admits `undefined` because a key may simply not be registered, and
1360
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1361
+ * optional property whose type excludes `undefined` from the index signature is an error
1362
+ * (TS2411) for every consumer compiling these declarations.
1475
1363
  */
1476
- export function Fn<R extends Node = Node>(
1477
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1478
- layout: { layout?: unknown },
1479
- ): ShaderCallable<R>
1364
+ interface PassRecord {
1365
+ scenePass?: ScenePassNode
1366
+ [key: string]: three_webgpu.Node | undefined
1367
+ }
1480
1368
 
1481
1369
  /**
1482
- * Fn with object params + layout
1370
+ * State passed to pipeline callbacks after the active pipeline has been created.
1371
+ *
1372
+ * `passes.scenePass` is required here: the hook installs the default scene pass before either
1373
+ * callback runs, so callbacks can use it without a guard or a cast.
1374
+ *
1375
+ * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1376
+ * the legacy renderer before either callback can run, so a callback never sees WebGL.
1483
1377
  */
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
-
1378
+ type RenderPipelineCallbackState = RootState & {
1379
+ renderPipeline: ThreeRenderPipeline
1380
+ passes: PassRecord & { scenePass: ScenePassNode }
1381
+ renderer: three_webgpu.WebGPURenderer
1382
+ isLegacy: false
1383
+ }
1495
1384
 
1496
- declare global {
1497
- /** Pass record - stores TSL pass nodes for render pipeline */
1498
- type PassRecord = Record<string, any>
1385
+ /**
1386
+ * What a callback may return to register entries into `state.passes`.
1387
+ *
1388
+ * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1389
+ * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1390
+ * store entry would leave the store pointing at a node the hook never disposes, and the hook
1391
+ * disposing a pass nothing references. So returning it is a type error.
1392
+ */
1393
+ type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1499
1394
 
1500
1395
  /** Setup callback - runs first to configure MRT, create additional passes */
1501
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1396
+ type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1502
1397
 
1503
1398
  /** Main callback - runs second to configure outputNode, create effect passes */
1504
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1399
+ type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1505
1400
 
1506
- /** Return type for useRenderPipeline hook */
1507
- interface UseRenderPipelineReturn {
1401
+ /** The imperative half of useRenderPipeline's return value, present in every state */
1402
+ interface UseRenderPipelineActions {
1508
1403
  /** Current passes from state */
1509
1404
  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
1405
  /** Clear all passes from state */
1513
1406
  clearPasses: () => void
1514
1407
  /** Reset RenderPipeline entirely (clears PP + passes) */
1515
1408
  reset: () => void
1516
1409
  /** Re-run setup/main callbacks with current closure values */
1517
1410
  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
1411
  }
1641
1412
 
1642
- // HMR Support --------------------------------
1643
-
1644
1413
  /**
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
1414
+ * Return type for useRenderPipeline hook, discriminated on `isReady`.
1415
+ *
1416
+ * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1417
+ * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1418
+ * `clearPasses()` empties the record while leaving the pipeline in place.
1659
1419
  */
1660
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1420
+ type UseRenderPipelineReturn = UseRenderPipelineActions &
1421
+ (
1422
+ | {
1423
+ /** True when RenderPipeline is configured and ready */
1424
+ isReady: true
1425
+ /** RenderPipeline instance */
1426
+ renderPipeline: ThreeRenderPipeline
1427
+ }
1428
+ | {
1429
+ /** False until the pipeline has been created */
1430
+ isReady: false
1431
+ /** Not initialized yet, or torn down by reset() */
1432
+ renderPipeline: null
1433
+ }
1434
+ )
1661
1435
  }
1662
1436
 
1663
1437
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
@@ -1736,10 +1510,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1736
1510
 
1737
1511
  /**
1738
1512
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1739
- * since @types/three has broken inheritance for TSL node subclasses.
1513
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1514
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1740
1515
  */
1741
1516
  type NodeProps<P> = {
1742
- [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1517
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1743
1518
  }
1744
1519
 
1745
1520
  interface ReactProps<P> {
@@ -1760,11 +1535,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1760
1535
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1761
1536
  }
1762
1537
 
1538
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1539
+ type Object3DMethod = NonNullable<
1540
+ {
1541
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1542
+ }[keyof Object3D]
1543
+ >
1544
+
1763
1545
  type ThreeExports = typeof THREE
1764
1546
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1765
1547
 
1766
1548
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1767
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1549
+ /**
1550
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1551
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1552
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1553
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1554
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1555
+ */
1556
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
1557
+ object: object
1558
+ ref?: React.Ref<any>
1559
+ onUpdate?: (self: any) => void
1560
+ [prop: string]: unknown
1561
+ }
1768
1562
  // Conflicts with DOM types can be accessed through a three* prefix
1769
1563
  threeAudio: ThreeElementsImpl['audio']
1770
1564
  threeSource: ThreeElementsImpl['source']
@@ -1805,6 +1599,7 @@ type three_d_Matrix3 = Matrix3;
1805
1599
  type three_d_Matrix4 = Matrix4;
1806
1600
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1807
1601
  type three_d_NodeProps<P> = NodeProps<P>;
1602
+ type three_d_Object3DMethod = Object3DMethod;
1808
1603
  type three_d_Quaternion = Quaternion;
1809
1604
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1810
1605
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1819,7 +1614,7 @@ type three_d_Vector3 = Vector3;
1819
1614
  type three_d_Vector4 = Vector4;
1820
1615
  type three_d_VectorRepresentation = VectorRepresentation;
1821
1616
  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 };
1617
+ 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
1618
  }
1824
1619
 
1825
1620
  /**
@@ -1829,7 +1624,7 @@ declare namespace three_d {
1829
1624
  * a single WebGPURenderer using Three.js CanvasTarget API.
1830
1625
  *
1831
1626
  * Primary canvas: Has `id` prop, creates its own renderer, registers here
1832
- * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1627
+ * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1833
1628
  */
1834
1629
 
1835
1630
  interface PrimaryCanvasEntry {
@@ -1897,12 +1692,23 @@ type EnvironmentLoaderProps = {
1897
1692
  * const texture = useEnvironment({ preset: 'sunset' })
1898
1693
  * ```
1899
1694
  */
1900
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1695
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1901
1696
  declare namespace useEnvironment {
1902
1697
  var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1903
1698
  var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1904
1699
  }
1905
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1700
+ /**
1701
+ * Options accepted by `useEnvironment.preload`.
1702
+ *
1703
+ * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1704
+ * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1705
+ * advertise an option this function silently ignores.
1706
+ *
1707
+ * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1708
+ * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1709
+ * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1710
+ */
1711
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1906
1712
  type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1907
1713
 
1908
1714
  /**
@@ -1946,9 +1752,9 @@ type EnvironmentProps = {
1946
1752
  blur?: number;
1947
1753
  backgroundBlurriness?: number;
1948
1754
  backgroundIntensity?: number;
1949
- backgroundRotation?: Euler$3;
1755
+ backgroundRotation?: Euler;
1950
1756
  environmentIntensity?: number;
1951
- environmentRotation?: Euler$3;
1757
+ environmentRotation?: Euler;
1952
1758
  map?: Texture$1;
1953
1759
  preset?: PresetsType;
1954
1760
  scene?: Scene | React$1.RefObject<Scene>;
@@ -2032,7 +1838,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
2032
1838
  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
1839
  declare module '@react-three/fiber' {
2034
1840
  interface ThreeElements {
2035
- groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
1841
+ groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
2036
1842
  }
2037
1843
  }
2038
1844
  /**
@@ -2132,6 +1938,24 @@ declare module '@react-three/fiber' {
2132
1938
  */
2133
1939
  declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
2134
1940
 
1941
+ /**
1942
+ * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1943
+ *
1944
+ * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1945
+ * instance. Removing the old object from the interaction state and registering the new one from
1946
+ * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1947
+ * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1948
+ * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1949
+ * swap the user never asked to see (#3744).
1950
+ *
1951
+ * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1952
+ * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1953
+ *
1954
+ * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1955
+ * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1956
+ * cannot outlive the object it described.
1957
+ */
1958
+ declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
2135
1959
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
2136
1960
  declare function createEvents(store: RootStore): {
2137
1961
  handlePointer: (name: string) => (event: DomEvent) => void;
@@ -2139,7 +1963,7 @@ declare function createEvents(store: RootStore): {
2139
1963
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
2140
1964
  };
2141
1965
  /** Default R3F event manager for web */
2142
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1966
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
2143
1967
 
2144
1968
  /**
2145
1969
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -2152,419 +1976,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
2152
1976
  * Note: this hook's caller must be wrapped with `React.Suspense`
2153
1977
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
2154
1978
  */
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>;
1979
+ 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
1980
  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;
1981
+ 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;
1982
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
2159
1983
  var loader: typeof getLoader;
2160
1984
  }
2161
1985
 
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
1986
  declare const IsObject: (url: unknown) => url is Record<string, string>;
2569
1987
  type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2570
1988
  type TextureRecord<T> = T extends Record<string, string> ? {
@@ -2750,11 +2168,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
2750
2168
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2751
2169
  */
2752
2170
  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
2171
  /**
2759
2172
  * Exposes an object's {@link Instance}.
2760
2173
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2830,7 +2243,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2830
2243
  * Invalidates the view, requesting a frame to be rendered.
2831
2244
  * In demand mode, this triggers the scheduler to run frames.
2832
2245
  *
2833
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2246
+ * With a state argument, only that root's jobs run on the requested frames; other
2247
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2248
+ *
2249
+ * @param state - Optional root state; targets the invalidation at that root
2834
2250
  * @param frames - Number of frames to request (default: 1)
2835
2251
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2836
2252
  *
@@ -2841,14 +2257,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2841
2257
  * Advances the frameloop and runs render effects.
2842
2258
  * Useful for when manually rendering via `frameloop="never"`.
2843
2259
  *
2260
+ * With a state argument, only that root is stepped. Without one, every
2261
+ * registered root is stepped for backwards compatibility.
2262
+ *
2844
2263
  * @param timestamp - The timestamp to use for this frame
2845
2264
  * @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)
2265
+ * @param state - Optional root state; targets the manual step at that root
2848
2266
  *
2849
2267
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2850
2268
  */
2851
- declare function advance(timestamp: number): void;
2269
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2852
2270
 
2853
2271
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2854
2272
  declare function ReactReconciler<
@@ -3893,6 +3311,7 @@ declare namespace ReactReconciler {
3893
3311
 
3894
3312
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3895
3313
  declare function extend<T extends Catalogue>(objects: T): void;
3314
+ declare function extend(objects: Record<string, unknown>): void;
3896
3315
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3897
3316
 
3898
3317
  declare const isRenderer: (def: any) => boolean;
@@ -3919,11 +3338,6 @@ declare function flushSync<R>(fn: () => R): R;
3919
3338
  declare const context: React$1.Context<RootStore>;
3920
3339
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3921
3340
 
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
3341
  /**
3928
3342
  * An SSR-friendly useLayoutEffect.
3929
3343
  *
@@ -4341,29 +3755,44 @@ declare const hasConstructor: (object: unknown) => object is {
4341
3755
  * Used to identify values that should be resolved from refs after mount.
4342
3756
  */
4343
3757
  declare const FROM_REF: unique symbol;
3758
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3759
+ interface FromRefMarker<T = unknown, R = T> {
3760
+ [FROM_REF]: React$1.RefObject<T | null>;
3761
+ /** Optional transform applied to the resolved ref before assignment. */
3762
+ transform?: (value: T) => R;
3763
+ }
4344
3764
  /**
4345
3765
  * Defers prop application until the referenced object is available.
4346
3766
  * Useful for props like `target` that need sibling refs to be populated.
4347
3767
  *
3768
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3769
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3770
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3771
+ * what gets assigned.
3772
+ *
4348
3773
  * @param ref - React ref object to resolve at mount time
4349
- * @returns A marker value that applyProps will resolve after mount
3774
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3775
+ * @returns A marker value that the reconciler resolves after mount
4350
3776
  *
4351
3777
  * @example
4352
3778
  * const targetRef = useRef<THREE.Object3D>(null)
4353
3779
  *
4354
3780
  * <group ref={targetRef} position={[-3, -2, -15]} />
4355
3781
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3782
+ *
3783
+ * @example
3784
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3785
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
4356
3786
  */
4357
3787
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3788
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
4358
3789
  /**
4359
3790
  * Type guard to check if a value is a fromRef marker.
4360
3791
  *
4361
3792
  * @param value - Value to check
4362
3793
  * @returns True if value is a fromRef marker
4363
3794
  */
4364
- declare function isFromRef(value: unknown): value is {
4365
- [FROM_REF]: React$1.RefObject<any>;
4366
- };
3795
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
4367
3796
 
4368
3797
  /**
4369
3798
  * Symbol marker for mount-only method calls.
@@ -4390,7 +3819,15 @@ declare const ONCE: unique symbol;
4390
3819
  * // No arguments
4391
3820
  * <geometry center={once()} />
4392
3821
  */
4393
- declare function once<T>(...args: T[]): T;
3822
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3823
+ /**
3824
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3825
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3826
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3827
+ *
3828
+ * The runtime value is always the marker object; only the declared type follows the prop.
3829
+ */
3830
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
4394
3831
  /**
4395
3832
  * Type guard to check if a value is a once marker.
4396
3833
  *
@@ -4401,11 +3838,8 @@ declare function isOnce(value: unknown): value is {
4401
3838
  [ONCE]: any[] | true;
4402
3839
  };
4403
3840
 
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;
3841
+ /** Distinguishes a resource leaf from a nested resource scope. */
3842
+ type ResourceLeafGuard<T> = (value: unknown) => value is T;
4409
3843
 
4410
3844
  /**
4411
3845
  * ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
@@ -4427,33 +3861,30 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
4427
3861
  * ```
4428
3862
  */
4429
3863
 
4430
- /** Keys reserved for methods (excluded from index signature) */
4431
- type MethodKeys = 'scope' | 'has' | 'keys';
4432
3864
  /**
4433
3865
  * Type-safe wrapper interface for accessing nested store data.
4434
3866
  * Property access returns `T` (assumes leaf node).
4435
3867
  * Use `.scope(key)` for nested object access.
4436
3868
  *
4437
- * Uses mapped type with key filtering to exclude method names from index signature,
4438
- * allowing methods to have their correct return types.
4439
3869
  */
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
- } & {
3870
+ type ScopedStoreMethods<TLeaf> = {
4444
3871
  /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
4445
- scope(key: string): ScopedStoreType<T>;
3872
+ scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
4446
3873
  /** Check if a key exists in the store */
4447
3874
  has(key: string): boolean;
4448
3875
  /** Get all keys in the store */
4449
3876
  keys(): string[];
4450
3877
  };
3878
+ type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
3879
+ interface ScopedStoreData<TLeaf> {
3880
+ [key: string]: TLeaf | ScopedStoreData<TLeaf>;
3881
+ }
4451
3882
  /**
4452
3883
  * Create a type-safe ScopedStore wrapper around store data.
4453
3884
  * @param data - The raw store data (uniforms or nodes from RootState)
4454
3885
  * @returns A ScopedStoreType wrapper with type-safe access
4455
3886
  */
4456
- declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
3887
+ declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
4457
3888
  /**
4458
3889
  * State type passed to creator functions with ScopedStore wrappers.
4459
3890
  * Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
@@ -4461,8 +3892,8 @@ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreTyp
4461
3892
  type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
4462
3893
  /** Type-safe uniform access - property access returns UniformNode */
4463
3894
  uniforms: ScopedStoreType<UniformNode>;
4464
- /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
4465
- nodes: ScopedStoreType<TSLNodeType>;
3895
+ /** Type-safe node access for real, callable, and legacy structural nodes */
3896
+ nodes: ScopedStoreType<NodeLike>;
4466
3897
  /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
4467
3898
  buffers: ScopedStoreType<BufferLike>;
4468
3899
  /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
@@ -4478,22 +3909,26 @@ type ClearUniformsFn = (scope?: string) => void;
4478
3909
  /** Function signature for rebuildUniforms util */
4479
3910
  type RebuildUniformsFn = (scope?: string) => void;
4480
3911
  /** Return type with utils included */
4481
- type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
3912
+ type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
4482
3913
  removeUniforms: RemoveUniformsFn;
4483
3914
  clearUniforms: ClearUniformsFn;
4484
3915
  rebuildUniforms: RebuildUniformsFn;
4485
3916
  };
4486
- declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
3917
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
3918
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
3919
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
3920
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
3921
+ declare function useUniforms(): UniformsWithUtils<UniformStore>;
4487
3922
  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>>;
3923
+ declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
4492
3924
  /**
4493
3925
  * Global rebuildUniforms function for HMR integration.
4494
- * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
3926
+ * Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
4495
3927
  * Call this when HMR is detected to refresh all uniform creators.
4496
3928
  *
3929
+ * Resolves to the primary store so shared TSL resources rebuild on the
3930
+ * authoritative store.
3931
+ *
4497
3932
  * @param store - The R3F store (from useStore or context)
4498
3933
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4499
3934
  */
@@ -4516,47 +3951,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
4516
3951
 
4517
3952
  /**
4518
3953
  * Supported uniform value types:
4519
- * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
3954
+ * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
4520
3955
  * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
4521
3956
  * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
4522
3957
  * - UniformNode: existing uniforms (reused as-is)
4523
3958
  */
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>>;
3959
+ type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
3960
+ declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
3961
+ declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
4535
3962
 
4536
3963
  /**
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.
3964
+ * Every node representation a creator may return. The definition lives with the store types as
3965
+ * `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
3966
+ * construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
3967
+ * `{ uuid, nodeType }` shape.
4541
3968
  */
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 */
3969
+ type TSLNodeLike = NodeLike;
3970
+
3971
+ /** Backward-compatible alias covering every accepted node representation. */
4550
3972
  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
3973
  /**
4557
3974
  * 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.
3975
+ * Exact creator return inference is preserved within the compatible node constraint.
4560
3976
  */
4561
3977
  type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
4562
3978
  /** Function signature for removeNodes util */
@@ -4566,20 +3982,25 @@ type ClearNodesFn = (scope?: string) => void;
4566
3982
  /** Function signature for rebuildNodes util */
4567
3983
  type RebuildNodesFn = (scope?: string) => void;
4568
3984
  /** Return type with utils included */
4569
- type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
3985
+ type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
4570
3986
  removeNodes: RemoveNodesFn;
4571
3987
  clearNodes: ClearNodesFn;
4572
3988
  rebuildNodes: RebuildNodesFn;
4573
3989
  };
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>;
3990
+ declare function useNodes(): NodesWithUtils<NodeStore>;
3991
+ declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
3992
+ declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
3993
+ declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
3994
+ declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
3995
+ declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
4578
3996
  /**
4579
3997
  * Global rebuildNodes function for HMR integration.
4580
- * Clears cached nodes and increments _hmrVersion to trigger re-creation.
3998
+ * Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
4581
3999
  * Call this when HMR is detected to refresh all node creators.
4582
4000
  *
4001
+ * Resolves to the primary store so shared TSL resources rebuild on the
4002
+ * authoritative store.
4003
+ *
4583
4004
  * @param store - The R3F store (from useStore or context)
4584
4005
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4585
4006
  */
@@ -4630,6 +4051,10 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
4630
4051
  */
4631
4052
  declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
4632
4053
 
4054
+ /**
4055
+ * A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
4056
+ */
4057
+ type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
4633
4058
  /**
4634
4059
  * Creator function that returns a record of buffers.
4635
4060
  * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
@@ -4644,26 +4069,34 @@ type RebuildBuffersFn = (scope?: string) => void;
4644
4069
  /** Function signature for disposeBuffers util - releases GPU resources */
4645
4070
  type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
4646
4071
  /** Return type with utils included */
4647
- type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
4072
+ type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
4648
4073
  removeBuffers: RemoveBuffersFn;
4649
4074
  clearBuffers: ClearBuffersFn;
4650
4075
  rebuildBuffers: RebuildBuffersFn;
4651
4076
  disposeBuffers: DisposeBuffersFn;
4652
4077
  };
4653
- declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
4078
+ declare function useBuffers(): BuffersWithUtils<BufferStore>;
4654
4079
  declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
4080
+ declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
4655
4081
  declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
4656
4082
  declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
4657
4083
  /**
4658
4084
  * Global rebuildBuffers function for HMR integration.
4659
- * Clears cached buffers and increments _hmrVersion to trigger re-creation.
4085
+ * Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
4660
4086
  * Call this when HMR is detected to refresh all buffer creators.
4661
4087
  *
4088
+ * Resolves to the primary store so shared TSL resources rebuild on the
4089
+ * authoritative store.
4090
+ *
4662
4091
  * @param store - The R3F store (from useStore or context)
4663
4092
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4664
4093
  */
4665
4094
  declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
4666
4095
 
4096
+ /**
4097
+ * A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
4098
+ */
4099
+ type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
4667
4100
  /**
4668
4101
  * Creator function that returns a record of GPU storage objects.
4669
4102
  * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
@@ -4678,26 +4111,47 @@ type RebuildStorageFn = (scope?: string) => void;
4678
4111
  /** Function signature for disposeStorage util - releases GPU resources */
4679
4112
  type DisposeStorageFn = (names: string | string[], scope?: string) => void;
4680
4113
  /** Return type with utils included */
4681
- type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
4114
+ type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
4682
4115
  removeStorage: RemoveStorageFn;
4683
4116
  clearStorage: ClearStorageFn;
4684
4117
  rebuildStorage: RebuildStorageFn;
4685
4118
  disposeStorage: DisposeStorageFn;
4686
4119
  };
4687
- declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
4120
+ declare function useGPUStorage(): StorageWithUtils<StorageStore>;
4688
4121
  declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
4122
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
4689
4123
  declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
4690
4124
  declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
4691
4125
  /**
4692
4126
  * Global rebuildStorage function for HMR integration.
4693
- * Clears cached storage and increments _hmrVersion to trigger re-creation.
4127
+ * Invalidates cached storage and increments _hmrVersion to trigger re-creation.
4694
4128
  * Call this when HMR is detected to refresh all storage creators.
4695
4129
  *
4130
+ * Resolves to the primary store so shared TSL resources rebuild on the
4131
+ * authoritative store.
4132
+ *
4696
4133
  * @param store - The R3F store (from useStore or context)
4697
4134
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4698
4135
  */
4699
4136
  declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
4700
4137
 
4138
+ /**
4139
+ * Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
4140
+ *
4141
+ * This file maintains backwards compatibility for existing webgpu imports.
4142
+ */
4143
+
4144
+ /**
4145
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4146
+ * Kept as an alias for backwards compatibility.
4147
+ */
4148
+ type TextureEntry = Texture$1;
4149
+ /**
4150
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4151
+ * Kept as an alias for backwards compatibility.
4152
+ */
4153
+ type TextureNode = Texture$1;
4154
+
4701
4155
  interface TextureOperations {
4702
4156
  add: (key: string, value: any) => void;
4703
4157
  addMultiple: (items: Map<string, any> | Record<string, any>) => void;
@@ -4715,6 +4169,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
4715
4169
  * - Callbacks receive full RootState for flexibility
4716
4170
  * - No auto-cleanup on unmount - use reset() for explicit cleanup
4717
4171
  * - Scene/camera changes trigger scenePass recreation
4172
+ * - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
4173
+ * strand its render target (and MRT attachments) on the GPU
4174
+ * - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
4175
+ * recompiles instead of silently keeping the first compiled graph
4718
4176
  *
4719
4177
  * @param mainCB - Main callback to configure outputNode and create effect passes
4720
4178
  * @param setupCB - Optional setup callback to configure MRT on scenePass
@@ -4792,5 +4250,32 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
4792
4250
  internal: WebGPUInternalState
4793
4251
  }
4794
4252
 
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 };
4253
+ /**
4254
+ * @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
4255
+ *
4256
+ * This entry point is for apps that want to use ONLY WebGPURenderer.
4257
+ * Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
4258
+ * Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
4259
+ *
4260
+ * Usage:
4261
+ * import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
4262
+ */
4263
+
4264
+ /** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
4265
+ type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
4266
+ /** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
4267
+ type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
4268
+ declare const useThree: UseThreeWebGPU;
4269
+ declare const useFrame: UseFrameWebGPU;
4270
+
4271
+ /** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
4272
+ type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
4273
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
4274
+ onCreated?: (state: WebGPURootState) => void;
4275
+ };
4276
+
4277
+ /** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
4278
+ declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
4279
+
4280
+ 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 };
4281
+ 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 };