@react-three/fiber 10.0.0-canary.c3fa45d → 10.0.0-canary.c4ecb6a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/legacy.d.cts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as THREE$1 from 'three';
2
- import { WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Node as Node$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three';
2
+ import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$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, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
3
3
  import * as React$1 from 'react';
4
4
  import { ReactNode, Component, RefObject, JSX } from 'react';
5
5
  import * as three_webgpu from 'three/webgpu';
6
- import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject } from 'three/webgpu';
6
+ import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget } from 'three/webgpu';
7
7
  import { StoreApi } from 'zustand';
8
8
  import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
9
+ import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
10
+ export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
9
11
  import { Options } from 'react-use-measure';
10
12
  import * as react_jsx_runtime from 'react/jsx-runtime';
11
- import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
12
13
  import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
13
14
 
14
15
  function _mergeNamespaces(n, m) {
@@ -37,23 +38,28 @@ function _mergeNamespaces(n, m) {
37
38
  declare const R3F_BUILD_LEGACY = true;
38
39
  declare const R3F_BUILD_WEBGPU = false;
39
40
 
40
- declare const Inspector: {
41
- new (): {};
42
- };
43
- declare const WebGPURenderer: {
44
- new (): {};
45
- };
41
+ type Inspector = never;
42
+ /** Not available on the legacy (WebGL-only) entry. */
43
+ declare function loadInspector(): Promise<never>;
44
+ declare class WebGPURenderer {
45
+ constructor();
46
+ }
46
47
 
47
48
  declare const RenderTarget: any;
48
49
 
50
+ declare const CubeRenderTarget: any;
51
+
49
52
  var THREE = /*#__PURE__*/_mergeNamespaces({
50
53
  __proto__: null,
54
+ CubeRenderTarget: CubeRenderTarget,
55
+ CubeRenderTargetCompat: WebGLCubeRenderTarget,
51
56
  Inspector: Inspector,
52
57
  R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
53
58
  R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
54
59
  RenderTarget: RenderTarget,
55
60
  RenderTargetCompat: WebGLRenderTarget,
56
- WebGPURenderer: WebGPURenderer
61
+ WebGPURenderer: WebGPURenderer,
62
+ loadInspector: loadInspector
57
63
  }, [THREE$1]);
58
64
 
59
65
  //* Utility Types ==============================
@@ -291,228 +297,33 @@ interface VisibilityEntry {
291
297
  }
292
298
 
293
299
  //* Scheduler Types (useFrame) ==============================
300
+ //
301
+ // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
302
+ // This file re-exports them and layers r3f's RootState-aware frame state on top,
303
+ // so existing `#types` imports across the codebase keep resolving unchanged.
294
304
 
295
305
 
296
306
 
297
- // Public Options --------------------------------
298
-
299
- /**
300
- * Options for useFrame hook
301
- */
302
- interface UseFrameNextOptions {
303
- /** Optional stable id for the job. Auto-generated if not provided */
304
- id?: string
305
- /** Named phase to run in. Default: 'update' */
306
- phase?: string
307
- /** Run before this phase or job id */
308
- before?: string | string[]
309
- /** Run after this phase or job id */
310
- after?: string | string[]
311
- /** Priority within phase. Higher runs first. Default: 0 */
312
- priority?: number
313
- /** Max frames per second for this job */
314
- fps?: number
315
- /** If true, skip frames when behind. If false, try to catch up. Default: true */
316
- drop?: boolean
317
- /** Enable/disable without unregistering. Default: true */
318
- enabled?: boolean
319
- }
320
-
321
- /** Alias for UseFrameNextOptions */
322
- type UseFrameOptions = UseFrameNextOptions
323
-
324
- /**
325
- * Options for addPhase
326
- */
327
- interface AddPhaseOptions {
328
- /** Insert this phase before the specified phase */
329
- before?: string
330
- /** Insert this phase after the specified phase */
331
- after?: string
332
- }
333
-
334
- // Frame State --------------------------------
335
-
336
- /**
337
- * Timing-only state for independent/outside mode (no RootState)
338
- */
339
- interface FrameTimingState {
340
- /** High-resolution timestamp from RAF (ms) */
341
- time: number
342
- /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
343
- delta: number
344
- /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
345
- elapsed: number
346
- /** Incrementing frame counter */
347
- frame: number
348
- }
307
+ // Frame State (r3f-specific) --------------------------------
349
308
 
350
309
  /**
351
- * State passed to useFrame callbacks (extends RootState with timing)
310
+ * State passed to useFrame callbacks (extends RootState with timing).
352
311
  */
353
312
  interface FrameNextState extends RootState, FrameTimingState {}
354
313
 
355
314
  /** Alias for FrameNextState */
356
315
  type FrameState = FrameNextState
357
316
 
358
- // Root Options --------------------------------
359
-
360
- /**
361
- * Options for registerRoot
362
- */
363
- interface RootOptions {
364
- /** State provider for callbacks. Optional in independent mode. */
365
- getState?: () => any
366
- /** Error handler for job errors. Falls back to console.error if not provided. */
367
- onError?: (error: Error) => void
368
- }
369
-
370
- // Callback Types --------------------------------
317
+ // Callback Types (r3f-specific) --------------------------------
371
318
 
372
319
  /**
373
- * Callback function for useFrame
320
+ * Callback function for useFrame. Receives the full r3f RootState plus timing.
374
321
  */
375
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
322
+ type FrameNextCallback = FrameCallback$1<RootState>
376
323
 
377
324
  /** Alias for FrameNextCallback */
378
325
  type FrameCallback = FrameNextCallback
379
326
 
380
- // Controls returned from useFrame --------------------------------
381
-
382
- /**
383
- * Controls object returned from useFrame hook
384
- */
385
- interface FrameNextControls {
386
- /** The job's unique ID */
387
- id: string
388
- /** Access to the global scheduler for frame loop control */
389
- scheduler: SchedulerApi
390
- /** Manually step this job only (bypasses FPS limiting) */
391
- step(timestamp?: number): void
392
- /** Manually step ALL jobs in the scheduler */
393
- stepAll(timestamp?: number): void
394
- /** Pause this job (set enabled=false) */
395
- pause(): void
396
- /** Resume this job (set enabled=true) */
397
- resume(): void
398
- /** Reactive paused state - automatically triggers re-render when changed */
399
- isPaused: boolean
400
- }
401
-
402
- /** Alias for FrameNextControls */
403
- type FrameControls = FrameNextControls
404
-
405
- // Scheduler Interface --------------------------------
406
-
407
- /**
408
- * Public interface for the global Scheduler
409
- */
410
- interface SchedulerApi {
411
- //* Phase Management --------------------------------
412
-
413
- /** Add a named phase to the scheduler */
414
- addPhase(name: string, options?: AddPhaseOptions): void
415
- /** Get the ordered list of phase names */
416
- readonly phases: string[]
417
- /** Check if a phase exists */
418
- hasPhase(name: string): boolean
419
-
420
- //* Root Management --------------------------------
421
-
422
- /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
423
- registerRoot(id: string, options?: RootOptions): () => void
424
- /** Unregister a root */
425
- unregisterRoot(id: string): void
426
- /** Generate a unique root ID */
427
- generateRootId(): string
428
- /** Get the number of registered roots */
429
- getRootCount(): number
430
- /** Check if any root is registered and ready */
431
- readonly isReady: boolean
432
- /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
433
- onRootReady(callback: () => void): () => void
434
-
435
- //* Job Registration --------------------------------
436
-
437
- /** Register a job with the scheduler (returns unsubscribe function) */
438
- register(
439
- callback: FrameNextCallback,
440
- options?: {
441
- id?: string
442
- rootId?: string
443
- phase?: string
444
- before?: string | string[]
445
- after?: string | string[]
446
- priority?: number
447
- fps?: number
448
- drop?: boolean
449
- enabled?: boolean
450
- },
451
- ): () => void
452
- /** Update a job's options */
453
- updateJob(
454
- id: string,
455
- options: {
456
- priority?: number
457
- fps?: number
458
- drop?: boolean
459
- enabled?: boolean
460
- phase?: string
461
- before?: string | string[]
462
- after?: string | string[]
463
- },
464
- ): void
465
- /** Unregister a job by ID */
466
- unregister(id: string, rootId?: string): void
467
- /** Get the number of registered jobs */
468
- getJobCount(): number
469
- /** Get all job IDs */
470
- getJobIds(): string[]
471
-
472
- //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
473
-
474
- /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
475
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
476
-
477
- //* Idle Callbacks (for legacy addTail) --------------------------------
478
-
479
- /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
480
- onIdle(callback: (timestamp: number) => void): () => void
481
-
482
- //* Frame Loop Control --------------------------------
483
-
484
- /** Start the scheduler loop */
485
- start(): void
486
- /** Stop the scheduler loop */
487
- stop(): void
488
- /** Check if the scheduler is running */
489
- readonly isRunning: boolean
490
- /** Get/set the frameloop mode ('always', 'demand', 'never') */
491
- frameloop: Frameloop
492
- /** Independent mode - runs without Canvas, callbacks receive timing-only state */
493
- independent: boolean
494
-
495
- //* Manual Stepping --------------------------------
496
-
497
- /** Manually step all jobs once (for frameloop='never' or testing) */
498
- step(timestamp?: number): void
499
- /** Manually step a single job by ID */
500
- stepJob(id: string, timestamp?: number): void
501
- /** Request frame(s) to be rendered (for frameloop='demand') */
502
- invalidate(frames?: number): void
503
-
504
- //* Per-Job Control --------------------------------
505
-
506
- /** Check if a job is paused */
507
- isJobPaused(id: string): boolean
508
- /** Pause a job */
509
- pauseJob(id: string): void
510
- /** Resume a job */
511
- resumeJob(id: string): void
512
- /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
513
- subscribeJobState(id: string, listener: () => void): () => void
514
- }
515
-
516
327
  //* Buffer Types (useBuffers) ========================================
517
328
 
518
329
  /**
@@ -537,6 +348,7 @@ type BufferLike =
537
348
  | Uint16Array
538
349
  | Int16Array
539
350
  | THREE$1.BufferAttribute // Base class for all buffer attributes
351
+ | THREE$1.InterleavedBufferAttribute
540
352
  | Node // TSL buffer nodes (instancedArray, storage)
541
353
 
542
354
  /** Flat record of buffer-like values (no nested scopes) */
@@ -548,6 +360,25 @@ type BufferRecord = Record<string, BufferLike>
548
360
  */
549
361
  type BufferStore = Record<string, BufferLike | BufferRecord>
550
362
 
363
+ //* Node Types (useNodes) ========================================
364
+
365
+ /**
366
+ * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
367
+ * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
368
+ * code passes through. Creators are constrained to this same type, so the shape a creator returns
369
+ * and the shape the store holds are one type by construction.
370
+ */
371
+ type NodeLike = TSLNodeType | LegacyTSLNodeLike
372
+
373
+ /** Flat record of TSL nodes (no nested scopes) */
374
+ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
375
+
376
+ /**
377
+ * Node store that can contain both root-level nodes and scoped node objects.
378
+ * Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
379
+ */
380
+ type NodeStore = Record<string, NodeLike | NodeRecord>
381
+
551
382
  //* Storage Types (useGPUStorage) ========================================
552
383
 
553
384
  /**
@@ -562,7 +393,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
562
393
  * ```
563
394
  */
564
395
  type StorageLike =
565
- | StorageTexture // GPU storage texture
396
+ | StorageTexture // 2D GPU storage texture
397
+ | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
398
+ | StorageArrayTexture // 2D-array GPU storage texture
566
399
  | Data3DTexture // 3D texture (can be used as storage)
567
400
  | Node // TSL storage texture nodes (storageTexture)
568
401
 
@@ -681,14 +514,31 @@ interface InternalState {
681
514
  /** Container for child attachment (scene for root, original container for portals) */
682
515
  container?: THREE$1.Object3D
683
516
  /**
684
- * CanvasTarget for multi-canvas WebGPU rendering.
685
- * Created for all WebGPU canvases to support renderer sharing.
517
+ * The CanvasTarget this root sizes and renders through.
518
+ *
519
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
520
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
521
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
522
+ * and the canvas-target job makes it the renderer's active one before this root renders.
523
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
686
524
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
687
525
  */
688
526
  canvasTarget?: CanvasTarget
527
+ /**
528
+ * Set when this root's canvas target has been resized and the backend's cached render pass
529
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
530
+ *
531
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
532
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
533
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
534
+ * invalidate some other canvas's descriptor instead.
535
+ *
536
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
537
+ */
538
+ canvasTargetSizeDirty?: boolean
689
539
  /**
690
540
  * Whether multi-canvas rendering is active.
691
- * True when any canvas uses `target` prop to share a renderer.
541
+ * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
692
542
  * When true, setCanvasTarget is called before each render.
693
543
  */
694
544
  isMultiCanvas?: boolean
@@ -786,8 +636,8 @@ interface RootState {
786
636
  setSize: (width?: number, height?: number, top?: number, left?: number) => void
787
637
  /** Shortcut to manual setting the pixel ratio */
788
638
  setDpr: (dpr: Dpr) => void
789
- /** Shortcut to setting frameloop flags */
790
- setFrameloop: (frameloop: Frameloop) => void
639
+ /** Shortcut to setting frameloop flags. No args resets to 'always'. */
640
+ setFrameloop: (frameloop?: Frameloop) => void
791
641
  /** Set error state to propagate to error boundary */
792
642
  setError: (error: Error | null) => void
793
643
  /** Current error state (null when no error) */
@@ -795,17 +645,19 @@ interface RootState {
795
645
  /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
796
646
  uniforms: UniformStore
797
647
  /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
798
- nodes: Record<string, any>
648
+ nodes: NodeStore
799
649
  /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
800
650
  buffers: BufferStore
801
651
  /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
802
652
  gpuStorage: StorageStore
803
- /** Global TSL texture nodes - use useTextures() hook for operations */
804
- textures: Map<string, any>
653
+ /** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
654
+ textures: Map<string, THREE$1.Texture>
655
+ /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
656
+ _textureRefs: Map<string, number>
805
657
  /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
806
- renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
658
+ renderPipeline: ThreeRenderPipeline | null
807
659
  /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
808
- passes: Record<string, any>
660
+ passes: PassRecord
809
661
  /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
810
662
  _hmrVersion: number
811
663
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
@@ -893,12 +745,19 @@ type DefaultRendererProps = {
893
745
  */
894
746
  interface CanvasSchedulerConfig {
895
747
  /**
896
- * Render this canvas after another canvas completes.
897
- * Pass the `id` of another canvas.
748
+ * Run this Canvas root before the referenced Canvas root id(s).
898
749
  */
899
- after?: string
750
+ before?: string | string[]
751
+ /**
752
+ * Run this Canvas root after the referenced Canvas root id(s).
753
+ */
754
+ after?: string | string[]
900
755
  /**
901
- * Limit this canvas's render rate (frames per second).
756
+ * Numeric root order. Lower values run first.
757
+ */
758
+ order?: number
759
+ /**
760
+ * Limit this Canvas's default render job (frames per second).
902
761
  */
903
762
  fps?: number
904
763
  }
@@ -985,14 +844,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
985
844
  performance?: Partial<Omit<Performance, 'regress'>>
986
845
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
987
846
  dpr?: Dpr
988
- /** Props that go into the default raycaster */
989
- raycaster?: Partial<THREE$1.Raycaster>
847
+ /**
848
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
849
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
850
+ */
851
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
990
852
  /** A `THREE.Scene` instance or props that go into the default scene */
991
853
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
992
854
  /** A `THREE.Camera` instance or props that go into the default camera */
993
855
  camera?: CameraProps
994
856
  /** An R3F event manager to manage elements' pointer events */
995
- events?: (store: RootStore) => EventManager<HTMLElement>
857
+ events?: (store: RootStore) => EventManager<Element>
996
858
  /** Callback after the canvas has rendered (but not yet committed) */
997
859
  onCreated?: (state: RootState) => void
998
860
  /** Response for pointer clicks that have missed any target */
@@ -1081,7 +943,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
1081
943
  object?: T
1082
944
  dispose?: null
1083
945
  attach?: AttachType<T>
1084
- onUpdate?: (self: T) => void
1085
946
  }
1086
947
 
1087
948
  interface Instance<O = any> {
@@ -1096,8 +957,6 @@ interface Instance<O = any> {
1096
957
  attach?: AttachType<O>
1097
958
  previousAttach?: any
1098
959
  isHidden: boolean
1099
- /** Deferred ref props to apply in commitMount */
1100
- deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
1101
960
  /** Set of props that have been applied via once() */
1102
961
  appliedOnce?: Set<string>
1103
962
  }
@@ -1223,7 +1082,7 @@ interface CanvasProps
1223
1082
  */
1224
1083
  resize?: Options
1225
1084
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1226
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1085
+ eventSource?: Element | React$1.RefObject<Element | null>
1227
1086
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1228
1087
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1229
1088
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1331,70 +1190,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1331
1190
 
1332
1191
  type RenderTargetOptions = RenderTargetOptions$1
1333
1192
 
1334
- //* Global Types ==============================
1193
+ //* Global TSL Types ==============================
1335
1194
 
1336
1195
  declare global {
1337
- /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
1338
- interface UniformNode<T = unknown> extends Node {
1339
- value: T
1340
- }
1341
-
1342
1196
  /**
1343
- * ShaderCallable - the return type of Fn()
1344
- * A callable shader function node that can be invoked with parameters.
1345
- * The function returns a ShaderNodeObject when called.
1346
- *
1347
- * @example
1348
- * ```tsx
1349
- * // Define a shader function
1350
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1351
- * return mix(color1, color2, factor)
1352
- * })
1353
- *
1354
- * // Type when retrieving from nodes store
1355
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1356
- *
1357
- * // Or with specific return type
1358
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1359
- * ```
1197
+ * Broad callable-node fallback for dynamic store readers.
1198
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1360
1199
  */
1361
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1200
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1201
+ readonly shaderNode: unknown
1202
+ readonly id: number
1203
+ }
1362
1204
 
1363
- /**
1364
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1365
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1366
- *
1367
- * @example
1368
- * ```tsx
1369
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1370
- * ```
1371
- */
1372
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1205
+ /** Legacy structural node accepted when at least one historical marker exists. */
1206
+ type LegacyTSLNodeLike = {
1207
+ label?: ((label: string) => unknown) | string
1208
+ setName?: (name: string) => unknown
1209
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1210
+
1211
+ /** Node type accepted by broad dynamic node-store readers. */
1212
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1373
1213
 
1374
1214
  /**
1375
- * TSLNodeType - Union of all common TSL node types
1376
- * Used by ScopedStore to properly type node access from the store.
1377
- *
1378
- * Includes:
1379
- * - Node: base Three.js node type
1380
- * - ShaderCallable: function nodes created with Fn()
1381
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1382
- *
1383
- * @example
1384
- * ```tsx
1385
- * // In useLocalNodes, nodes are typed as TSLNodeType
1386
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1387
- * positionNode: nodes.myPosition, // Works - Node is in union
1388
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1389
- * }))
1390
- *
1391
- * // Can narrow with type guard or assertion when needed
1392
- * if (typeof blendColorFn === 'function') {
1393
- * blendColorFn(someColor, 0.5)
1394
- * }
1395
- * ```
1215
+ * Derive Three's shader node type from an existing node or a supported raw input.
1216
+ * Existing InputNode generics take precedence over structural value normalization.
1217
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1218
+ * InputNode base with its concrete InputNode specialization.
1396
1219
  */
1397
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1220
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1221
+ ? TNodeType
1222
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1223
+ ? TNodeType
1224
+ : T extends number
1225
+ ? 'float'
1226
+ : T extends boolean
1227
+ ? 'bool'
1228
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1229
+ ? 'color'
1230
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1231
+ ? 'vec4'
1232
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1233
+ ? 'vec3'
1234
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1235
+ ? 'vec2'
1236
+ : T extends three_webgpu.Matrix4
1237
+ ? 'mat4'
1238
+ : T extends three_webgpu.Matrix3
1239
+ ? 'mat3'
1240
+ : T extends three_webgpu.Matrix2
1241
+ ? 'mat2'
1242
+ : unknown
1243
+
1244
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1245
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1246
+ ? TValue
1247
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1248
+ ? TValue
1249
+ : T extends string | { r: number; g: number; b: number }
1250
+ ? three_webgpu.Color
1251
+ : T extends { x: number; y: number; z: number; w: number }
1252
+ ? three_webgpu.Vector4
1253
+ : T extends { x: number; y: number; z: number }
1254
+ ? three_webgpu.Vector3
1255
+ : T extends { x: number; y: number }
1256
+ ? three_webgpu.Vector2
1257
+ : T extends number
1258
+ ? number
1259
+ : T extends boolean
1260
+ ? boolean
1261
+ : T
1262
+
1263
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1264
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1265
+
1266
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1267
+ type UniformNodesFor<T extends UniformInputRecord> = {
1268
+ [K in keyof T]: UniformNodeFor<T[K]>
1269
+ }
1270
+
1271
+ /** Backward-compatible single-parameter uniform alias. */
1272
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1398
1273
 
1399
1274
  /** Flat record of uniform nodes (no nested scopes) */
1400
1275
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1419,7 +1294,7 @@ declare global {
1419
1294
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1420
1295
  * Supports:
1421
1296
  * - Primitives: number, string (color), boolean
1422
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1297
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1423
1298
  * - Plain objects: { x, y, z, w } converted to vectors
1424
1299
  * - TSL nodes: color(), vec3(), float() for type casting
1425
1300
  * - UniformNode: existing uniforms (reused as-is)
@@ -1432,227 +1307,124 @@ declare global {
1432
1307
  | three_webgpu.Vector2
1433
1308
  | three_webgpu.Vector3
1434
1309
  | three_webgpu.Vector4
1310
+ | three_webgpu.Matrix2
1435
1311
  | three_webgpu.Matrix3
1436
1312
  | three_webgpu.Matrix4
1437
- | three_webgpu.Euler
1438
- | three_webgpu.Quaternion
1439
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1313
+ | { x: number; y: number }
1314
+ | { x: number; y: number; z: number }
1315
+ | { x: number; y: number; z: number; w: number }
1440
1316
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1441
- | Node // TSL nodes like color(), vec3(), float() for type casting
1317
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1442
1318
  | UniformNode
1443
1319
 
1444
1320
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1445
1321
  type UniformInputRecord = Record<string, UniformValue>
1446
1322
  }
1447
1323
 
1448
- //* Module Augmentation ==============================
1449
-
1450
- declare module 'three/tsl' {
1324
+ declare global {
1451
1325
  /**
1452
- * Fn with array parameter destructuring
1453
- * @example Fn(([uv, skew]) => { ... })
1326
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1327
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1328
+ * is r185, so the new name is the only one.
1454
1329
  */
1455
- export function Fn<R extends Node = Node>(
1456
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1457
- ): ShaderCallable<R>
1330
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1458
1331
 
1459
1332
  /**
1460
- * Fn with object parameter destructuring
1461
- * @example Fn(({ color, intensity }) => { ... })
1333
+ * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1334
+ * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1335
+ * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1462
1336
  */
1463
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1464
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1465
- ): ShaderCallable<R>
1337
+ type ScenePassNode = three_webgpu.PassNode
1466
1338
 
1467
1339
  /**
1468
- * Fn with array params + layout
1469
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1340
+ * Pass record - stores TSL pass nodes for render pipeline.
1341
+ *
1342
+ * `scenePass` is the only key the library owns. It is optional here because this is also the
1343
+ * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1344
+ * or `clearPasses()`. Inside the callbacks it is always present; see
1345
+ * {@link RenderPipelineCallbackState}.
1346
+ *
1347
+ * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1348
+ * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1349
+ * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1350
+ * site when you need a member, e.g. `passes.velocity as TextureNode`.
1351
+ *
1352
+ * The index signature admits `undefined` because a key may simply not be registered, and
1353
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1354
+ * optional property whose type excludes `undefined` from the index signature is an error
1355
+ * (TS2411) for every consumer compiling these declarations.
1470
1356
  */
1471
- export function Fn<R extends Node = Node>(
1472
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1473
- layout: { layout?: unknown },
1474
- ): ShaderCallable<R>
1357
+ interface PassRecord {
1358
+ scenePass?: ScenePassNode
1359
+ [key: string]: three_webgpu.Node | undefined
1360
+ }
1475
1361
 
1476
1362
  /**
1477
- * Fn with object params + layout
1363
+ * State passed to pipeline callbacks after the active pipeline has been created.
1364
+ *
1365
+ * `passes.scenePass` is required here: the hook installs the default scene pass before either
1366
+ * callback runs, so callbacks can use it without a guard or a cast.
1367
+ *
1368
+ * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1369
+ * the legacy renderer before either callback can run, so a callback never sees WebGL.
1478
1370
  */
1479
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1480
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1481
- layout: { layout?: unknown },
1482
- ): ShaderCallable<R>
1483
- }
1484
-
1485
- /**
1486
- * RenderPipeline Types for useRenderPipeline hook (WebGPU only)
1487
- */
1488
-
1489
-
1371
+ type RenderPipelineCallbackState = RootState & {
1372
+ renderPipeline: ThreeRenderPipeline
1373
+ passes: PassRecord & { scenePass: ScenePassNode }
1374
+ renderer: three_webgpu.WebGPURenderer
1375
+ isLegacy: false
1376
+ }
1490
1377
 
1491
- declare global {
1492
- /** Pass record - stores TSL pass nodes for render pipeline */
1493
- type PassRecord = Record<string, any>
1378
+ /**
1379
+ * What a callback may return to register entries into `state.passes`.
1380
+ *
1381
+ * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1382
+ * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1383
+ * store entry would leave the store pointing at a node the hook never disposes, and the hook
1384
+ * disposing a pass nothing references. So returning it is a type error.
1385
+ */
1386
+ type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1494
1387
 
1495
1388
  /** Setup callback - runs first to configure MRT, create additional passes */
1496
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1389
+ type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1497
1390
 
1498
1391
  /** Main callback - runs second to configure outputNode, create effect passes */
1499
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1392
+ type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1500
1393
 
1501
- /** Return type for useRenderPipeline hook */
1502
- interface UseRenderPipelineReturn {
1394
+ /** The imperative half of useRenderPipeline's return value, present in every state */
1395
+ interface UseRenderPipelineActions {
1503
1396
  /** Current passes from state */
1504
1397
  passes: PassRecord
1505
- /** RenderPipeline instance (null if not initialized) */
1506
- renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
1507
1398
  /** Clear all passes from state */
1508
1399
  clearPasses: () => void
1509
1400
  /** Reset RenderPipeline entirely (clears PP + passes) */
1510
1401
  reset: () => void
1511
1402
  /** Re-run setup/main callbacks with current closure values */
1512
1403
  rebuild: () => void
1513
- /** True when RenderPipeline is configured and ready */
1514
- isReady: boolean
1515
1404
  }
1516
- }
1517
-
1518
- //* useFrameNext Types ==============================
1519
-
1520
-
1521
-
1522
- //* Global Type Declarations ==============================
1523
-
1524
- declare global {
1525
- // Job --------------------------------
1526
1405
 
1527
1406
  /**
1528
- * Internal job representation in the scheduler
1529
- */
1530
- interface Job {
1531
- /** Unique identifier */
1532
- id: string
1533
- /** The callback to execute */
1534
- callback: FrameNextCallback
1535
- /** Phase this job belongs to */
1536
- phase: string
1537
- /** Run before these phases/job ids */
1538
- before: Set<string>
1539
- /** Run after these phases/job ids */
1540
- after: Set<string>
1541
- /** Priority within phase (higher first) */
1542
- priority: number
1543
- /** Insertion order for deterministic tie-breaking */
1544
- index: number
1545
- /** Max FPS for this job (undefined = no limit) */
1546
- fps?: number
1547
- /** Drop frames when behind (true) or catch up (false) */
1548
- drop: boolean
1549
- /** Last run timestamp (ms) */
1550
- lastRun?: number
1551
- /** Whether job is enabled */
1552
- enabled: boolean
1553
- /** Internal flag: system jobs (like default render) don't block user render takeover */
1554
- system?: boolean
1555
- }
1556
-
1557
- // Phase Graph --------------------------------
1558
-
1559
- /**
1560
- * A node in the phase graph
1561
- */
1562
- interface PhaseNode {
1563
- /** Phase name */
1564
- name: string
1565
- /** Whether this was auto-generated from a before/after constraint */
1566
- isAutoGenerated: boolean
1567
- }
1568
-
1569
- /**
1570
- * Options for creating a job from hook options
1571
- */
1572
- interface JobOptions {
1573
- id?: string
1574
- phase?: string
1575
- before?: string | string[]
1576
- after?: string | string[]
1577
- priority?: number
1578
- fps?: number
1579
- drop?: boolean
1580
- enabled?: boolean
1581
- }
1582
-
1583
- // Frame Loop State --------------------------------
1584
-
1585
- /**
1586
- * Internal frame loop state
1587
- */
1588
- interface FrameLoopState {
1589
- /** Whether the loop is running */
1590
- running: boolean
1591
- /** Current RAF handle */
1592
- rafHandle: number | null
1593
- /** Last frame timestamp in ms (null = uninitialized) */
1594
- lastTime: number | null
1595
- /** Frame counter */
1596
- frameCount: number
1597
- /** Elapsed time since first frame in ms */
1598
- elapsedTime: number
1599
- /** createdAt timestamp in ms */
1600
- createdAt: number
1601
- }
1602
-
1603
- // Root Entry --------------------------------
1604
-
1605
- /**
1606
- * Internal representation of a registered root (Canvas).
1607
- * Tracks jobs and manages rebuild state for this root.
1608
- * @internal
1609
- */
1610
- interface RootEntry {
1611
- /** Unique identifier for this root */
1612
- id: string
1613
- /** Function to get the root's current state. Returns any to support independent mode. */
1614
- getState: () => any
1615
- /** Map of job IDs to Job objects */
1616
- jobs: Map<string, Job>
1617
- /** Cached sorted job list for execution order */
1618
- sortedJobs: Job[]
1619
- /** Whether sortedJobs needs rebuilding */
1620
- needsRebuild: boolean
1621
- }
1622
-
1623
- /**
1624
- * Internal representation of a global job (deprecated API).
1625
- * Global jobs run once per frame, not per-root.
1626
- * Used by legacy addEffect/addAfterEffect APIs.
1627
- * @internal
1628
- * @deprecated Use useFrame with phases instead
1629
- */
1630
- interface GlobalJob {
1631
- /** Unique identifier for this global job */
1632
- id: string
1633
- /** Callback invoked with RAF timestamp in ms */
1634
- callback: (timestamp: number) => void
1635
- }
1636
-
1637
- // HMR Support --------------------------------
1638
-
1639
- /**
1640
- * Hot Module Replacement data structure for preserving scheduler state
1641
- * @internal
1642
- */
1643
- interface HMRData {
1644
- /** Shared data object for storing values across reloads */
1645
- data: Record<string, any>
1646
- /** Optional function to accept HMR updates */
1647
- accept?: () => void
1648
- }
1649
-
1650
- // Default Phases --------------------------------
1651
-
1652
- /**
1653
- * Default phase names for the scheduler
1407
+ * Return type for useRenderPipeline hook, discriminated on `isReady`.
1408
+ *
1409
+ * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1410
+ * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1411
+ * `clearPasses()` empties the record while leaving the pipeline in place.
1654
1412
  */
1655
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1413
+ type UseRenderPipelineReturn = UseRenderPipelineActions &
1414
+ (
1415
+ | {
1416
+ /** True when RenderPipeline is configured and ready */
1417
+ isReady: true
1418
+ /** RenderPipeline instance */
1419
+ renderPipeline: ThreeRenderPipeline
1420
+ }
1421
+ | {
1422
+ /** False until the pipeline has been created */
1423
+ isReady: false
1424
+ /** Not initialized yet, or torn down by reset() */
1425
+ renderPipeline: null
1426
+ }
1427
+ )
1656
1428
  }
1657
1429
 
1658
1430
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
@@ -1731,10 +1503,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1731
1503
 
1732
1504
  /**
1733
1505
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1734
- * since @types/three has broken inheritance for TSL node subclasses.
1506
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1507
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1735
1508
  */
1736
1509
  type NodeProps<P> = {
1737
- [K in keyof P as P[K] extends Node$1 | null ? K : never]?: TSLNodeInput
1510
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1738
1511
  }
1739
1512
 
1740
1513
  interface ReactProps<P> {
@@ -1755,11 +1528,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1755
1528
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1756
1529
  }
1757
1530
 
1531
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1532
+ type Object3DMethod = NonNullable<
1533
+ {
1534
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1535
+ }[keyof Object3D]
1536
+ >
1537
+
1758
1538
  type ThreeExports = typeof THREE
1759
1539
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1760
1540
 
1761
1541
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1762
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1542
+ /**
1543
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1544
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1545
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1546
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1547
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1548
+ */
1549
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
1550
+ object: object
1551
+ ref?: React.Ref<any>
1552
+ [prop: string]: unknown
1553
+ }
1763
1554
  // Conflicts with DOM types can be accessed through a three* prefix
1764
1555
  threeAudio: ThreeElementsImpl['audio']
1765
1556
  threeSource: ThreeElementsImpl['source']
@@ -1800,6 +1591,7 @@ type three_d_Matrix3 = Matrix3;
1800
1591
  type three_d_Matrix4 = Matrix4;
1801
1592
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1802
1593
  type three_d_NodeProps<P> = NodeProps<P>;
1594
+ type three_d_Object3DMethod = Object3DMethod;
1803
1595
  type three_d_Quaternion = Quaternion;
1804
1596
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1805
1597
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1814,7 +1606,7 @@ type three_d_Vector3 = Vector3;
1814
1606
  type three_d_Vector4 = Vector4;
1815
1607
  type three_d_VectorRepresentation = VectorRepresentation;
1816
1608
  declare namespace three_d {
1817
- 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 };
1609
+ 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 };
1818
1610
  }
1819
1611
 
1820
1612
  /**
@@ -1824,7 +1616,7 @@ declare namespace three_d {
1824
1616
  * a single WebGPURenderer using Three.js CanvasTarget API.
1825
1617
  *
1826
1618
  * Primary canvas: Has `id` prop, creates its own renderer, registers here
1827
- * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1619
+ * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1828
1620
  */
1829
1621
 
1830
1622
  interface PrimaryCanvasEntry {
@@ -1892,12 +1684,23 @@ type EnvironmentLoaderProps = {
1892
1684
  * const texture = useEnvironment({ preset: 'sunset' })
1893
1685
  * ```
1894
1686
  */
1895
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1687
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1896
1688
  declare namespace useEnvironment {
1897
1689
  var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1898
1690
  var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1899
1691
  }
1900
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1692
+ /**
1693
+ * Options accepted by `useEnvironment.preload`.
1694
+ *
1695
+ * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1696
+ * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1697
+ * advertise an option this function silently ignores.
1698
+ *
1699
+ * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1700
+ * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1701
+ * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1702
+ */
1703
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1901
1704
  type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1902
1705
 
1903
1706
  /**
@@ -1941,9 +1744,9 @@ type EnvironmentProps = {
1941
1744
  blur?: number;
1942
1745
  backgroundBlurriness?: number;
1943
1746
  backgroundIntensity?: number;
1944
- backgroundRotation?: Euler$2;
1747
+ backgroundRotation?: Euler;
1945
1748
  environmentIntensity?: number;
1946
- environmentRotation?: Euler$2;
1749
+ environmentRotation?: Euler;
1947
1750
  map?: Texture$1;
1948
1751
  preset?: PresetsType;
1949
1752
  scene?: Scene | React$1.RefObject<Scene>;
@@ -2027,7 +1830,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
2027
1830
  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;
2028
1831
  declare module '@react-three/fiber' {
2029
1832
  interface ThreeElements {
2030
- groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
1833
+ groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
2031
1834
  }
2032
1835
  }
2033
1836
  /**
@@ -2127,6 +1930,24 @@ declare module '@react-three/fiber' {
2127
1930
  */
2128
1931
  declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
2129
1932
 
1933
+ /**
1934
+ * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1935
+ *
1936
+ * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1937
+ * instance. Removing the old object from the interaction state and registering the new one from
1938
+ * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1939
+ * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1940
+ * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1941
+ * swap the user never asked to see (#3744).
1942
+ *
1943
+ * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1944
+ * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1945
+ *
1946
+ * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1947
+ * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1948
+ * cannot outlive the object it described.
1949
+ */
1950
+ declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
2130
1951
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
2131
1952
  declare function createEvents(store: RootStore): {
2132
1953
  handlePointer: (name: string) => (event: DomEvent) => void;
@@ -2134,7 +1955,7 @@ declare function createEvents(store: RootStore): {
2134
1955
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
2135
1956
  };
2136
1957
  /** Default R3F event manager for web */
2137
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1958
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
2138
1959
 
2139
1960
  /**
2140
1961
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -2147,419 +1968,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
2147
1968
  * Note: this hook's caller must be wrapped with `React.Suspense`
2148
1969
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
2149
1970
  */
2150
- 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>;
1971
+ 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>;
2151
1972
  declare namespace useLoader {
2152
- var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
2153
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
1973
+ 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;
1974
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
2154
1975
  var loader: typeof getLoader;
2155
1976
  }
2156
1977
 
2157
- /**
2158
- * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
2159
- *
2160
- * Features:
2161
- * - Single RAF loop for entire application
2162
- * - Root registration (multiple Canvas support)
2163
- * - Global phases for addEffect/addAfterEffect (deprecated)
2164
- * - Per-root job management with phases, priorities, FPS throttling
2165
- * - onIdle callbacks for addTail (deprecated)
2166
- * - Demand mode support via invalidate()
2167
- */
2168
- declare class Scheduler {
2169
- private static readonly INSTANCE_KEY;
2170
- private static get instance();
2171
- private static set instance(value);
2172
- /**
2173
- * Get the global scheduler instance (creates if doesn't exist).
2174
- * Uses HMR data to preserve instance across hot reloads.
2175
- * @returns {Scheduler} The singleton scheduler instance
2176
- */
2177
- static get(): Scheduler;
2178
- /**
2179
- * Reset the singleton instance. Stops the loop and clears all state.
2180
- * Primarily used for testing to ensure clean state between tests.
2181
- * @returns {void}
2182
- */
2183
- static reset(): void;
2184
- private roots;
2185
- private phaseGraph;
2186
- private loopState;
2187
- private stoppedTime;
2188
- private nextRootIndex;
2189
- private globalBeforeJobs;
2190
- private globalAfterJobs;
2191
- private nextGlobalIndex;
2192
- private idleCallbacks;
2193
- private nextJobIndex;
2194
- private jobStateListeners;
2195
- private pendingFrames;
2196
- private _frameloop;
2197
- private _independent;
2198
- private errorHandler;
2199
- private rootReadyCallbacks;
2200
- get phases(): string[];
2201
- get frameloop(): Frameloop;
2202
- set frameloop(mode: Frameloop);
2203
- get isRunning(): boolean;
2204
- get isReady(): boolean;
2205
- get independent(): boolean;
2206
- set independent(value: boolean);
2207
- constructor();
2208
- /**
2209
- * Register a root (Canvas) with the scheduler.
2210
- * The first root to register starts the RAF loop (if frameloop='always').
2211
- * @param {string} id - Unique identifier for this root
2212
- * @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
2213
- * @returns {() => void} Unsubscribe function to remove this root
2214
- */
2215
- registerRoot(id: string, options?: RootOptions): () => void;
2216
- /**
2217
- * Unregister a root from the scheduler.
2218
- * Cleans up all job state listeners for this root's jobs.
2219
- * The last root to unregister stops the RAF loop.
2220
- * @param {string} id - The root ID to unregister
2221
- * @returns {void}
2222
- */
2223
- unregisterRoot(id: string): void;
2224
- /**
2225
- * Subscribe to be notified when a root becomes available.
2226
- * Fires immediately if a root already exists.
2227
- * @param {() => void} callback - Function called when first root registers
2228
- * @returns {() => void} Unsubscribe function
2229
- */
2230
- onRootReady(callback: () => void): () => void;
2231
- /**
2232
- * Notify all registered root-ready callbacks.
2233
- * Called when the first root registers.
2234
- * @returns {void}
2235
- * @private
2236
- */
2237
- private notifyRootReady;
2238
- /**
2239
- * Ensure a default root exists for independent mode.
2240
- * Creates a minimal root with no state provider.
2241
- * @returns {void}
2242
- * @private
2243
- */
2244
- private ensureDefaultRoot;
2245
- /**
2246
- * Trigger error handling for job errors.
2247
- * Uses the bound error handler if available, otherwise logs to console.
2248
- * @param {Error} error - The error to handle
2249
- * @returns {void}
2250
- */
2251
- triggerError(error: Error): void;
2252
- /**
2253
- * Add a named phase to the scheduler's execution order.
2254
- * Marks all roots for rebuild to incorporate the new phase.
2255
- * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
2256
- * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
2257
- * @returns {void}
2258
- * @example
2259
- * scheduler.addPhase('physics', { before: 'update' });
2260
- * scheduler.addPhase('postprocess', { after: 'render' });
2261
- */
2262
- addPhase(name: string, options?: AddPhaseOptions): void;
2263
- /**
2264
- * Check if a phase exists in the scheduler.
2265
- * @param {string} name - The phase name to check
2266
- * @returns {boolean} True if the phase exists
2267
- */
2268
- hasPhase(name: string): boolean;
2269
- /**
2270
- * Register a global job that runs once per frame (not per-root).
2271
- * Used internally by deprecated addEffect/addAfterEffect APIs.
2272
- * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
2273
- * @param {string} id - Unique identifier for this global job
2274
- * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
2275
- * @returns {() => void} Unsubscribe function to remove this global job
2276
- * @deprecated Use useFrame with phases instead
2277
- */
2278
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
2279
- /**
2280
- * Register an idle callback that fires when the loop stops.
2281
- * Used internally by deprecated addTail API.
2282
- * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
2283
- * @returns {() => void} Unsubscribe function to remove this idle callback
2284
- * @deprecated Use demand mode with invalidate() instead
2285
- */
2286
- onIdle(callback: (timestamp: number) => void): () => void;
2287
- /**
2288
- * Notify all registered idle callbacks.
2289
- * Called when the loop stops in demand mode.
2290
- * @param {number} timestamp - The RAF timestamp when idle occurred
2291
- * @returns {void}
2292
- * @private
2293
- */
2294
- private notifyIdle;
2295
- /**
2296
- * Register a job (frame callback) with a specific root.
2297
- * This is the core registration method used by useFrame internally.
2298
- * @param {FrameNextCallback} callback - The function to call each frame
2299
- * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
2300
- * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
2301
- * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
2302
- * @param {string} [options.phase] - Execution phase (defaults to 'update')
2303
- * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
2304
- * @param {number} [options.fps] - FPS throttle limit
2305
- * @param {boolean} [options.drop] - Drop frames when behind (default true)
2306
- * @param {boolean} [options.enabled] - Whether job is active (default true)
2307
- * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
2308
- * @returns {() => void} Unsubscribe function to remove this job
2309
- */
2310
- register(callback: FrameNextCallback, options?: JobOptions & {
2311
- rootId?: string;
2312
- system?: boolean;
2313
- }): () => void;
2314
- /**
2315
- * Unregister a job by its ID.
2316
- * Searches all roots if rootId is not provided.
2317
- * @param {string} id - The job ID to unregister
2318
- * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
2319
- * @returns {void}
2320
- */
2321
- unregister(id: string, rootId?: string): void;
2322
- /**
2323
- * Update a job's options dynamically.
2324
- * Searches all roots to find the job by ID.
2325
- * Phase/constraint changes trigger a rebuild of the sorted job list.
2326
- * @param {string} id - The job ID to update
2327
- * @param {Partial<JobOptions>} options - The options to update
2328
- * @returns {void}
2329
- */
2330
- updateJob(id: string, options: Partial<JobOptions>): void;
2331
- /**
2332
- * Check if a job is currently paused (disabled).
2333
- * @param {string} id - The job ID to check
2334
- * @returns {boolean} True if the job exists and is paused
2335
- */
2336
- isJobPaused(id: string): boolean;
2337
- /**
2338
- * Subscribe to state changes for a specific job.
2339
- * Listener is called when job is paused or resumed.
2340
- * @param {string} id - The job ID to subscribe to
2341
- * @param {() => void} listener - Callback invoked on state changes
2342
- * @returns {() => void} Unsubscribe function
2343
- */
2344
- subscribeJobState(id: string, listener: () => void): () => void;
2345
- /**
2346
- * Notify all listeners that a job's state has changed.
2347
- * @param {string} id - The job ID that changed
2348
- * @returns {void}
2349
- * @private
2350
- */
2351
- private notifyJobStateChange;
2352
- /**
2353
- * Pause a job by ID (sets enabled=false).
2354
- * Notifies any subscribed state listeners.
2355
- * @param {string} id - The job ID to pause
2356
- * @returns {void}
2357
- */
2358
- pauseJob(id: string): void;
2359
- /**
2360
- * Resume a paused job by ID (sets enabled=true).
2361
- * Resets job timing to prevent frame accumulation.
2362
- * Notifies any subscribed state listeners.
2363
- * @param {string} id - The job ID to resume
2364
- * @returns {void}
2365
- */
2366
- resumeJob(id: string): void;
2367
- /**
2368
- * Start the requestAnimationFrame loop.
2369
- * Resets timing state (elapsedTime, frameCount) on start.
2370
- * No-op if already running.
2371
- * @returns {void}
2372
- */
2373
- start(): void;
2374
- /**
2375
- * Stop the requestAnimationFrame loop.
2376
- * Cancels any pending RAF callback.
2377
- * No-op if not running.
2378
- * @returns {void}
2379
- */
2380
- stop(): void;
2381
- /**
2382
- * Request frames to be rendered in demand mode.
2383
- * Accumulates pending frames (capped at 60) and starts the loop if not running.
2384
- * No-op if frameloop is not 'demand'.
2385
- * @param {number} [frames=1] - Number of frames to request
2386
- * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
2387
- * - `false` (default): Sets pending frames to the specified value (replaces existing count)
2388
- * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
2389
- * @returns {void}
2390
- * @example
2391
- * // Request a single frame render
2392
- * scheduler.invalidate();
2393
- *
2394
- * @example
2395
- * // Request 5 frames (e.g., for animations)
2396
- * scheduler.invalidate(5);
2397
- *
2398
- * @example
2399
- * // Set pending frames to exactly 3 (don't stack with existing)
2400
- * scheduler.invalidate(3, false);
2401
- *
2402
- * @example
2403
- * // Add 2 more frames to existing pending count
2404
- * scheduler.invalidate(2, true);
2405
- */
2406
- invalidate(frames?: number, stackFrames?: boolean): void;
2407
- /**
2408
- * Reset timing state for deterministic testing.
2409
- * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
2410
- * @returns {void}
2411
- */
2412
- resetTiming(): void;
2413
- /**
2414
- * Manually execute a single frame for all roots.
2415
- * Useful for frameloop='never' mode or testing scenarios.
2416
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2417
- * @returns {void}
2418
- * @example
2419
- * // Manual control mode
2420
- * scheduler.frameloop = 'never';
2421
- * scheduler.step(); // Execute one frame
2422
- */
2423
- step(timestamp?: number): void;
2424
- /**
2425
- * Manually execute a single job by its ID.
2426
- * Useful for testing individual job callbacks in isolation.
2427
- * @param {string} id - The job ID to step
2428
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2429
- * @returns {void}
2430
- */
2431
- stepJob(id: string, timestamp?: number): void;
2432
- /**
2433
- * Main RAF loop callback.
2434
- * Executes frame, handles demand mode, and schedules next frame.
2435
- * @param {number} timestamp - RAF timestamp in milliseconds
2436
- * @returns {void}
2437
- * @private
2438
- */
2439
- private loop;
2440
- /**
2441
- * Execute a single frame across all roots.
2442
- * Order: globalBefore → each root's jobs → globalAfter
2443
- * @param {number} timestamp - RAF timestamp in milliseconds
2444
- * @returns {void}
2445
- * @private
2446
- */
2447
- private executeFrame;
2448
- /**
2449
- * Run all global jobs from a job map.
2450
- * Catches and logs errors without stopping execution.
2451
- * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
2452
- * @param {number} timestamp - RAF timestamp in milliseconds
2453
- * @returns {void}
2454
- * @private
2455
- */
2456
- private runGlobalJobs;
2457
- /**
2458
- * Execute all jobs for a single root in sorted order.
2459
- * Rebuilds sorted job list if needed, then dispatches each job.
2460
- * Errors are caught and propagated via triggerError.
2461
- * @param {RootEntry} root - The root entry to tick
2462
- * @param {number} timestamp - RAF timestamp in milliseconds
2463
- * @param {number} delta - Time since last frame in seconds
2464
- * @returns {void}
2465
- * @private
2466
- */
2467
- private tickRoot;
2468
- /**
2469
- * Get the total number of registered jobs across all roots.
2470
- * Includes both per-root jobs and global before/after jobs.
2471
- * @returns {number} Total job count
2472
- */
2473
- getJobCount(): number;
2474
- /**
2475
- * Get all registered job IDs across all roots.
2476
- * Includes both per-root jobs and global before/after jobs.
2477
- * @returns {string[]} Array of all job IDs
2478
- */
2479
- getJobIds(): string[];
2480
- /**
2481
- * Get the number of registered roots (Canvas instances).
2482
- * @returns {number} Number of registered roots
2483
- */
2484
- getRootCount(): number;
2485
- /**
2486
- * Check if any user (non-system) jobs are registered in a specific phase.
2487
- * Used by the default render job to know if a user has taken over rendering.
2488
- *
2489
- * @param phase The phase to check
2490
- * @param rootId Optional root ID to check (checks all roots if not provided)
2491
- * @returns true if any user jobs exist in the phase
2492
- */
2493
- hasUserJobsInPhase(phase: string, rootId?: string): boolean;
2494
- /**
2495
- * Generate a unique root ID for automatic root registration.
2496
- * @returns {string} A unique root ID in the format 'root_N'
2497
- */
2498
- generateRootId(): string;
2499
- /**
2500
- * Generate a unique job ID.
2501
- * @returns {string} A unique job ID in the format 'job_N'
2502
- * @private
2503
- */
2504
- private generateJobId;
2505
- /**
2506
- * Normalize before/after constraints to a Set.
2507
- * Handles undefined, single string, or array inputs.
2508
- * @param {string | string[] | undefined} value - The constraint value(s)
2509
- * @returns {Set<string>} Normalized Set of constraint strings
2510
- * @private
2511
- */
2512
- private normalizeConstraints;
2513
- }
2514
- /**
2515
- * Get the global scheduler instance.
2516
- * Creates one if it doesn't exist.
2517
- */
2518
- declare const getScheduler: () => Scheduler;
2519
-
2520
- /**
2521
- * Frame hook with phase-based ordering, priority, and FPS throttling.
2522
- *
2523
- * Works both inside and outside Canvas context:
2524
- * - Inside Canvas: Full RootState (gl, scene, camera, etc.)
2525
- * - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
2526
- * - Outside Canvas (independent mode): Fires immediately with timing-only state
2527
- *
2528
- * Returns a controls object for manual stepping, pausing, and resuming.
2529
- *
2530
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
2531
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
2532
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
2533
- *
2534
- * @example
2535
- * // Simple priority (backwards compat)
2536
- * useFrame((state, delta) => { ... }, 5)
2537
- *
2538
- * @example
2539
- * // With phase-based ordering
2540
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
2541
- *
2542
- * @example
2543
- * // Outside Canvas - waits for Canvas to mount
2544
- * function UI() {
2545
- * useFrame((state, delta) => { syncUI(state.camera) });
2546
- * return <button>...</button>;
2547
- * }
2548
- *
2549
- * @example
2550
- * // Independent mode - no Canvas needed
2551
- * getScheduler().independent = true;
2552
- * useFrame((state, delta) => { updateGame(delta) });
2553
- *
2554
- * @example
2555
- * // Scheduler-only access (no callback)
2556
- * const { scheduler } = useFrame()
2557
- * scheduler.pauseJob('some-job-id')
2558
- *
2559
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
2560
- */
2561
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
2562
-
2563
1978
  declare const IsObject: (url: unknown) => url is Record<string, string>;
2564
1979
  type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2565
1980
  type TextureRecord<T> = T extends Record<string, string> ? {
@@ -2572,11 +1987,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
2572
1987
  /** Callback when texture(s) finish loading */
2573
1988
  onLoad?: (texture: MappedTextureType<Url>) => void;
2574
1989
  /**
2575
- * Cache the texture in R3F's global state for access via useTextures().
2576
- * When true:
1990
+ * Register the texture(s) in R3F's global texture registry for access via useTextures().
1991
+ * When true (the default):
2577
1992
  * - Textures persist until explicitly disposed
2578
- * - Returns existing cached textures if available (preserving modifications like colorSpace)
2579
- * @default false
1993
+ * - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
1994
+ *
1995
+ * Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
1996
+ * changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
1997
+ *
1998
+ * Pass `false` to opt out of registry enrollment entirely.
1999
+ * @default true
2580
2000
  */
2581
2001
  cache?: boolean;
2582
2002
  };
@@ -2600,15 +2020,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
2600
2020
  * normal: '/normal.png'
2601
2021
  * })
2602
2022
  *
2603
- * // With caching - returns same texture object across components
2604
- * // Modifications (colorSpace, wrapS, etc.) are preserved
2605
- * const diffuse = useTexture('/diffuse.png', { cache: true })
2023
+ * // Textures are registered in the global registry by default — the same texture
2024
+ * // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
2025
+ * const diffuse = useTexture('/diffuse.png')
2606
2026
  * diffuse.colorSpace = THREE.SRGBColorSpace
2607
2027
  *
2608
2028
  * // Another component gets the SAME texture with colorSpace already set
2609
- * const sameDiffuse = useTexture('/diffuse.png', { cache: true })
2029
+ * const sameDiffuse = useTexture('/diffuse.png')
2030
+ *
2031
+ * // Opt out of registry enrollment for a one-off texture
2032
+ * const scratch = useTexture('/scratch.png', { cache: false })
2610
2033
  *
2611
- * // Access cache directly
2034
+ * // Access the registry directly
2612
2035
  * const { get } = useTextures()
2613
2036
  * const cached = get('/diffuse.png')
2614
2037
  * ```
@@ -2625,63 +2048,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
2625
2048
  cache?: boolean;
2626
2049
  }) => react_jsx_runtime.JSX.Element;
2627
2050
 
2628
- type TextureEntry = Texture$1 | {
2629
- value: Texture$1;
2630
- [key: string]: any;
2051
+ /** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
2052
+ type TextureInput = string | string[] | Record<string, string>;
2053
+ /** Result of a `get()` read, mirroring the input shape. */
2054
+ type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
2055
+ [K in keyof Input]: Texture$1 | undefined;
2631
2056
  };
2057
+ /** Options for `dispose()`. */
2058
+ interface DisposeOptions {
2059
+ /** Dispose even if the texture still has active references (default false). */
2060
+ force?: boolean;
2061
+ }
2632
2062
  interface UseTexturesReturn {
2633
- /** Map of all textures currently in cache */
2634
- textures: Map<string, TextureEntry>;
2635
- /** Get a specific texture by key (usually URL) */
2636
- get: (key: string) => TextureEntry | undefined;
2637
- /** Check if a texture exists in cache */
2638
- has: (key: string) => boolean;
2639
- /** Add a texture to the cache */
2640
- add: (key: string, value: TextureEntry) => void;
2641
- /** Add multiple textures to the cache */
2642
- addMultiple: (items: Map<string, TextureEntry> | Record<string, TextureEntry>) => void;
2643
- /** Remove a texture from cache (does NOT dispose GPU resources) */
2644
- remove: (key: string) => void;
2645
- /** Remove multiple textures from cache */
2646
- removeMultiple: (keys: string[]) => void;
2647
- /** Dispose a texture's GPU resources and remove from cache */
2648
- dispose: (key: string) => void;
2649
- /** Dispose multiple textures */
2650
- disposeMultiple: (keys: string[]) => void;
2651
- /** Dispose ALL cached textures - use with caution */
2652
- disposeAll: () => void;
2063
+ /** The live registry Map (key → Texture). Treat as read-only. */
2064
+ readonly all: Map<string, Texture$1>;
2065
+ /** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
2066
+ get<Input extends TextureInput>(input: Input): TextureResult<Input>;
2067
+ /** Check whether a key exists in the registry. */
2068
+ has(key: string): boolean;
2069
+ /**
2070
+ * Register a texture (or a record of textures) that has no URL — e.g. a render
2071
+ * target or procedural texture. URL-loaded textures are registered automatically
2072
+ * by `useTexture` (registry enrollment is on by default).
2073
+ */
2074
+ add(key: string, texture: Texture$1): void;
2075
+ add(record: Record<string, Texture$1>): void;
2076
+ /**
2077
+ * Dispose a texture's GPU resources and remove it from the registry.
2078
+ * Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
2079
+ * skipped (with a warning) unless `{ force: true }` is passed.
2080
+ * @returns true if disposed, false if skipped.
2081
+ */
2082
+ dispose(key: string, options?: DisposeOptions): boolean;
2083
+ /** Dispose every texture in the registry and clear it. Use on scene teardown. */
2084
+ disposeAll(): void;
2653
2085
  }
2654
2086
  /**
2655
- * Hook for managing the global texture cache in R3F state.
2087
+ * Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
2088
+ *
2089
+ * This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
2090
+ * a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
2091
+ * `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
2656
2092
  *
2657
- * Textures are stored in a Map with URL/path keys for efficient lookup.
2658
- * Useful for sharing texture references across materials and components.
2093
+ * The returned handle is **reactive**: the calling component re-renders when the registry
2094
+ * changes. Pass a selector to scope the subscription to a single read.
2659
2095
  *
2660
2096
  * @example
2661
2097
  * ```tsx
2662
- * const { textures, add, get, remove, has, dispose } = useTextures()
2663
- *
2664
- * // Check if texture is already cached
2665
- * if (!has('/textures/diffuse.png')) {
2666
- * // Load with useTexture and cache: true, or manually add
2667
- * const tex = useTexture('/textures/diffuse.png', { cache: true })
2668
- * }
2098
+ * // Load + register once (anywhere in the tree) — registered by default
2099
+ * useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
2669
2100
  *
2670
- * // Access cached texture from anywhere
2671
- * const diffuse = get('/textures/diffuse.png')
2672
- * if (diffuse) material.map = diffuse
2101
+ * // Reach them from another component — record form lands straight into a material
2102
+ * const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
2103
+ * return <meshStandardMaterial map={map} normalMap={normalMap} />
2673
2104
  *
2674
- * // Remove from cache only (texture still in GPU memory)
2675
- * remove('/textures/old.png')
2105
+ * // A set of heightmaps at once
2106
+ * const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
2676
2107
  *
2677
- * // Fully dispose (frees GPU memory + removes from cache)
2678
- * dispose('/textures/unused.png')
2108
+ * // Register a non-URL texture (render target / procedural)
2109
+ * useTextures().add('rt-main', renderTarget.texture)
2679
2110
  *
2680
- * // Nuclear option - dispose everything
2681
- * disposeAll()
2111
+ * // Deliberate GPU cleanup (refcount-aware; force to override)
2112
+ * useTextures().dispose('/diffuse.jpg')
2113
+ * useTextures().disposeAll() // scene teardown
2682
2114
  * ```
2115
+ *
2116
+ * @remarks
2117
+ * **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
2118
+ * intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
2119
+ * populate the registry without Suspense, at the cost of putting loading back into this hook. It
2120
+ * will be added only if a concrete consumer needs imperative loading; for now, loading lives in
2121
+ * `useTexture`.
2683
2122
  */
2684
2123
  declare function useTextures(): UseTexturesReturn;
2124
+ declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
2685
2125
 
2686
2126
  /**
2687
2127
  * Creates a render target compatible with the current renderer.
@@ -2720,11 +2160,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
2720
2160
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2721
2161
  */
2722
2162
  declare function useStore(): RootStore;
2723
- /**
2724
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2725
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2726
- */
2727
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2728
2163
  /**
2729
2164
  * Exposes an object's {@link Instance}.
2730
2165
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2800,7 +2235,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2800
2235
  * Invalidates the view, requesting a frame to be rendered.
2801
2236
  * In demand mode, this triggers the scheduler to run frames.
2802
2237
  *
2803
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2238
+ * With a state argument, only that root's jobs run on the requested frames; other
2239
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2240
+ *
2241
+ * @param state - Optional root state; targets the invalidation at that root
2804
2242
  * @param frames - Number of frames to request (default: 1)
2805
2243
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2806
2244
  *
@@ -2811,14 +2249,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2811
2249
  * Advances the frameloop and runs render effects.
2812
2250
  * Useful for when manually rendering via `frameloop="never"`.
2813
2251
  *
2252
+ * With a state argument, only that root is stepped. Without one, every
2253
+ * registered root is stepped for backwards compatibility.
2254
+ *
2814
2255
  * @param timestamp - The timestamp to use for this frame
2815
2256
  * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2816
- * @param state - Ignored (kept for backwards compat)
2817
- * @param frame - Ignored (kept for backwards compat)
2257
+ * @param state - Optional root state; targets the manual step at that root
2818
2258
  *
2819
2259
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2820
2260
  */
2821
- declare function advance(timestamp: number): void;
2261
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2822
2262
 
2823
2263
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2824
2264
  declare function ReactReconciler<
@@ -3863,6 +3303,7 @@ declare namespace ReactReconciler {
3863
3303
 
3864
3304
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3865
3305
  declare function extend<T extends Catalogue>(objects: T): void;
3306
+ declare function extend(objects: Record<string, unknown>): void;
3866
3307
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3867
3308
 
3868
3309
  declare const isRenderer: (def: any) => boolean;
@@ -3889,11 +3330,6 @@ declare function flushSync<R>(fn: () => R): R;
3889
3330
  declare const context: React$1.Context<RootStore>;
3890
3331
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3891
3332
 
3892
- /**
3893
- * Safely flush async effects when testing, simulating a legacy root.
3894
- * @deprecated Import from React instead. import { act } from 'react'
3895
- */
3896
- declare const act: typeof React$1.act;
3897
3333
  /**
3898
3334
  * An SSR-friendly useLayoutEffect.
3899
3335
  *
@@ -4145,7 +3581,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
4145
3581
  declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
4146
3582
  /**
4147
3583
  * Triggers an update for an instance.
4148
- * Calls onUpdate callback and invalidates the frame if necessary.
3584
+ * Invalidates the frame if the root is in demand mode.
4149
3585
  *
4150
3586
  * @param instance - Instance to invalidate
4151
3587
  */
@@ -4311,29 +3747,44 @@ declare const hasConstructor: (object: unknown) => object is {
4311
3747
  * Used to identify values that should be resolved from refs after mount.
4312
3748
  */
4313
3749
  declare const FROM_REF: unique symbol;
3750
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3751
+ interface FromRefMarker<T = unknown, R = T> {
3752
+ [FROM_REF]: React$1.RefObject<T | null>;
3753
+ /** Optional transform applied to the resolved ref before assignment. */
3754
+ transform?: (value: T) => R;
3755
+ }
4314
3756
  /**
4315
3757
  * Defers prop application until the referenced object is available.
4316
3758
  * Useful for props like `target` that need sibling refs to be populated.
4317
3759
  *
3760
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3761
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3762
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3763
+ * what gets assigned.
3764
+ *
4318
3765
  * @param ref - React ref object to resolve at mount time
4319
- * @returns A marker value that applyProps will resolve after mount
3766
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3767
+ * @returns A marker value that the reconciler resolves after mount
4320
3768
  *
4321
3769
  * @example
4322
3770
  * const targetRef = useRef<THREE.Object3D>(null)
4323
3771
  *
4324
3772
  * <group ref={targetRef} position={[-3, -2, -15]} />
4325
3773
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3774
+ *
3775
+ * @example
3776
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3777
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
4326
3778
  */
4327
3779
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3780
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
4328
3781
  /**
4329
3782
  * Type guard to check if a value is a fromRef marker.
4330
3783
  *
4331
3784
  * @param value - Value to check
4332
3785
  * @returns True if value is a fromRef marker
4333
3786
  */
4334
- declare function isFromRef(value: unknown): value is {
4335
- [FROM_REF]: React$1.RefObject<any>;
4336
- };
3787
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
4337
3788
 
4338
3789
  /**
4339
3790
  * Symbol marker for mount-only method calls.
@@ -4360,7 +3811,15 @@ declare const ONCE: unique symbol;
4360
3811
  * // No arguments
4361
3812
  * <geometry center={once()} />
4362
3813
  */
4363
- declare function once<T>(...args: T[]): T;
3814
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3815
+ /**
3816
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3817
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3818
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3819
+ *
3820
+ * The runtime value is always the marker object; only the declared type follows the prop.
3821
+ */
3822
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
4364
3823
  /**
4365
3824
  * Type guard to check if a value is a once marker.
4366
3825
  *
@@ -4372,10 +3831,31 @@ declare function isOnce(value: unknown): value is {
4372
3831
  };
4373
3832
 
4374
3833
  /**
4375
- * A DOM canvas which accepts threejs elements as children.
4376
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3834
+ * @fileoverview Legacy entry point - WebGL only
3835
+ *
3836
+ * This entry point is for apps that want to use the legacy WebGLRenderer.
3837
+ * No WebGPU features are available from this import path.
3838
+ * Auto-extends THREE with WebGL-only constructors (no node materials).
3839
+ *
3840
+ * Usage:
3841
+ * import { Canvas, useFrame } from '@react-three/fiber/legacy'
4377
3842
  */
4378
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
4379
3843
 
4380
- 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, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, 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, reconciler, registerPrimary, removeInteractivity, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
4381
- export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, 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, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, LegacyRootState as RootState, RootStore, SchedulerApi, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
3844
+ /** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
3845
+ type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
3846
+ /** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
3847
+ type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
3848
+ declare const useThree: UseThreeLegacy;
3849
+ declare const useFrame: UseFrameLegacy;
3850
+
3851
+ /** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
3852
+ type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
3853
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
3854
+ onCreated?: (state: LegacyRootState) => void;
3855
+ };
3856
+
3857
+ /** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
3858
+ declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
3859
+
3860
+ 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, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, 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, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
3861
+ export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, LegacyCanvasProps as CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, 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, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyCanvasProps, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameLegacy, UseTextureOptions, UseTexturesReturn, UseThreeLegacy, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };