@react-three/fiber 10.0.0-canary.da7a768 → 10.0.0-canary.dc0ec15

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.ts 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';
@@ -12,20 +12,6 @@ import { Options } from 'react-use-measure';
12
12
  import * as react_jsx_runtime from 'react/jsx-runtime';
13
13
  import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
14
14
 
15
- function _mergeNamespaces(n, m) {
16
- m.forEach(function (e) {
17
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
18
- if (k !== 'default' && !(k in n)) {
19
- var d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: function () { return e[k]; }
23
- });
24
- }
25
- });
26
- });
27
- return Object.freeze(n);
28
- }
29
15
 
30
16
  /**
31
17
  * @fileoverview Internal Three.js re-exports - LEGACY ENTRY
@@ -41,26 +27,14 @@ declare const R3F_BUILD_WEBGPU = false;
41
27
  type Inspector = never;
42
28
  /** Not available on the legacy (WebGL-only) entry. */
43
29
  declare function loadInspector(): Promise<never>;
44
- declare const WebGPURenderer: {
45
- new (): {};
46
- };
30
+ declare class WebGPURenderer {
31
+ constructor();
32
+ }
47
33
 
48
34
  declare const RenderTarget: any;
49
35
 
50
36
  declare const CubeRenderTarget: any;
51
37
 
52
- var THREE = /*#__PURE__*/_mergeNamespaces({
53
- __proto__: null,
54
- CubeRenderTarget: CubeRenderTarget,
55
- CubeRenderTargetCompat: WebGLCubeRenderTarget,
56
- Inspector: Inspector,
57
- R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
58
- R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
59
- RenderTarget: RenderTarget,
60
- RenderTargetCompat: WebGLRenderTarget,
61
- WebGPURenderer: WebGPURenderer,
62
- loadInspector: loadInspector
63
- }, [THREE$1]);
64
38
 
65
39
  //* Utility Types ==============================
66
40
 
@@ -348,6 +322,7 @@ type BufferLike =
348
322
  | Uint16Array
349
323
  | Int16Array
350
324
  | THREE$1.BufferAttribute // Base class for all buffer attributes
325
+ | THREE$1.InterleavedBufferAttribute
351
326
  | Node // TSL buffer nodes (instancedArray, storage)
352
327
 
353
328
  /** Flat record of buffer-like values (no nested scopes) */
@@ -359,6 +334,25 @@ type BufferRecord = Record<string, BufferLike>
359
334
  */
360
335
  type BufferStore = Record<string, BufferLike | BufferRecord>
361
336
 
337
+ //* Node Types (useNodes) ========================================
338
+
339
+ /**
340
+ * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
341
+ * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
342
+ * code passes through. Creators are constrained to this same type, so the shape a creator returns
343
+ * and the shape the store holds are one type by construction.
344
+ */
345
+ type NodeLike = TSLNodeType | LegacyTSLNodeLike
346
+
347
+ /** Flat record of TSL nodes (no nested scopes) */
348
+ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
349
+
350
+ /**
351
+ * Node store that can contain both root-level nodes and scoped node objects.
352
+ * Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
353
+ */
354
+ type NodeStore = Record<string, NodeLike | NodeRecord>
355
+
362
356
  //* Storage Types (useGPUStorage) ========================================
363
357
 
364
358
  /**
@@ -373,7 +367,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
373
367
  * ```
374
368
  */
375
369
  type StorageLike =
376
- | StorageTexture // GPU storage texture
370
+ | StorageTexture // 2D GPU storage texture
371
+ | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
372
+ | StorageArrayTexture // 2D-array GPU storage texture
377
373
  | Data3DTexture // 3D texture (can be used as storage)
378
374
  | Node // TSL storage texture nodes (storageTexture)
379
375
 
@@ -485,6 +481,12 @@ interface InternalState {
485
481
  actualRenderer: R3FRenderer
486
482
  /** Global scheduler reference (for useFrame hook) */
487
483
  scheduler: SchedulerApi | null
484
+ /**
485
+ * Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
486
+ * `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
487
+ * render-phase takeover. Used by `useRenderPipeline`.
488
+ */
489
+ renderOverride?: (() => void) | null
488
490
  /** This root's unique ID in the global scheduler */
489
491
  rootId?: string
490
492
  /** Function to unregister this root from the global scheduler */
@@ -492,11 +494,28 @@ interface InternalState {
492
494
  /** Container for child attachment (scene for root, original container for portals) */
493
495
  container?: THREE$1.Object3D
494
496
  /**
495
- * CanvasTarget for multi-canvas WebGPU rendering.
496
- * Created for all WebGPU canvases to support renderer sharing.
497
+ * The CanvasTarget this root sizes and renders through.
498
+ *
499
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
500
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
501
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
502
+ * and the canvas-target job makes it the renderer's active one before this root renders.
503
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
497
504
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
498
505
  */
499
506
  canvasTarget?: CanvasTarget
507
+ /**
508
+ * Set when this root's canvas target has been resized and the backend's cached render pass
509
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
510
+ *
511
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
512
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
513
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
514
+ * invalidate some other canvas's descriptor instead.
515
+ *
516
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
517
+ */
518
+ canvasTargetSizeDirty?: boolean
500
519
  /**
501
520
  * Whether multi-canvas rendering is active.
502
521
  * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
@@ -606,7 +625,7 @@ interface RootState {
606
625
  /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
607
626
  uniforms: UniformStore
608
627
  /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
609
- nodes: Record<string, any>
628
+ nodes: NodeStore
610
629
  /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
611
630
  buffers: BufferStore
612
631
  /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
@@ -618,7 +637,7 @@ interface RootState {
618
637
  /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
619
638
  renderPipeline: ThreeRenderPipeline | null
620
639
  /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
621
- passes: Record<string, any>
640
+ passes: PassRecord
622
641
  /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
623
642
  _hmrVersion: number
624
643
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
@@ -706,12 +725,19 @@ type DefaultRendererProps = {
706
725
  */
707
726
  interface CanvasSchedulerConfig {
708
727
  /**
709
- * Render this canvas after another canvas completes.
710
- * Pass the `id` of another canvas.
728
+ * Run this Canvas root before the referenced Canvas root id(s).
729
+ */
730
+ before?: string | string[]
731
+ /**
732
+ * Run this Canvas root after the referenced Canvas root id(s).
711
733
  */
712
- after?: string
734
+ after?: string | string[]
713
735
  /**
714
- * Limit this canvas's render rate (frames per second).
736
+ * Numeric root order. Lower values run first.
737
+ */
738
+ order?: number
739
+ /**
740
+ * Limit this Canvas's default render job (frames per second).
715
741
  */
716
742
  fps?: number
717
743
  }
@@ -798,14 +824,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
798
824
  performance?: Partial<Omit<Performance, 'regress'>>
799
825
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
800
826
  dpr?: Dpr
801
- /** Props that go into the default raycaster */
802
- raycaster?: Partial<THREE$1.Raycaster>
827
+ /**
828
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
829
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
830
+ */
831
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
803
832
  /** A `THREE.Scene` instance or props that go into the default scene */
804
833
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
805
834
  /** A `THREE.Camera` instance or props that go into the default camera */
806
835
  camera?: CameraProps
807
836
  /** An R3F event manager to manage elements' pointer events */
808
- events?: (store: RootStore) => EventManager<HTMLElement>
837
+ events?: (store: RootStore) => EventManager<Element>
809
838
  /** Callback after the canvas has rendered (but not yet committed) */
810
839
  onCreated?: (state: RootState) => void
811
840
  /** Response for pointer clicks that have missed any target */
@@ -894,7 +923,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
894
923
  object?: T
895
924
  dispose?: null
896
925
  attach?: AttachType<T>
897
- onUpdate?: (self: T) => void
898
926
  }
899
927
 
900
928
  interface Instance<O = any> {
@@ -1034,7 +1062,7 @@ interface CanvasProps
1034
1062
  */
1035
1063
  resize?: Options
1036
1064
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1037
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1065
+ eventSource?: Element | React$1.RefObject<Element | null>
1038
1066
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1039
1067
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1040
1068
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1142,81 +1170,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1142
1170
 
1143
1171
  type RenderTargetOptions = RenderTargetOptions$1
1144
1172
 
1145
- //* Global Types ==============================
1173
+ //* Global TSL Types ==============================
1146
1174
 
1147
1175
  declare global {
1148
1176
  /**
1149
- * Uniform node type.
1150
- *
1151
- * This is three's own `UniformNode`, not a re-declaration of it. It previously was a
1152
- * hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
1153
- * exported type globally — so R3F's ~58 references resolved to an approximation that was
1154
- * missing members three actually ships (`setName` among them) and had drifted to the wrong
1155
- * arity when three made `UniformNode` two-parameter.
1156
- *
1157
- * three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
1158
- * so the node type is fixed to `unknown` and the single parameter is kept for call-site
1159
- * ergonomics. The result is three's structural type, so members stay in sync with the
1160
- * installed three instead of needing to be mirrored by hand.
1177
+ * Broad callable-node fallback for dynamic store readers.
1178
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1161
1179
  */
1162
- type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
1180
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1181
+ readonly shaderNode: unknown
1182
+ readonly id: number
1183
+ }
1163
1184
 
1164
- /**
1165
- * ShaderCallable - the return type of Fn()
1166
- * A callable shader function node that can be invoked with parameters.
1167
- * The function returns a ShaderNodeObject when called.
1168
- *
1169
- * @example
1170
- * ```tsx
1171
- * // Define a shader function
1172
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1173
- * return mix(color1, color2, factor)
1174
- * })
1175
- *
1176
- * // Type when retrieving from nodes store
1177
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1178
- *
1179
- * // Or with specific return type
1180
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1181
- * ```
1182
- */
1183
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1185
+ /** Legacy structural node accepted when at least one historical marker exists. */
1186
+ type LegacyTSLNodeLike = {
1187
+ label?: ((label: string) => unknown) | string
1188
+ setName?: (name: string) => unknown
1189
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1184
1190
 
1185
- /**
1186
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1187
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1188
- *
1189
- * @example
1190
- * ```tsx
1191
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1192
- * ```
1193
- */
1194
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1191
+ /** Node type accepted by broad dynamic node-store readers. */
1192
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1195
1193
 
1196
1194
  /**
1197
- * TSLNodeType - Union of all common TSL node types
1198
- * Used by ScopedStore to properly type node access from the store.
1199
- *
1200
- * Includes:
1201
- * - Node: base Three.js node type
1202
- * - ShaderCallable: function nodes created with Fn()
1203
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1204
- *
1205
- * @example
1206
- * ```tsx
1207
- * // In useLocalNodes, nodes are typed as TSLNodeType
1208
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1209
- * positionNode: nodes.myPosition, // Works - Node is in union
1210
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1211
- * }))
1212
- *
1213
- * // Can narrow with type guard or assertion when needed
1214
- * if (typeof blendColorFn === 'function') {
1215
- * blendColorFn(someColor, 0.5)
1216
- * }
1217
- * ```
1195
+ * Derive Three's shader node type from an existing node or a supported raw input.
1196
+ * Existing InputNode generics take precedence over structural value normalization.
1197
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1198
+ * InputNode base with its concrete InputNode specialization.
1218
1199
  */
1219
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1200
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1201
+ ? TNodeType
1202
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1203
+ ? TNodeType
1204
+ : T extends number
1205
+ ? 'float'
1206
+ : T extends boolean
1207
+ ? 'bool'
1208
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1209
+ ? 'color'
1210
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1211
+ ? 'vec4'
1212
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1213
+ ? 'vec3'
1214
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1215
+ ? 'vec2'
1216
+ : T extends three_webgpu.Matrix4
1217
+ ? 'mat4'
1218
+ : T extends three_webgpu.Matrix3
1219
+ ? 'mat3'
1220
+ : T extends three_webgpu.Matrix2
1221
+ ? 'mat2'
1222
+ : unknown
1223
+
1224
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1225
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1226
+ ? TValue
1227
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1228
+ ? TValue
1229
+ : T extends string | { r: number; g: number; b: number }
1230
+ ? three_webgpu.Color
1231
+ : T extends { x: number; y: number; z: number; w: number }
1232
+ ? three_webgpu.Vector4
1233
+ : T extends { x: number; y: number; z: number }
1234
+ ? three_webgpu.Vector3
1235
+ : T extends { x: number; y: number }
1236
+ ? three_webgpu.Vector2
1237
+ : T extends number
1238
+ ? number
1239
+ : T extends boolean
1240
+ ? boolean
1241
+ : T
1242
+
1243
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1244
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1245
+
1246
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1247
+ type UniformNodesFor<T extends UniformInputRecord> = {
1248
+ [K in keyof T]: UniformNodeFor<T[K]>
1249
+ }
1250
+
1251
+ /** Backward-compatible single-parameter uniform alias. */
1252
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1220
1253
 
1221
1254
  /** Flat record of uniform nodes (no nested scopes) */
1222
1255
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1241,7 +1274,7 @@ declare global {
1241
1274
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1242
1275
  * Supports:
1243
1276
  * - Primitives: number, string (color), boolean
1244
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1277
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1245
1278
  * - Plain objects: { x, y, z, w } converted to vectors
1246
1279
  * - TSL nodes: color(), vec3(), float() for type casting
1247
1280
  * - UniformNode: existing uniforms (reused as-is)
@@ -1254,88 +1287,124 @@ declare global {
1254
1287
  | three_webgpu.Vector2
1255
1288
  | three_webgpu.Vector3
1256
1289
  | three_webgpu.Vector4
1290
+ | three_webgpu.Matrix2
1257
1291
  | three_webgpu.Matrix3
1258
1292
  | three_webgpu.Matrix4
1259
- | three_webgpu.Euler
1260
- | three_webgpu.Quaternion
1261
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1293
+ | { x: number; y: number }
1294
+ | { x: number; y: number; z: number }
1295
+ | { x: number; y: number; z: number; w: number }
1262
1296
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1263
- | Node // TSL nodes like color(), vec3(), float() for type casting
1297
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1264
1298
  | UniformNode
1265
1299
 
1266
1300
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1267
1301
  type UniformInputRecord = Record<string, UniformValue>
1268
1302
  }
1269
1303
 
1270
- //* Module Augmentation ==============================
1271
-
1272
- declare module 'three/tsl' {
1304
+ declare global {
1273
1305
  /**
1274
- * Fn with array parameter destructuring
1275
- * @example Fn(([uv, skew]) => { ... })
1306
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1307
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1308
+ * is r185, so the new name is the only one.
1276
1309
  */
1277
- export function Fn<R extends Node = Node>(
1278
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1279
- ): ShaderCallable<R>
1310
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1280
1311
 
1281
1312
  /**
1282
- * Fn with object parameter destructuring
1283
- * @example Fn(({ color, intensity }) => { ... })
1313
+ * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1314
+ * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1315
+ * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1284
1316
  */
1285
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1286
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1287
- ): ShaderCallable<R>
1317
+ type ScenePassNode = three_webgpu.PassNode
1288
1318
 
1289
1319
  /**
1290
- * Fn with array params + layout
1291
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1320
+ * Pass record - stores TSL pass nodes for render pipeline.
1321
+ *
1322
+ * `scenePass` is the only key the library owns. It is optional here because this is also the
1323
+ * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1324
+ * or `clearPasses()`. Inside the callbacks it is always present; see
1325
+ * {@link RenderPipelineCallbackState}.
1326
+ *
1327
+ * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1328
+ * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1329
+ * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1330
+ * site when you need a member, e.g. `passes.velocity as TextureNode`.
1331
+ *
1332
+ * The index signature admits `undefined` because a key may simply not be registered, and
1333
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1334
+ * optional property whose type excludes `undefined` from the index signature is an error
1335
+ * (TS2411) for every consumer compiling these declarations.
1292
1336
  */
1293
- export function Fn<R extends Node = Node>(
1294
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1295
- layout: { layout?: unknown },
1296
- ): ShaderCallable<R>
1337
+ interface PassRecord {
1338
+ scenePass?: ScenePassNode
1339
+ [key: string]: three_webgpu.Node | undefined
1340
+ }
1297
1341
 
1298
1342
  /**
1299
- * Fn with object params + layout
1343
+ * State passed to pipeline callbacks after the active pipeline has been created.
1344
+ *
1345
+ * `passes.scenePass` is required here: the hook installs the default scene pass before either
1346
+ * callback runs, so callbacks can use it without a guard or a cast.
1347
+ *
1348
+ * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1349
+ * the legacy renderer before either callback can run, so a callback never sees WebGL.
1300
1350
  */
1301
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1302
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1303
- layout: { layout?: unknown },
1304
- ): ShaderCallable<R>
1305
- }
1351
+ type RenderPipelineCallbackState = RootState & {
1352
+ renderPipeline: ThreeRenderPipeline
1353
+ passes: PassRecord & { scenePass: ScenePassNode }
1354
+ renderer: three_webgpu.WebGPURenderer
1355
+ isLegacy: false
1356
+ }
1306
1357
 
1307
- declare global {
1308
1358
  /**
1309
- * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1310
- * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1311
- * is r185, so the new name is the only one.
1359
+ * What a callback may return to register entries into `state.passes`.
1360
+ *
1361
+ * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1362
+ * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1363
+ * store entry would leave the store pointing at a node the hook never disposes, and the hook
1364
+ * disposing a pass nothing references. So returning it is a type error.
1312
1365
  */
1313
- type ThreeRenderPipeline = three_webgpu.RenderPipeline
1314
-
1315
- /** Pass record - stores TSL pass nodes for render pipeline */
1316
- type PassRecord = Record<string, any>
1366
+ type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1317
1367
 
1318
1368
  /** Setup callback - runs first to configure MRT, create additional passes */
1319
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1369
+ type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1320
1370
 
1321
1371
  /** Main callback - runs second to configure outputNode, create effect passes */
1322
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1372
+ type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1323
1373
 
1324
- /** Return type for useRenderPipeline hook */
1325
- interface UseRenderPipelineReturn {
1374
+ /** The imperative half of useRenderPipeline's return value, present in every state */
1375
+ interface UseRenderPipelineActions {
1326
1376
  /** Current passes from state */
1327
1377
  passes: PassRecord
1328
- /** RenderPipeline instance (null if not initialized) */
1329
- renderPipeline: ThreeRenderPipeline | null
1330
1378
  /** Clear all passes from state */
1331
1379
  clearPasses: () => void
1332
1380
  /** Reset RenderPipeline entirely (clears PP + passes) */
1333
1381
  reset: () => void
1334
1382
  /** Re-run setup/main callbacks with current closure values */
1335
1383
  rebuild: () => void
1336
- /** True when RenderPipeline is configured and ready */
1337
- isReady: boolean
1338
1384
  }
1385
+
1386
+ /**
1387
+ * Return type for useRenderPipeline hook, discriminated on `isReady`.
1388
+ *
1389
+ * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1390
+ * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1391
+ * `clearPasses()` empties the record while leaving the pipeline in place.
1392
+ */
1393
+ type UseRenderPipelineReturn = UseRenderPipelineActions &
1394
+ (
1395
+ | {
1396
+ /** True when RenderPipeline is configured and ready */
1397
+ isReady: true
1398
+ /** RenderPipeline instance */
1399
+ renderPipeline: ThreeRenderPipeline
1400
+ }
1401
+ | {
1402
+ /** False until the pipeline has been created */
1403
+ isReady: false
1404
+ /** Not initialized yet, or torn down by reset() */
1405
+ renderPipeline: null
1406
+ }
1407
+ )
1339
1408
  }
1340
1409
 
1341
1410
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
@@ -1414,10 +1483,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1414
1483
 
1415
1484
  /**
1416
1485
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1417
- * since @types/three has broken inheritance for TSL node subclasses.
1486
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1487
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1418
1488
  */
1419
1489
  type NodeProps<P> = {
1420
- [K in keyof P as P[K] extends Node$1 | null ? K : never]?: TSLNodeInput
1490
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1421
1491
  }
1422
1492
 
1423
1493
  interface ReactProps<P> {
@@ -1438,11 +1508,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1438
1508
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1439
1509
  }
1440
1510
 
1511
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1512
+ type Object3DMethod = NonNullable<
1513
+ {
1514
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1515
+ }[keyof Object3D]
1516
+ >
1517
+
1441
1518
  type ThreeExports = typeof import('three')
1442
1519
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1443
1520
 
1444
1521
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1445
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1522
+ /**
1523
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1524
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1525
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1526
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1527
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1528
+ */
1529
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
1530
+ object: object
1531
+ ref?: React.Ref<any>
1532
+ [prop: string]: unknown
1533
+ }
1446
1534
  // Conflicts with DOM types can be accessed through a three* prefix
1447
1535
  threeAudio: ThreeElementsImpl['audio']
1448
1536
  threeSource: ThreeElementsImpl['source']
@@ -1483,6 +1571,7 @@ type three_d_Matrix3 = Matrix3;
1483
1571
  type three_d_Matrix4 = Matrix4;
1484
1572
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1485
1573
  type three_d_NodeProps<P> = NodeProps<P>;
1574
+ type three_d_Object3DMethod = Object3DMethod;
1486
1575
  type three_d_Quaternion = Quaternion;
1487
1576
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1488
1577
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1497,7 +1586,7 @@ type three_d_Vector3 = Vector3;
1497
1586
  type three_d_Vector4 = Vector4;
1498
1587
  type three_d_VectorRepresentation = VectorRepresentation;
1499
1588
  declare namespace three_d {
1500
- export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1589
+ export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1501
1590
  }
1502
1591
 
1503
1592
  /**
@@ -1846,7 +1935,43 @@ declare function createEvents(store: RootStore): {
1846
1935
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1847
1936
  };
1848
1937
  /** Default R3F event manager for web */
1849
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1938
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
1939
+
1940
+ interface RootExtension {
1941
+ /** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
1942
+ * set up are not set up a second time, but get the new entry's dispose and hmr. */
1943
+ name: string;
1944
+ /**
1945
+ * Called once per root, after its renderer exists and before `onCreated` and the first frame.
1946
+ * `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
1947
+ * to the primary canvas. Return fields to merge into the root's state, or nothing.
1948
+ */
1949
+ setup?(store: RootStore): Partial<RootState> | void;
1950
+ /** Called when a root this extension set up unmounts. */
1951
+ dispose?(store: RootStore): void;
1952
+ /** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
1953
+ hmr?(store: RootStore): void;
1954
+ }
1955
+ /**
1956
+ * Register an extension. It is set up on every live root immediately, and on every root created
1957
+ * afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
1958
+ * it already set up keep its state and still get its dispose when they unmount.
1959
+ */
1960
+ declare function registerRootExtension(extension: RootExtension): () => void;
1961
+ /**
1962
+ * Point a root's default render job at a different render function, or back at
1963
+ * `renderer.render(scene, camera)` with `null`.
1964
+ *
1965
+ * The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
1966
+ * boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
1967
+ */
1968
+ declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
1969
+
1970
+ /**
1971
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1972
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1973
+ */
1974
+ declare function useStore(): RootStore;
1850
1975
 
1851
1976
  /**
1852
1977
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -1866,50 +1991,6 @@ declare namespace useLoader {
1866
1991
  var loader: typeof getLoader;
1867
1992
  }
1868
1993
 
1869
- /**
1870
- * Frame hook with phase-based ordering, priority, and FPS throttling.
1871
- *
1872
- * Always delivers full RootState — works both inside and outside Canvas context:
1873
- * - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
1874
- * - Outside Canvas: The job registers immediately but the callback is held until a
1875
- * Canvas adopts it, then runs with full RootState. For hostless / standalone
1876
- * frame loops with no Canvas, use `@pmndrs/scheduler` directly.
1877
- *
1878
- * Returns a controls object for manual stepping, pausing, and resuming.
1879
- *
1880
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1881
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1882
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
1883
- *
1884
- * @example
1885
- * // Simple priority (backwards compat)
1886
- * useFrame((state, delta) => { ... }, 5)
1887
- *
1888
- * @example
1889
- * // With phase-based ordering
1890
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
1891
- *
1892
- * @example
1893
- * // Outside Canvas - callback waits for a Canvas, then always has full state
1894
- * function UI() {
1895
- * useFrame((state, delta) => { syncUI(state.camera) });
1896
- * return <button>...</button>;
1897
- * }
1898
- *
1899
- * @example
1900
- * // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
1901
- * import { getScheduler } from '@pmndrs/scheduler'
1902
- * getScheduler().register((state, delta) => { updateGame(delta) })
1903
- *
1904
- * @example
1905
- * // Scheduler-only access (no callback)
1906
- * const { scheduler } = useFrame()
1907
- * scheduler.pauseJob('some-job-id')
1908
- *
1909
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1910
- */
1911
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
1912
-
1913
1994
  declare const IsObject: (url: unknown) => url is Record<string, string>;
1914
1995
  type TextureArray<T> = T extends string[] ? Texture$1[] : never;
1915
1996
  type TextureRecord<T> = T extends Record<string, string> ? {
@@ -2090,16 +2171,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): WebGLRenderTarg
2090
2171
  declare function useRenderTarget(size: number, options?: RenderTargetOptions): WebGLRenderTarget;
2091
2172
  declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): WebGLRenderTarget;
2092
2173
 
2093
- /**
2094
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2095
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2096
- */
2097
- declare function useStore(): RootStore;
2098
- /**
2099
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2100
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2101
- */
2102
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2103
2174
  /**
2104
2175
  * Exposes an object's {@link Instance}.
2105
2176
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2175,7 +2246,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2175
2246
  * Invalidates the view, requesting a frame to be rendered.
2176
2247
  * In demand mode, this triggers the scheduler to run frames.
2177
2248
  *
2178
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2249
+ * With a state argument, only that root's jobs run on the requested frames; other
2250
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2251
+ *
2252
+ * @param state - Optional root state; targets the invalidation at that root
2179
2253
  * @param frames - Number of frames to request (default: 1)
2180
2254
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2181
2255
  *
@@ -2186,14 +2260,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2186
2260
  * Advances the frameloop and runs render effects.
2187
2261
  * Useful for when manually rendering via `frameloop="never"`.
2188
2262
  *
2263
+ * With a state argument, only that root is stepped. Without one, every
2264
+ * registered root is stepped for backwards compatibility.
2265
+ *
2189
2266
  * @param timestamp - The timestamp to use for this frame
2190
2267
  * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2191
- * @param state - Ignored (kept for backwards compat)
2192
- * @param frame - Ignored (kept for backwards compat)
2268
+ * @param state - Optional root state; targets the manual step at that root
2193
2269
  *
2194
2270
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2195
2271
  */
2196
- declare function advance(timestamp: number): void;
2272
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2197
2273
 
2198
2274
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2199
2275
  declare function ReactReconciler<
@@ -3238,6 +3314,7 @@ declare namespace ReactReconciler {
3238
3314
 
3239
3315
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3240
3316
  declare function extend<T extends Catalogue>(objects: T): void;
3317
+ declare function extend(objects: Record<string, unknown>): void;
3241
3318
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3242
3319
 
3243
3320
  declare const isRenderer: (def: any) => boolean;
@@ -3262,6 +3339,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
3262
3339
  declare function flushSync<R>(fn: () => R): R;
3263
3340
 
3264
3341
  declare const context: React$1.Context<RootStore>;
3342
+
3265
3343
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3266
3344
 
3267
3345
  /**
@@ -3515,7 +3593,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
3515
3593
  declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3516
3594
  /**
3517
3595
  * Triggers an update for an instance.
3518
- * Calls onUpdate callback and invalidates the frame if necessary.
3596
+ * Invalidates the frame if the root is in demand mode.
3519
3597
  *
3520
3598
  * @param instance - Instance to invalidate
3521
3599
  */
@@ -3681,29 +3759,44 @@ declare const hasConstructor: (object: unknown) => object is {
3681
3759
  * Used to identify values that should be resolved from refs after mount.
3682
3760
  */
3683
3761
  declare const FROM_REF: unique symbol;
3762
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3763
+ interface FromRefMarker<T = unknown, R = T> {
3764
+ [FROM_REF]: React$1.RefObject<T | null>;
3765
+ /** Optional transform applied to the resolved ref before assignment. */
3766
+ transform?: (value: T) => R;
3767
+ }
3684
3768
  /**
3685
3769
  * Defers prop application until the referenced object is available.
3686
3770
  * Useful for props like `target` that need sibling refs to be populated.
3687
3771
  *
3772
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3773
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3774
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3775
+ * what gets assigned.
3776
+ *
3688
3777
  * @param ref - React ref object to resolve at mount time
3689
- * @returns A marker value that applyProps will resolve after mount
3778
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3779
+ * @returns A marker value that the reconciler resolves after mount
3690
3780
  *
3691
3781
  * @example
3692
3782
  * const targetRef = useRef<THREE.Object3D>(null)
3693
3783
  *
3694
3784
  * <group ref={targetRef} position={[-3, -2, -15]} />
3695
3785
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3786
+ *
3787
+ * @example
3788
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3789
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3696
3790
  */
3697
3791
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3792
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3698
3793
  /**
3699
3794
  * Type guard to check if a value is a fromRef marker.
3700
3795
  *
3701
3796
  * @param value - Value to check
3702
3797
  * @returns True if value is a fromRef marker
3703
3798
  */
3704
- declare function isFromRef(value: unknown): value is {
3705
- [FROM_REF]: React$1.RefObject<any>;
3706
- };
3799
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3707
3800
 
3708
3801
  /**
3709
3802
  * Symbol marker for mount-only method calls.
@@ -3730,7 +3823,15 @@ declare const ONCE: unique symbol;
3730
3823
  * // No arguments
3731
3824
  * <geometry center={once()} />
3732
3825
  */
3733
- declare function once<T>(...args: T[]): T;
3826
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3827
+ /**
3828
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3829
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3830
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3831
+ *
3832
+ * The runtime value is always the marker object; only the declared type follows the prop.
3833
+ */
3834
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3734
3835
  /**
3735
3836
  * Type guard to check if a value is a once marker.
3736
3837
  *
@@ -3742,10 +3843,31 @@ declare function isOnce(value: unknown): value is {
3742
3843
  };
3743
3844
 
3744
3845
  /**
3745
- * A DOM canvas which accepts threejs elements as children.
3746
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3846
+ * @fileoverview Legacy entry point - WebGL only
3847
+ *
3848
+ * This entry point is for apps that want to use the legacy WebGLRenderer.
3849
+ * No WebGPU features are available from this import path.
3850
+ * Auto-extends THREE with WebGL-only constructors (no node materials).
3851
+ *
3852
+ * Usage:
3853
+ * import { Canvas, useFrame } from '@react-three/fiber/legacy'
3747
3854
  */
3748
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3749
3855
 
3750
- 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 };
3751
- 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 };
3856
+ /** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
3857
+ type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
3858
+ /** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
3859
+ type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
3860
+ declare const useThree: UseThreeLegacy;
3861
+ declare const useFrame: UseFrameLegacy;
3862
+
3863
+ /** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
3864
+ type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
3865
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
3866
+ onCreated?: (state: LegacyRootState) => void;
3867
+ };
3868
+
3869
+ /** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
3870
+ declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
3871
+
3872
+ 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 };
3873
+ 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 };