@react-three/fiber 10.0.0-canary.6eb9584 → 10.0.0-canary.777b94d

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/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
2
- import * as three_webgpu from 'three/webgpu';
3
- import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
2
+ import * as webgpu from 'three/webgpu';
3
+ import { CubeRenderTarget, RenderTarget, WebGPURenderer, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three/webgpu';
4
4
  import * as THREE$1 from 'three';
5
5
  import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
6
  import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
@@ -64,7 +64,7 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
64
64
  WebGLRenderer: WebGLRenderer,
65
65
  WebGLRendererParameters: WebGLRendererParameters,
66
66
  loadInspector: loadInspector
67
- }, [three_webgpu]);
67
+ }, [webgpu]);
68
68
 
69
69
  //* Utility Types ==============================
70
70
 
@@ -328,68 +328,6 @@ type FrameNextCallback = FrameCallback$1<RootState>
328
328
  /** Alias for FrameNextCallback */
329
329
  type FrameCallback = FrameNextCallback
330
330
 
331
- //* Buffer Types (useBuffers) ========================================
332
-
333
- /**
334
- * Buffer-like types for GPU compute and storage operations.
335
- * Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
336
- *
337
- * @example
338
- * ```tsx
339
- * const { positions, velocities } = useBuffers(() => ({
340
- * positions: instancedArray(count, 'vec3'), // StorageBufferNode
341
- * velocities: new Float32Array(count * 3), // TypedArray
342
- * }), 'particles')
343
- * ```
344
- */
345
- type BufferLike =
346
- | Float32Array
347
- | Uint32Array
348
- | Int32Array
349
- | Float64Array
350
- | Uint8Array
351
- | Int8Array
352
- | Uint16Array
353
- | Int16Array
354
- | THREE$1.BufferAttribute // Base class for all buffer attributes
355
- | Node // TSL buffer nodes (instancedArray, storage)
356
-
357
- /** Flat record of buffer-like values (no nested scopes) */
358
- type BufferRecord = Record<string, BufferLike>
359
-
360
- /**
361
- * Buffer store that can contain both root-level buffers and scoped buffer objects.
362
- * Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
363
- */
364
- type BufferStore = Record<string, BufferLike | BufferRecord>
365
-
366
- //* Storage Types (useGPUStorage) ========================================
367
-
368
- /**
369
- * GPU storage types for texture-based storage operations.
370
- * Includes Three.js storage textures and TSL storage texture nodes.
371
- *
372
- * @example
373
- * ```tsx
374
- * const { heightMap } = useGPUStorage(() => ({
375
- * heightMap: new StorageTexture(512, 512),
376
- * }), 'terrain')
377
- * ```
378
- */
379
- type StorageLike =
380
- | StorageTexture // GPU storage texture
381
- | Data3DTexture // 3D texture (can be used as storage)
382
- | Node // TSL storage texture nodes (storageTexture)
383
-
384
- /** Flat record of storage-like values (no nested scopes) */
385
- type StorageRecord = Record<string, StorageLike>
386
-
387
- /**
388
- * Storage store that can contain both root-level storage and scoped storage objects.
389
- * Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
390
- */
391
- type StorageStore = Record<string, StorageLike | StorageRecord>
392
-
393
331
  //* Renderer Types ========================================
394
332
 
395
333
  /** Default renderer type - union of WebGL and WebGPU renderers */
@@ -489,6 +427,12 @@ interface InternalState {
489
427
  actualRenderer: R3FRenderer
490
428
  /** Global scheduler reference (for useFrame hook) */
491
429
  scheduler: SchedulerApi | null
430
+ /**
431
+ * Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
432
+ * `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
433
+ * render-phase takeover. Used by `useRenderPipeline`.
434
+ */
435
+ renderOverride?: (() => void) | null
492
436
  /** This root's unique ID in the global scheduler */
493
437
  rootId?: string
494
438
  /** Function to unregister this root from the global scheduler */
@@ -496,11 +440,28 @@ interface InternalState {
496
440
  /** Container for child attachment (scene for root, original container for portals) */
497
441
  container?: THREE$1.Object3D
498
442
  /**
499
- * CanvasTarget for multi-canvas WebGPU rendering.
500
- * Created for all WebGPU canvases to support renderer sharing.
443
+ * The CanvasTarget this root sizes and renders through.
444
+ *
445
+ * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
446
+ * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
447
+ * R3F created for its own element. Either way there is exactly one target per canvas element,
448
+ * and the canvas-target job makes it the renderer's active one before this root renders.
449
+ * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
501
450
  * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
502
451
  */
503
452
  canvasTarget?: CanvasTarget
453
+ /**
454
+ * Set when this root's canvas target has been resized and the backend's cached render pass
455
+ * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
456
+ *
457
+ * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
458
+ * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
459
+ * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
460
+ * invalidate some other canvas's descriptor instead.
461
+ *
462
+ * @see https://github.com/pmndrs/react-three-fiber/issues/3847
463
+ */
464
+ canvasTargetSizeDirty?: boolean
504
465
  /**
505
466
  * Whether multi-canvas rendering is active.
506
467
  * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
@@ -539,12 +500,13 @@ interface RootState {
539
500
  /** Get current state */
540
501
  get: StoreApi<RootState>['getState']
541
502
  /**
542
- * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
503
+ * The store of the canvas that owns this root's renderer.
543
504
  * - For primary/independent canvases: points to its own store (self-reference)
544
505
  * - For secondary canvases: points to the primary canvas's store
506
+ * - Portals copy it from their parent
545
507
  *
546
- * Hooks like useNodes/useUniforms should read from primaryStore to ensure
547
- * consistent shared state across all canvases sharing a renderer.
508
+ * Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
509
+ * resolves through it.
548
510
  */
549
511
  primaryStore: RootStore
550
512
  /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
@@ -607,24 +569,10 @@ interface RootState {
607
569
  setError: (error: Error | null) => void
608
570
  /** Current error state (null when no error) */
609
571
  error: Error | null
610
- /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
611
- uniforms: UniformStore
612
- /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
613
- nodes: Record<string, any>
614
- /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
615
- buffers: BufferStore
616
- /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
617
- gpuStorage: StorageStore
618
572
  /** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
619
573
  textures: Map<string, THREE$1.Texture>
620
574
  /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
621
575
  _textureRefs: Map<string, number>
622
- /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
623
- renderPipeline: ThreeRenderPipeline | null
624
- /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
625
- passes: Record<string, any>
626
- /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
627
- _hmrVersion: number
628
576
  /** Internal: whether setSize() has taken ownership of canvas dimensions */
629
577
  _sizeImperative: boolean
630
578
  /** Internal: stored size props from Canvas for reset functionality */
@@ -710,12 +658,19 @@ type DefaultRendererProps = {
710
658
  */
711
659
  interface CanvasSchedulerConfig {
712
660
  /**
713
- * Render this canvas after another canvas completes.
714
- * Pass the `id` of another canvas.
661
+ * Run this Canvas root before the referenced Canvas root id(s).
662
+ */
663
+ before?: string | string[]
664
+ /**
665
+ * Run this Canvas root after the referenced Canvas root id(s).
715
666
  */
716
- after?: string
667
+ after?: string | string[]
717
668
  /**
718
- * Limit this canvas's render rate (frames per second).
669
+ * Numeric root order. Lower values run first.
670
+ */
671
+ order?: number
672
+ /**
673
+ * Limit this Canvas's default render job (frames per second).
719
674
  */
720
675
  fps?: number
721
676
  }
@@ -802,14 +757,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
802
757
  performance?: Partial<Omit<Performance, 'regress'>>
803
758
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
804
759
  dpr?: Dpr
805
- /** Props that go into the default raycaster */
806
- raycaster?: Partial<THREE$1.Raycaster>
760
+ /**
761
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
762
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
763
+ */
764
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
807
765
  /** A `THREE.Scene` instance or props that go into the default scene */
808
766
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
809
767
  /** A `THREE.Camera` instance or props that go into the default camera */
810
768
  camera?: CameraProps
811
769
  /** An R3F event manager to manage elements' pointer events */
812
- events?: (store: RootStore) => EventManager<HTMLElement>
770
+ events?: (store: RootStore) => EventManager<Element>
813
771
  /** Callback after the canvas has rendered (but not yet committed) */
814
772
  onCreated?: (state: RootState) => void
815
773
  /** Response for pointer clicks that have missed any target */
@@ -898,7 +856,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
898
856
  object?: T
899
857
  dispose?: null
900
858
  attach?: AttachType<T>
901
- onUpdate?: (self: T) => void
902
859
  }
903
860
 
904
861
  interface Instance<O = any> {
@@ -1038,7 +995,7 @@ interface CanvasProps
1038
995
  */
1039
996
  resize?: Options
1040
997
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1041
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
998
+ eventSource?: Element | React$1.RefObject<Element | null>
1042
999
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1043
1000
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1044
1001
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1146,202 +1103,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1146
1103
 
1147
1104
  type RenderTargetOptions = RenderTargetOptions$1
1148
1105
 
1149
- //* Global Types ==============================
1150
-
1151
- declare global {
1152
- /**
1153
- * Uniform node type.
1154
- *
1155
- * This is three's own `UniformNode`, not a re-declaration of it. It previously was a
1156
- * hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
1157
- * exported type globally — so R3F's ~58 references resolved to an approximation that was
1158
- * missing members three actually ships (`setName` among them) and had drifted to the wrong
1159
- * arity when three made `UniformNode` two-parameter.
1160
- *
1161
- * three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
1162
- * so the node type is fixed to `unknown` and the single parameter is kept for call-site
1163
- * ergonomics. The result is three's structural type, so members stay in sync with the
1164
- * installed three instead of needing to be mirrored by hand.
1165
- */
1166
- type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
1167
-
1168
- /**
1169
- * ShaderCallable - the return type of Fn()
1170
- * A callable shader function node that can be invoked with parameters.
1171
- * The function returns a ShaderNodeObject when called.
1172
- *
1173
- * @example
1174
- * ```tsx
1175
- * // Define a shader function
1176
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1177
- * return mix(color1, color2, factor)
1178
- * })
1179
- *
1180
- * // Type when retrieving from nodes store
1181
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1182
- *
1183
- * // Or with specific return type
1184
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1185
- * ```
1186
- */
1187
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1188
-
1189
- /**
1190
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1191
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1192
- *
1193
- * @example
1194
- * ```tsx
1195
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1196
- * ```
1197
- */
1198
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1199
-
1200
- /**
1201
- * TSLNodeType - Union of all common TSL node types
1202
- * Used by ScopedStore to properly type node access from the store.
1203
- *
1204
- * Includes:
1205
- * - Node: base Three.js node type
1206
- * - ShaderCallable: function nodes created with Fn()
1207
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1208
- *
1209
- * @example
1210
- * ```tsx
1211
- * // In useLocalNodes, nodes are typed as TSLNodeType
1212
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1213
- * positionNode: nodes.myPosition, // Works - Node is in union
1214
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1215
- * }))
1216
- *
1217
- * // Can narrow with type guard or assertion when needed
1218
- * if (typeof blendColorFn === 'function') {
1219
- * blendColorFn(someColor, 0.5)
1220
- * }
1221
- * ```
1222
- */
1223
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1224
-
1225
- /** Flat record of uniform nodes (no nested scopes) */
1226
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1227
-
1228
- /**
1229
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
1230
- * Used by state.uniforms which has structure like:
1231
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1232
- */
1233
- type UniformStore = Record<string, UniformNode | UniformRecord>
1234
-
1235
- /**
1236
- * Helper to safely access a uniform node from the store.
1237
- * Use this when accessing state.uniforms to get proper typing.
1238
- * @example
1239
- * const uTime = uniforms.uTime as UniformNode<number>
1240
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1241
- */
1242
- type GetUniform<T = unknown> = UniformNode<T>
1243
-
1244
- /**
1245
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1246
- * Supports:
1247
- * - Primitives: number, string (color), boolean
1248
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1249
- * - Plain objects: { x, y, z, w } converted to vectors
1250
- * - TSL nodes: color(), vec3(), float() for type casting
1251
- * - UniformNode: existing uniforms (reused as-is)
1252
- */
1253
- type UniformValue =
1254
- | number
1255
- | string
1256
- | boolean
1257
- | three_webgpu.Color
1258
- | three_webgpu.Vector2
1259
- | three_webgpu.Vector3
1260
- | three_webgpu.Vector4
1261
- | three_webgpu.Matrix3
1262
- | three_webgpu.Matrix4
1263
- | three_webgpu.Euler
1264
- | three_webgpu.Quaternion
1265
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1266
- | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1267
- | Node // TSL nodes like color(), vec3(), float() for type casting
1268
- | UniformNode
1269
-
1270
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1271
- type UniformInputRecord = Record<string, UniformValue>
1272
- }
1273
-
1274
- //* Module Augmentation ==============================
1275
-
1276
- declare module 'three/tsl' {
1277
- /**
1278
- * Fn with array parameter destructuring
1279
- * @example Fn(([uv, skew]) => { ... })
1280
- */
1281
- export function Fn<R extends Node = Node>(
1282
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1283
- ): ShaderCallable<R>
1284
-
1285
- /**
1286
- * Fn with object parameter destructuring
1287
- * @example Fn(({ color, intensity }) => { ... })
1288
- */
1289
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1290
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1291
- ): ShaderCallable<R>
1292
-
1293
- /**
1294
- * Fn with array params + layout
1295
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1296
- */
1297
- export function Fn<R extends Node = Node>(
1298
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1299
- layout: { layout?: unknown },
1300
- ): ShaderCallable<R>
1301
-
1302
- /**
1303
- * Fn with object params + layout
1304
- */
1305
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1306
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1307
- layout: { layout?: unknown },
1308
- ): ShaderCallable<R>
1309
- }
1310
-
1311
- declare global {
1312
- /**
1313
- * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1314
- * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1315
- * is r185, so the new name is the only one.
1316
- */
1317
- type ThreeRenderPipeline = three_webgpu.RenderPipeline
1318
-
1319
- /** Pass record - stores TSL pass nodes for render pipeline */
1320
- type PassRecord = Record<string, any>
1321
-
1322
- /** Setup callback - runs first to configure MRT, create additional passes */
1323
- type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1324
-
1325
- /** Main callback - runs second to configure outputNode, create effect passes */
1326
- type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1327
-
1328
- /** Return type for useRenderPipeline hook */
1329
- interface UseRenderPipelineReturn {
1330
- /** Current passes from state */
1331
- passes: PassRecord
1332
- /** RenderPipeline instance (null if not initialized) */
1333
- renderPipeline: ThreeRenderPipeline | null
1334
- /** Clear all passes from state */
1335
- clearPasses: () => void
1336
- /** Reset RenderPipeline entirely (clears PP + passes) */
1337
- reset: () => void
1338
- /** Re-run setup/main callbacks with current closure values */
1339
- rebuild: () => void
1340
- /** True when RenderPipeline is configured and ready */
1341
- isReady: boolean
1342
- }
1343
- }
1344
-
1345
1106
  type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1346
1107
 
1347
1108
  interface MathRepresentation {
@@ -1418,10 +1179,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1418
1179
 
1419
1180
  /**
1420
1181
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1421
- * since @types/three has broken inheritance for TSL node subclasses.
1182
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1183
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1422
1184
  */
1423
1185
  type NodeProps<P> = {
1424
- [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1186
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1425
1187
  }
1426
1188
 
1427
1189
  interface ReactProps<P> {
@@ -1442,11 +1204,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1442
1204
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1443
1205
  }
1444
1206
 
1207
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1208
+ type Object3DMethod = NonNullable<
1209
+ {
1210
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1211
+ }[keyof Object3D]
1212
+ >
1213
+
1445
1214
  type ThreeExports = typeof THREE
1446
1215
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1447
1216
 
1448
1217
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1449
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1218
+ /**
1219
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1220
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1221
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1222
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1223
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1224
+ */
1225
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
1226
+ object: object
1227
+ ref?: React.Ref<any>
1228
+ [prop: string]: unknown
1229
+ }
1450
1230
  // Conflicts with DOM types can be accessed through a three* prefix
1451
1231
  threeAudio: ThreeElementsImpl['audio']
1452
1232
  threeSource: ThreeElementsImpl['source']
@@ -1487,6 +1267,7 @@ type three_d_Matrix3 = Matrix3;
1487
1267
  type three_d_Matrix4 = Matrix4;
1488
1268
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1489
1269
  type three_d_NodeProps<P> = NodeProps<P>;
1270
+ type three_d_Object3DMethod = Object3DMethod;
1490
1271
  type three_d_Quaternion = Quaternion;
1491
1272
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1492
1273
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1501,7 +1282,7 @@ type three_d_Vector3 = Vector3;
1501
1282
  type three_d_Vector4 = Vector4;
1502
1283
  type three_d_VectorRepresentation = VectorRepresentation;
1503
1284
  declare namespace three_d {
1504
- 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 };
1285
+ 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 };
1505
1286
  }
1506
1287
 
1507
1288
  /**
@@ -1850,7 +1631,48 @@ declare function createEvents(store: RootStore): {
1850
1631
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1851
1632
  };
1852
1633
  /** Default R3F event manager for web */
1853
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1634
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
1635
+
1636
+ interface RootExtension {
1637
+ /** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
1638
+ * set up are not set up a second time, but get the new entry's dispose and hmr. */
1639
+ name: string;
1640
+ /**
1641
+ * Called once per root, after its renderer exists and before `onCreated` and the first frame.
1642
+ * `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
1643
+ * to the primary canvas. Return fields to merge into the root's state, or nothing.
1644
+ */
1645
+ setup?(store: RootStore): Partial<RootState> | void;
1646
+ /** Called when a root this extension set up unmounts. */
1647
+ dispose?(store: RootStore): void;
1648
+ /** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
1649
+ hmr?(store: RootStore): void;
1650
+ }
1651
+ /**
1652
+ * Register an extension. It is set up on every live root immediately, and on every root created
1653
+ * afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
1654
+ * it already set up keep its state and still get its dispose when they unmount.
1655
+ */
1656
+ declare function registerRootExtension(extension: RootExtension): () => void;
1657
+ /**
1658
+ * Point a root's default render job at a different render function, or back at
1659
+ * `renderer.render(scene, camera)` with `null`.
1660
+ *
1661
+ * The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
1662
+ * boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
1663
+ */
1664
+ declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
1665
+
1666
+ /**
1667
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1668
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1669
+ */
1670
+ declare function useStore(): RootStore;
1671
+ /**
1672
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1673
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1674
+ */
1675
+ declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
1854
1676
 
1855
1677
  /**
1856
1678
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -1883,7 +1705,7 @@ declare namespace useLoader {
1883
1705
  *
1884
1706
  * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1885
1707
  * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1886
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
1708
+ * @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
1887
1709
  *
1888
1710
  * @example
1889
1711
  * // Simple priority (backwards compat)
@@ -2094,16 +1916,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
2094
1916
  declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
2095
1917
  declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
2096
1918
 
2097
- /**
2098
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2099
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2100
- */
2101
- declare function useStore(): RootStore;
2102
- /**
2103
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2104
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2105
- */
2106
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2107
1919
  /**
2108
1920
  * Exposes an object's {@link Instance}.
2109
1921
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -2179,7 +1991,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
2179
1991
  * Invalidates the view, requesting a frame to be rendered.
2180
1992
  * In demand mode, this triggers the scheduler to run frames.
2181
1993
  *
2182
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
1994
+ * With a state argument, only that root's jobs run on the requested frames; other
1995
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
1996
+ *
1997
+ * @param state - Optional root state; targets the invalidation at that root
2183
1998
  * @param frames - Number of frames to request (default: 1)
2184
1999
  * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2185
2000
  *
@@ -2190,14 +2005,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2190
2005
  * Advances the frameloop and runs render effects.
2191
2006
  * Useful for when manually rendering via `frameloop="never"`.
2192
2007
  *
2008
+ * With a state argument, only that root is stepped. Without one, every
2009
+ * registered root is stepped for backwards compatibility.
2010
+ *
2193
2011
  * @param timestamp - The timestamp to use for this frame
2194
2012
  * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2195
- * @param state - Ignored (kept for backwards compat)
2196
- * @param frame - Ignored (kept for backwards compat)
2013
+ * @param state - Optional root state; targets the manual step at that root
2197
2014
  *
2198
2015
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2199
2016
  */
2200
- declare function advance(timestamp: number): void;
2017
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2201
2018
 
2202
2019
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2203
2020
  declare function ReactReconciler<
@@ -3242,6 +3059,7 @@ declare namespace ReactReconciler {
3242
3059
 
3243
3060
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3244
3061
  declare function extend<T extends Catalogue>(objects: T): void;
3062
+ declare function extend(objects: Record<string, unknown>): void;
3245
3063
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3246
3064
 
3247
3065
  declare const isRenderer: (def: any) => boolean;
@@ -3266,6 +3084,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
3266
3084
  declare function flushSync<R>(fn: () => R): R;
3267
3085
 
3268
3086
  declare const context: React$1.Context<RootStore>;
3087
+
3269
3088
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3270
3089
 
3271
3090
  /**
@@ -3519,7 +3338,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
3519
3338
  declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3520
3339
  /**
3521
3340
  * Triggers an update for an instance.
3522
- * Calls onUpdate callback and invalidates the frame if necessary.
3341
+ * Invalidates the frame if the root is in demand mode.
3523
3342
  *
3524
3343
  * @param instance - Instance to invalidate
3525
3344
  */
@@ -3685,29 +3504,44 @@ declare const hasConstructor: (object: unknown) => object is {
3685
3504
  * Used to identify values that should be resolved from refs after mount.
3686
3505
  */
3687
3506
  declare const FROM_REF: unique symbol;
3507
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3508
+ interface FromRefMarker<T = unknown, R = T> {
3509
+ [FROM_REF]: React$1.RefObject<T | null>;
3510
+ /** Optional transform applied to the resolved ref before assignment. */
3511
+ transform?: (value: T) => R;
3512
+ }
3688
3513
  /**
3689
3514
  * Defers prop application until the referenced object is available.
3690
3515
  * Useful for props like `target` that need sibling refs to be populated.
3691
3516
  *
3517
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3518
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3519
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3520
+ * what gets assigned.
3521
+ *
3692
3522
  * @param ref - React ref object to resolve at mount time
3693
- * @returns A marker value that applyProps will resolve after mount
3523
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3524
+ * @returns A marker value that the reconciler resolves after mount
3694
3525
  *
3695
3526
  * @example
3696
3527
  * const targetRef = useRef<THREE.Object3D>(null)
3697
3528
  *
3698
3529
  * <group ref={targetRef} position={[-3, -2, -15]} />
3699
3530
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3531
+ *
3532
+ * @example
3533
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3534
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3700
3535
  */
3701
3536
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3537
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3702
3538
  /**
3703
3539
  * Type guard to check if a value is a fromRef marker.
3704
3540
  *
3705
3541
  * @param value - Value to check
3706
3542
  * @returns True if value is a fromRef marker
3707
3543
  */
3708
- declare function isFromRef(value: unknown): value is {
3709
- [FROM_REF]: React$1.RefObject<any>;
3710
- };
3544
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3711
3545
 
3712
3546
  /**
3713
3547
  * Symbol marker for mount-only method calls.
@@ -3734,7 +3568,15 @@ declare const ONCE: unique symbol;
3734
3568
  * // No arguments
3735
3569
  * <geometry center={once()} />
3736
3570
  */
3737
- declare function once<T>(...args: T[]): T;
3571
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3572
+ /**
3573
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3574
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3575
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3576
+ *
3577
+ * The runtime value is always the marker object; only the declared type follows the prop.
3578
+ */
3579
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3738
3580
  /**
3739
3581
  * Type guard to check if a value is a once marker.
3740
3582
  *
@@ -3751,5 +3593,5 @@ declare function isOnce(value: unknown): value is {
3751
3593
  */
3752
3594
  declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3753
3595
 
3754
- 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 };
3755
- 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, 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, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, 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 };
3596
+ 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 };
3597
+ export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, 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, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, RootState, RootStore, SetBlock, Size, 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 };