@react-three/fiber 10.0.0-canary.4bc4a97 → 10.0.0-canary.4bf885a

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.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as THREE$1 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, 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
9
  import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
@@ -38,12 +38,12 @@ function _mergeNamespaces(n, m) {
38
38
  declare const R3F_BUILD_LEGACY = true;
39
39
  declare const R3F_BUILD_WEBGPU = false;
40
40
 
41
- declare const Inspector: {
42
- new (): {};
43
- };
44
- declare const WebGPURenderer: {
45
- new (): {};
46
- };
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
+ }
47
47
 
48
48
  declare const RenderTarget: any;
49
49
 
@@ -58,7 +58,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
58
58
  R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
59
59
  RenderTarget: RenderTarget,
60
60
  RenderTargetCompat: WebGLRenderTarget,
61
- WebGPURenderer: WebGPURenderer
61
+ WebGPURenderer: WebGPURenderer,
62
+ loadInspector: loadInspector
62
63
  }, [THREE$1]);
63
64
 
64
65
  //* Utility Types ==============================
@@ -347,6 +348,7 @@ type BufferLike =
347
348
  | Uint16Array
348
349
  | Int16Array
349
350
  | THREE$1.BufferAttribute // Base class for all buffer attributes
351
+ | THREE$1.InterleavedBufferAttribute
350
352
  | Node // TSL buffer nodes (instancedArray, storage)
351
353
 
352
354
  /** Flat record of buffer-like values (no nested scopes) */
@@ -358,6 +360,25 @@ type BufferRecord = Record<string, BufferLike>
358
360
  */
359
361
  type BufferStore = Record<string, BufferLike | BufferRecord>
360
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
+
361
382
  //* Storage Types (useGPUStorage) ========================================
362
383
 
363
384
  /**
@@ -372,7 +393,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
372
393
  * ```
373
394
  */
374
395
  type StorageLike =
375
- | 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
376
399
  | Data3DTexture // 3D texture (can be used as storage)
377
400
  | Node // TSL storage texture nodes (storageTexture)
378
401
 
@@ -484,6 +507,12 @@ interface InternalState {
484
507
  actualRenderer: R3FRenderer
485
508
  /** Global scheduler reference (for useFrame hook) */
486
509
  scheduler: SchedulerApi | null
510
+ /**
511
+ * Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
512
+ * `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
513
+ * render-phase takeover. Used by `useRenderPipeline`.
514
+ */
515
+ renderOverride?: (() => void) | null
487
516
  /** This root's unique ID in the global scheduler */
488
517
  rootId?: string
489
518
  /** Function to unregister this root from the global scheduler */
@@ -491,11 +520,28 @@ interface InternalState {
491
520
  /** Container for child attachment (scene for root, original container for portals) */
492
521
  container?: THREE$1.Object3D
493
522
  /**
494
- * CanvasTarget for multi-canvas WebGPU rendering.
495
- * Created for all WebGPU canvases to support renderer sharing.
523
+ * The CanvasTarget this root sizes and renders through.
524
+ *
525
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
526
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
527
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
528
+ * and the canvas-target job makes it the renderer's active one before this root renders.
529
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
496
530
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
497
531
  */
498
532
  canvasTarget?: CanvasTarget
533
+ /**
534
+ * Set when this root's canvas target has been resized and the backend's cached render pass
535
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
536
+ *
537
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
538
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
539
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
540
+ * invalidate some other canvas's descriptor instead.
541
+ *
542
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
543
+ */
544
+ canvasTargetSizeDirty?: boolean
499
545
  /**
500
546
  * Whether multi-canvas rendering is active.
501
547
  * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
@@ -605,7 +651,7 @@ interface RootState {
605
651
  /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
606
652
  uniforms: UniformStore
607
653
  /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
608
- nodes: Record<string, any>
654
+ nodes: NodeStore
609
655
  /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
610
656
  buffers: BufferStore
611
657
  /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
@@ -617,7 +663,7 @@ interface RootState {
617
663
  /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
618
664
  renderPipeline: ThreeRenderPipeline | null
619
665
  /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
620
- passes: Record<string, any>
666
+ passes: PassRecord
621
667
  /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
622
668
  _hmrVersion: number
623
669
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
@@ -705,12 +751,19 @@ type DefaultRendererProps = {
705
751
  */
706
752
  interface CanvasSchedulerConfig {
707
753
  /**
708
- * Render this canvas after another canvas completes.
709
- * Pass the `id` of another canvas.
754
+ * Run this Canvas root before the referenced Canvas root id(s).
755
+ */
756
+ before?: string | string[]
757
+ /**
758
+ * Run this Canvas root after the referenced Canvas root id(s).
759
+ */
760
+ after?: string | string[]
761
+ /**
762
+ * Numeric root order. Lower values run first.
710
763
  */
711
- after?: string
764
+ order?: number
712
765
  /**
713
- * Limit this canvas's render rate (frames per second).
766
+ * Limit this Canvas's default render job (frames per second).
714
767
  */
715
768
  fps?: number
716
769
  }
@@ -797,14 +850,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
797
850
  performance?: Partial<Omit<Performance, 'regress'>>
798
851
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
799
852
  dpr?: Dpr
800
- /** Props that go into the default raycaster */
801
- raycaster?: Partial<THREE$1.Raycaster>
853
+ /**
854
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
855
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
856
+ */
857
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
802
858
  /** A `THREE.Scene` instance or props that go into the default scene */
803
859
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
804
860
  /** A `THREE.Camera` instance or props that go into the default camera */
805
861
  camera?: CameraProps
806
862
  /** An R3F event manager to manage elements' pointer events */
807
- events?: (store: RootStore) => EventManager<HTMLElement>
863
+ events?: (store: RootStore) => EventManager<Element>
808
864
  /** Callback after the canvas has rendered (but not yet committed) */
809
865
  onCreated?: (state: RootState) => void
810
866
  /** Response for pointer clicks that have missed any target */
@@ -893,7 +949,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
893
949
  object?: T
894
950
  dispose?: null
895
951
  attach?: AttachType<T>
896
- onUpdate?: (self: T) => void
897
952
  }
898
953
 
899
954
  interface Instance<O = any> {
@@ -1033,7 +1088,7 @@ interface CanvasProps
1033
1088
  */
1034
1089
  resize?: Options
1035
1090
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1036
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1091
+ eventSource?: Element | React$1.RefObject<Element | null>
1037
1092
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1038
1093
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1039
1094
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1141,81 +1196,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1141
1196
 
1142
1197
  type RenderTargetOptions = RenderTargetOptions$1
1143
1198
 
1144
- //* Global Types ==============================
1199
+ //* Global TSL Types ==============================
1145
1200
 
1146
1201
  declare global {
1147
1202
  /**
1148
- * Uniform node type.
1149
- *
1150
- * This is three's own `UniformNode`, not a re-declaration of it. It previously was a
1151
- * hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
1152
- * exported type globally — so R3F's ~58 references resolved to an approximation that was
1153
- * missing members three actually ships (`setName` among them) and had drifted to the wrong
1154
- * arity when three made `UniformNode` two-parameter.
1155
- *
1156
- * three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
1157
- * so the node type is fixed to `unknown` and the single parameter is kept for call-site
1158
- * ergonomics. The result is three's structural type, so members stay in sync with the
1159
- * installed three instead of needing to be mirrored by hand.
1203
+ * Broad callable-node fallback for dynamic store readers.
1204
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1160
1205
  */
1161
- type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
1206
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1207
+ readonly shaderNode: unknown
1208
+ readonly id: number
1209
+ }
1162
1210
 
1163
- /**
1164
- * ShaderCallable - the return type of Fn()
1165
- * A callable shader function node that can be invoked with parameters.
1166
- * The function returns a ShaderNodeObject when called.
1167
- *
1168
- * @example
1169
- * ```tsx
1170
- * // Define a shader function
1171
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1172
- * return mix(color1, color2, factor)
1173
- * })
1174
- *
1175
- * // Type when retrieving from nodes store
1176
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1177
- *
1178
- * // Or with specific return type
1179
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1180
- * ```
1181
- */
1182
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1211
+ /** Legacy structural node accepted when at least one historical marker exists. */
1212
+ type LegacyTSLNodeLike = {
1213
+ label?: ((label: string) => unknown) | string
1214
+ setName?: (name: string) => unknown
1215
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1183
1216
 
1184
- /**
1185
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1186
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1187
- *
1188
- * @example
1189
- * ```tsx
1190
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1191
- * ```
1192
- */
1193
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1217
+ /** Node type accepted by broad dynamic node-store readers. */
1218
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1194
1219
 
1195
1220
  /**
1196
- * TSLNodeType - Union of all common TSL node types
1197
- * Used by ScopedStore to properly type node access from the store.
1198
- *
1199
- * Includes:
1200
- * - Node: base Three.js node type
1201
- * - ShaderCallable: function nodes created with Fn()
1202
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1203
- *
1204
- * @example
1205
- * ```tsx
1206
- * // In useLocalNodes, nodes are typed as TSLNodeType
1207
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1208
- * positionNode: nodes.myPosition, // Works - Node is in union
1209
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1210
- * }))
1211
- *
1212
- * // Can narrow with type guard or assertion when needed
1213
- * if (typeof blendColorFn === 'function') {
1214
- * blendColorFn(someColor, 0.5)
1215
- * }
1216
- * ```
1221
+ * Derive Three's shader node type from an existing node or a supported raw input.
1222
+ * Existing InputNode generics take precedence over structural value normalization.
1223
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1224
+ * InputNode base with its concrete InputNode specialization.
1217
1225
  */
1218
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1226
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1227
+ ? TNodeType
1228
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1229
+ ? TNodeType
1230
+ : T extends number
1231
+ ? 'float'
1232
+ : T extends boolean
1233
+ ? 'bool'
1234
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1235
+ ? 'color'
1236
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1237
+ ? 'vec4'
1238
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1239
+ ? 'vec3'
1240
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1241
+ ? 'vec2'
1242
+ : T extends three_webgpu.Matrix4
1243
+ ? 'mat4'
1244
+ : T extends three_webgpu.Matrix3
1245
+ ? 'mat3'
1246
+ : T extends three_webgpu.Matrix2
1247
+ ? 'mat2'
1248
+ : unknown
1249
+
1250
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1251
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1252
+ ? TValue
1253
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1254
+ ? TValue
1255
+ : T extends string | { r: number; g: number; b: number }
1256
+ ? three_webgpu.Color
1257
+ : T extends { x: number; y: number; z: number; w: number }
1258
+ ? three_webgpu.Vector4
1259
+ : T extends { x: number; y: number; z: number }
1260
+ ? three_webgpu.Vector3
1261
+ : T extends { x: number; y: number }
1262
+ ? three_webgpu.Vector2
1263
+ : T extends number
1264
+ ? number
1265
+ : T extends boolean
1266
+ ? boolean
1267
+ : T
1268
+
1269
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1270
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1271
+
1272
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1273
+ type UniformNodesFor<T extends UniformInputRecord> = {
1274
+ [K in keyof T]: UniformNodeFor<T[K]>
1275
+ }
1276
+
1277
+ /** Backward-compatible single-parameter uniform alias. */
1278
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1219
1279
 
1220
1280
  /** Flat record of uniform nodes (no nested scopes) */
1221
1281
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1240,7 +1300,7 @@ declare global {
1240
1300
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1241
1301
  * Supports:
1242
1302
  * - Primitives: number, string (color), boolean
1243
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1303
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1244
1304
  * - Plain objects: { x, y, z, w } converted to vectors
1245
1305
  * - TSL nodes: color(), vec3(), float() for type casting
1246
1306
  * - UniformNode: existing uniforms (reused as-is)
@@ -1253,88 +1313,124 @@ declare global {
1253
1313
  | three_webgpu.Vector2
1254
1314
  | three_webgpu.Vector3
1255
1315
  | three_webgpu.Vector4
1316
+ | three_webgpu.Matrix2
1256
1317
  | three_webgpu.Matrix3
1257
1318
  | three_webgpu.Matrix4
1258
- | three_webgpu.Euler
1259
- | three_webgpu.Quaternion
1260
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1319
+ | { x: number; y: number }
1320
+ | { x: number; y: number; z: number }
1321
+ | { x: number; y: number; z: number; w: number }
1261
1322
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1262
- | Node // TSL nodes like color(), vec3(), float() for type casting
1323
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1263
1324
  | UniformNode
1264
1325
 
1265
1326
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1266
1327
  type UniformInputRecord = Record<string, UniformValue>
1267
1328
  }
1268
1329
 
1269
- //* Module Augmentation ==============================
1270
-
1271
- declare module 'three/tsl' {
1330
+ declare global {
1272
1331
  /**
1273
- * Fn with array parameter destructuring
1274
- * @example Fn(([uv, skew]) => { ... })
1332
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1333
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1334
+ * is r185, so the new name is the only one.
1275
1335
  */
1276
- export function Fn<R extends Node = Node>(
1277
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1278
- ): ShaderCallable<R>
1336
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1279
1337
 
1280
1338
  /**
1281
- * Fn with object parameter destructuring
1282
- * @example Fn(({ color, intensity }) => { ... })
1339
+ * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1340
+ * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1341
+ * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1283
1342
  */
1284
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1285
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1286
- ): ShaderCallable<R>
1343
+ type ScenePassNode = three_webgpu.PassNode
1287
1344
 
1288
1345
  /**
1289
- * Fn with array params + layout
1290
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1346
+ * Pass record - stores TSL pass nodes for render pipeline.
1347
+ *
1348
+ * `scenePass` is the only key the library owns. It is optional here because this is also the
1349
+ * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1350
+ * or `clearPasses()`. Inside the callbacks it is always present; see
1351
+ * {@link RenderPipelineCallbackState}.
1352
+ *
1353
+ * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1354
+ * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1355
+ * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1356
+ * site when you need a member, e.g. `passes.velocity as TextureNode`.
1357
+ *
1358
+ * The index signature admits `undefined` because a key may simply not be registered, and
1359
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1360
+ * optional property whose type excludes `undefined` from the index signature is an error
1361
+ * (TS2411) for every consumer compiling these declarations.
1291
1362
  */
1292
- export function Fn<R extends Node = Node>(
1293
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1294
- layout: { layout?: unknown },
1295
- ): ShaderCallable<R>
1363
+ interface PassRecord {
1364
+ scenePass?: ScenePassNode
1365
+ [key: string]: three_webgpu.Node | undefined
1366
+ }
1296
1367
 
1297
1368
  /**
1298
- * Fn with object params + layout
1369
+ * State passed to pipeline callbacks after the active pipeline has been created.
1370
+ *
1371
+ * `passes.scenePass` is required here: the hook installs the default scene pass before either
1372
+ * callback runs, so callbacks can use it without a guard or a cast.
1373
+ *
1374
+ * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1375
+ * the legacy renderer before either callback can run, so a callback never sees WebGL.
1299
1376
  */
1300
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1301
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1302
- layout: { layout?: unknown },
1303
- ): ShaderCallable<R>
1304
- }
1377
+ type RenderPipelineCallbackState = RootState & {
1378
+ renderPipeline: ThreeRenderPipeline
1379
+ passes: PassRecord & { scenePass: ScenePassNode }
1380
+ renderer: three_webgpu.WebGPURenderer
1381
+ isLegacy: false
1382
+ }
1305
1383
 
1306
- declare global {
1307
1384
  /**
1308
- * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1309
- * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1310
- * is r185, so the new name is the only one.
1385
+ * What a callback may return to register entries into `state.passes`.
1386
+ *
1387
+ * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1388
+ * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1389
+ * store entry would leave the store pointing at a node the hook never disposes, and the hook
1390
+ * disposing a pass nothing references. So returning it is a type error.
1311
1391
  */
1312
- type ThreeRenderPipeline = three_webgpu.RenderPipeline
1313
-
1314
- /** Pass record - stores TSL pass nodes for render pipeline */
1315
- type PassRecord = Record<string, any>
1392
+ type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1316
1393
 
1317
1394
  /** Setup callback - runs first to configure MRT, create additional passes */
1318
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1395
+ type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1319
1396
 
1320
1397
  /** Main callback - runs second to configure outputNode, create effect passes */
1321
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1398
+ type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1322
1399
 
1323
- /** Return type for useRenderPipeline hook */
1324
- interface UseRenderPipelineReturn {
1400
+ /** The imperative half of useRenderPipeline's return value, present in every state */
1401
+ interface UseRenderPipelineActions {
1325
1402
  /** Current passes from state */
1326
1403
  passes: PassRecord
1327
- /** RenderPipeline instance (null if not initialized) */
1328
- renderPipeline: ThreeRenderPipeline | null
1329
1404
  /** Clear all passes from state */
1330
1405
  clearPasses: () => void
1331
1406
  /** Reset RenderPipeline entirely (clears PP + passes) */
1332
1407
  reset: () => void
1333
1408
  /** Re-run setup/main callbacks with current closure values */
1334
1409
  rebuild: () => void
1335
- /** True when RenderPipeline is configured and ready */
1336
- isReady: boolean
1337
1410
  }
1411
+
1412
+ /**
1413
+ * Return type for useRenderPipeline hook, discriminated on `isReady`.
1414
+ *
1415
+ * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1416
+ * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1417
+ * `clearPasses()` empties the record while leaving the pipeline in place.
1418
+ */
1419
+ type UseRenderPipelineReturn = UseRenderPipelineActions &
1420
+ (
1421
+ | {
1422
+ /** True when RenderPipeline is configured and ready */
1423
+ isReady: true
1424
+ /** RenderPipeline instance */
1425
+ renderPipeline: ThreeRenderPipeline
1426
+ }
1427
+ | {
1428
+ /** False until the pipeline has been created */
1429
+ isReady: false
1430
+ /** Not initialized yet, or torn down by reset() */
1431
+ renderPipeline: null
1432
+ }
1433
+ )
1338
1434
  }
1339
1435
 
1340
1436
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
@@ -1413,10 +1509,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1413
1509
 
1414
1510
  /**
1415
1511
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1416
- * since @types/three has broken inheritance for TSL node subclasses.
1512
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1513
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1417
1514
  */
1418
1515
  type NodeProps<P> = {
1419
- [K in keyof P as P[K] extends Node$1 | null ? K : never]?: TSLNodeInput
1516
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1420
1517
  }
1421
1518
 
1422
1519
  interface ReactProps<P> {
@@ -1437,11 +1534,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1437
1534
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1438
1535
  }
1439
1536
 
1537
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1538
+ type Object3DMethod = NonNullable<
1539
+ {
1540
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1541
+ }[keyof Object3D]
1542
+ >
1543
+
1440
1544
  type ThreeExports = typeof THREE
1441
1545
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1442
1546
 
1443
1547
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1444
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1548
+ /**
1549
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1550
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1551
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1552
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1553
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1554
+ */
1555
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
1556
+ object: object
1557
+ ref?: React.Ref<any>
1558
+ [prop: string]: unknown
1559
+ }
1445
1560
  // Conflicts with DOM types can be accessed through a three* prefix
1446
1561
  threeAudio: ThreeElementsImpl['audio']
1447
1562
  threeSource: ThreeElementsImpl['source']
@@ -1482,6 +1597,7 @@ type three_d_Matrix3 = Matrix3;
1482
1597
  type three_d_Matrix4 = Matrix4;
1483
1598
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1484
1599
  type three_d_NodeProps<P> = NodeProps<P>;
1600
+ type three_d_Object3DMethod = Object3DMethod;
1485
1601
  type three_d_Quaternion = Quaternion;
1486
1602
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1487
1603
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1496,7 +1612,7 @@ type three_d_Vector3 = Vector3;
1496
1612
  type three_d_Vector4 = Vector4;
1497
1613
  type three_d_VectorRepresentation = VectorRepresentation;
1498
1614
  declare namespace three_d {
1499
- 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 };
1615
+ 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 };
1500
1616
  }
1501
1617
 
1502
1618
  /**
@@ -1845,7 +1961,43 @@ declare function createEvents(store: RootStore): {
1845
1961
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1846
1962
  };
1847
1963
  /** Default R3F event manager for web */
1848
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1964
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
1965
+
1966
+ interface RootExtension {
1967
+ /** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
1968
+ * set up are not set up a second time, but get the new entry's dispose and hmr. */
1969
+ name: string;
1970
+ /**
1971
+ * Called once per root, after its renderer exists and before `onCreated` and the first frame.
1972
+ * `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
1973
+ * to the primary canvas. Return fields to merge into the root's state, or nothing.
1974
+ */
1975
+ setup?(store: RootStore): Partial<RootState> | void;
1976
+ /** Called when a root this extension set up unmounts. */
1977
+ dispose?(store: RootStore): void;
1978
+ /** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
1979
+ hmr?(store: RootStore): void;
1980
+ }
1981
+ /**
1982
+ * Register an extension. It is set up on every live root immediately, and on every root created
1983
+ * afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
1984
+ * it already set up keep its state and still get its dispose when they unmount.
1985
+ */
1986
+ declare function registerRootExtension(extension: RootExtension): () => void;
1987
+ /**
1988
+ * Point a root's default render job at a different render function, or back at
1989
+ * `renderer.render(scene, camera)` with `null`.
1990
+ *
1991
+ * The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
1992
+ * boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
1993
+ */
1994
+ declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
1995
+
1996
+ /**
1997
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1998
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1999
+ */
2000
+ declare function useStore(): RootStore;
1849
2001
 
1850
2002
  /**
1851
2003
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -1865,50 +2017,6 @@ declare namespace useLoader {
1865
2017
  var loader: typeof getLoader;
1866
2018
  }
1867
2019
 
1868
- /**
1869
- * Frame hook with phase-based ordering, priority, and FPS throttling.
1870
- *
1871
- * Always delivers full RootState — works both inside and outside Canvas context:
1872
- * - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
1873
- * - Outside Canvas: The job registers immediately but the callback is held until a
1874
- * Canvas adopts it, then runs with full RootState. For hostless / standalone
1875
- * frame loops with no Canvas, use `@pmndrs/scheduler` directly.
1876
- *
1877
- * Returns a controls object for manual stepping, pausing, and resuming.
1878
- *
1879
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1880
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1881
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
1882
- *
1883
- * @example
1884
- * // Simple priority (backwards compat)
1885
- * useFrame((state, delta) => { ... }, 5)
1886
- *
1887
- * @example
1888
- * // With phase-based ordering
1889
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
1890
- *
1891
- * @example
1892
- * // Outside Canvas - callback waits for a Canvas, then always has full state
1893
- * function UI() {
1894
- * useFrame((state, delta) => { syncUI(state.camera) });
1895
- * return <button>...</button>;
1896
- * }
1897
- *
1898
- * @example
1899
- * // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
1900
- * import { getScheduler } from '@pmndrs/scheduler'
1901
- * getScheduler().register((state, delta) => { updateGame(delta) })
1902
- *
1903
- * @example
1904
- * // Scheduler-only access (no callback)
1905
- * const { scheduler } = useFrame()
1906
- * scheduler.pauseJob('some-job-id')
1907
- *
1908
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1909
- */
1910
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
1911
-
1912
2020
  declare const IsObject: (url: unknown) => url is Record<string, string>;
1913
2021
  type TextureArray<T> = T extends string[] ? Texture$1[] : never;
1914
2022
  type TextureRecord<T> = T extends Record<string, string> ? {
@@ -2089,16 +2197,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): WebGLRenderTarg
2089
2197
  declare function useRenderTarget(size: number, options?: RenderTargetOptions): WebGLRenderTarget;
2090
2198
  declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): WebGLRenderTarget;
2091
2199
 
2092
- /**
2093
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2094
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2095
- */
2096
- declare function useStore(): RootStore;
2097
- /**
2098
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2099
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2100
- */
2101
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2102
2200
  /**
2103
2201
  * Exposes an object's {@link Instance}.
2104
2202
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2174,7 +2272,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2174
2272
  * Invalidates the view, requesting a frame to be rendered.
2175
2273
  * In demand mode, this triggers the scheduler to run frames.
2176
2274
  *
2177
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2275
+ * With a state argument, only that root's jobs run on the requested frames; other
2276
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2277
+ *
2278
+ * @param state - Optional root state; targets the invalidation at that root
2178
2279
  * @param frames - Number of frames to request (default: 1)
2179
2280
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2180
2281
  *
@@ -2185,14 +2286,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2185
2286
  * Advances the frameloop and runs render effects.
2186
2287
  * Useful for when manually rendering via `frameloop="never"`.
2187
2288
  *
2289
+ * With a state argument, only that root is stepped. Without one, every
2290
+ * registered root is stepped for backwards compatibility.
2291
+ *
2188
2292
  * @param timestamp - The timestamp to use for this frame
2189
2293
  * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2190
- * @param state - Ignored (kept for backwards compat)
2191
- * @param frame - Ignored (kept for backwards compat)
2294
+ * @param state - Optional root state; targets the manual step at that root
2192
2295
  *
2193
2296
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2194
2297
  */
2195
- declare function advance(timestamp: number): void;
2298
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2196
2299
 
2197
2300
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2198
2301
  declare function ReactReconciler<
@@ -3237,6 +3340,7 @@ declare namespace ReactReconciler {
3237
3340
 
3238
3341
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3239
3342
  declare function extend<T extends Catalogue>(objects: T): void;
3343
+ declare function extend(objects: Record<string, unknown>): void;
3240
3344
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3241
3345
 
3242
3346
  declare const isRenderer: (def: any) => boolean;
@@ -3261,6 +3365,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
3261
3365
  declare function flushSync<R>(fn: () => R): R;
3262
3366
 
3263
3367
  declare const context: React$1.Context<RootStore>;
3368
+
3264
3369
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3265
3370
 
3266
3371
  /**
@@ -3514,7 +3619,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
3514
3619
  declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3515
3620
  /**
3516
3621
  * Triggers an update for an instance.
3517
- * Calls onUpdate callback and invalidates the frame if necessary.
3622
+ * Invalidates the frame if the root is in demand mode.
3518
3623
  *
3519
3624
  * @param instance - Instance to invalidate
3520
3625
  */
@@ -3680,29 +3785,44 @@ declare const hasConstructor: (object: unknown) => object is {
3680
3785
  * Used to identify values that should be resolved from refs after mount.
3681
3786
  */
3682
3787
  declare const FROM_REF: unique symbol;
3788
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3789
+ interface FromRefMarker<T = unknown, R = T> {
3790
+ [FROM_REF]: React$1.RefObject<T | null>;
3791
+ /** Optional transform applied to the resolved ref before assignment. */
3792
+ transform?: (value: T) => R;
3793
+ }
3683
3794
  /**
3684
3795
  * Defers prop application until the referenced object is available.
3685
3796
  * Useful for props like `target` that need sibling refs to be populated.
3686
3797
  *
3798
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3799
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3800
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3801
+ * what gets assigned.
3802
+ *
3687
3803
  * @param ref - React ref object to resolve at mount time
3688
- * @returns A marker value that applyProps will resolve after mount
3804
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3805
+ * @returns A marker value that the reconciler resolves after mount
3689
3806
  *
3690
3807
  * @example
3691
3808
  * const targetRef = useRef<THREE.Object3D>(null)
3692
3809
  *
3693
3810
  * <group ref={targetRef} position={[-3, -2, -15]} />
3694
3811
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3812
+ *
3813
+ * @example
3814
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3815
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3695
3816
  */
3696
3817
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3818
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3697
3819
  /**
3698
3820
  * Type guard to check if a value is a fromRef marker.
3699
3821
  *
3700
3822
  * @param value - Value to check
3701
3823
  * @returns True if value is a fromRef marker
3702
3824
  */
3703
- declare function isFromRef(value: unknown): value is {
3704
- [FROM_REF]: React$1.RefObject<any>;
3705
- };
3825
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3706
3826
 
3707
3827
  /**
3708
3828
  * Symbol marker for mount-only method calls.
@@ -3729,7 +3849,15 @@ declare const ONCE: unique symbol;
3729
3849
  * // No arguments
3730
3850
  * <geometry center={once()} />
3731
3851
  */
3732
- declare function once<T>(...args: T[]): T;
3852
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3853
+ /**
3854
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3855
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3856
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3857
+ *
3858
+ * The runtime value is always the marker object; only the declared type follows the prop.
3859
+ */
3860
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3733
3861
  /**
3734
3862
  * Type guard to check if a value is a once marker.
3735
3863
  *
@@ -3741,10 +3869,31 @@ declare function isOnce(value: unknown): value is {
3741
3869
  };
3742
3870
 
3743
3871
  /**
3744
- * A DOM canvas which accepts threejs elements as children.
3745
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3872
+ * @fileoverview Legacy entry point - WebGL only
3873
+ *
3874
+ * This entry point is for apps that want to use the legacy WebGLRenderer.
3875
+ * No WebGPU features are available from this import path.
3876
+ * Auto-extends THREE with WebGL-only constructors (no node materials).
3877
+ *
3878
+ * Usage:
3879
+ * import { Canvas, useFrame } from '@react-three/fiber/legacy'
3746
3880
  */
3747
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3748
3881
 
3749
- 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 };
3750
- export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, 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, 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, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
3882
+ /** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
3883
+ type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
3884
+ /** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
3885
+ type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
3886
+ declare const useThree: UseThreeLegacy;
3887
+ declare const useFrame: UseFrameLegacy;
3888
+
3889
+ /** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
3890
+ type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
3891
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
3892
+ onCreated?: (state: LegacyRootState) => void;
3893
+ };
3894
+
3895
+ /** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
3896
+ declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
3897
+
3898
+ 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, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
3899
+ 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, RootExtension, 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 };