@react-three/fiber 10.0.0-canary.de17310 → 10.0.0-canary.e53bd54

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.ts CHANGED
@@ -1,3569 +1,144 @@
1
- import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
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
- import * as THREE$1 from 'three';
5
- import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
- import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
7
- import { Inspector } from 'three/addons/inspector/Inspector.js';
8
- import * as React$1 from 'react';
9
- import { ReactNode, Component, RefObject, JSX } from 'react';
10
- import { StoreApi } from 'zustand';
11
- import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
12
- import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
13
- export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
14
- import { Options } from 'react-use-measure';
1
+ import * as ThreeWebGPU from 'three/webgpu';
2
+ import * as THREE from 'three';
15
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
- import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
17
-
18
-
19
- /**
20
- * @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
21
- *
22
- * This is the single source of truth for Three.js imports within R3F.
23
- * All internal code should import from '#three' (or '../three' relative).
24
- *
25
- * DEFAULT behavior (root import):
26
- * - Exports from three/webgpu (the new standard)
27
- * - Also exports WebGLRenderer for backwards compatibility (with deprecation)
28
- * - Both renderer types available, runtime decides which to use
29
- *
30
- * For explicit legacy or webgpu-only builds, use:
31
- * - #three/legacy - WebGL only, no WebGPU
32
- * - #three/webgpu - WebGPU only, no WebGL legacy
33
- */
34
- declare const R3F_BUILD_LEGACY = true;
35
- declare const R3F_BUILD_WEBGPU = true;
36
-
37
- /** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
38
- declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
39
-
40
-
41
- //* Utility Types ==============================
42
-
43
- type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
44
- type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
45
- type Properties<T> = Pick<T, NonFunctionKeys<T>>
46
- type Mutable<P> = { -readonly [K in keyof P]: P[K] }
47
- type IsOptional<T> = undefined extends T ? true : false
48
- type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
49
- ? IsOptional<First> extends true
50
- ? IsAllOptional<Rest>
51
- : false
52
- : true
53
-
54
- //* Camera Types ==============================
55
-
56
- type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
57
-
58
- //* Act Type ==============================
59
-
60
- type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
61
-
62
- //* Bridge & Block Types ==============================
63
-
64
- type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
65
-
66
- type SetBlock = false | Promise<null> | null
67
- type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
68
-
69
- //* Object Map Type ==============================
70
-
71
- /* Original version
72
- export interface ObjectMap {
73
- nodes: { [name: string]: THREE.Object3D }
74
- materials: { [name: string]: THREE.Material }
75
- meshes: { [name: string]: THREE.Mesh }
76
- }
77
- */
78
- /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
79
- It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
80
- I will keep the use here)
81
- https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
82
- His description is:
83
- The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
84
- */
85
- interface ObjectMap<
86
- T extends { nodes?: string; materials?: string; meshes?: string } = {
87
- nodes: string
88
- materials: string
89
- meshes: string
90
- },
91
- > {
92
- nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
93
- materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
94
- meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
95
- }
96
-
97
- //* Equality Config ==============================
98
-
99
- interface EquConfig {
100
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
101
- arrays?: 'reference' | 'shallow'
102
- /** Compare objects by reference equality a === b (default), or by shallow equality */
103
- objects?: 'reference' | 'shallow'
104
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
105
- strict?: boolean
106
- }
107
-
108
- //* Disposable Type ==============================
109
-
110
- interface Disposable {
111
- type?: string
112
- dispose?: () => void
113
- }
114
-
115
- //* Event-related Types =====================================
116
-
117
- interface Intersection extends THREE$1.Intersection {
118
- /** The event source (the object which registered the handler) */
119
- eventObject: THREE$1.Object3D
120
- }
121
-
122
- type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
123
-
124
- interface IntersectionEvent<TSourceEvent> extends Intersection {
125
- /** The event source (the object which registered the handler) */
126
- eventObject: THREE$1.Object3D
127
- /** An array of intersections */
128
- intersections: Intersection[]
129
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
130
- unprojectedPoint: THREE$1.Vector3
131
- /** Normalized event coordinates */
132
- pointer: THREE$1.Vector2
133
- /** pointerId of the original event for multiple pointer events */
134
- pointerId: number
135
- /** Delta between first click and this event */
136
- delta: number
137
- /** The ray that pierced it */
138
- ray: THREE$1.Ray
139
- /** The camera that was used by the raycaster */
140
- camera: Camera
141
- /** stopPropagation will stop underlying handlers from firing */
142
- stopPropagation: () => void
143
- /** The original host event */
144
- nativeEvent: TSourceEvent
145
- /** If the event was stopped by calling stopPropagation */
146
- stopped: boolean
147
- }
148
-
149
- type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
150
- type DomEvent = PointerEvent | MouseEvent | WheelEvent
151
-
152
- /** DOM event handlers registered on the canvas element */
153
- interface Events {
154
- onClick: EventListener
155
- onContextMenu: EventListener
156
- onDoubleClick: EventListener
157
- onWheel: EventListener
158
- onPointerDown: EventListener
159
- onPointerUp: EventListener
160
- onPointerLeave: EventListener
161
- onPointerMove: EventListener
162
- onPointerCancel: EventListener
163
- onLostPointerCapture: EventListener
164
- onDragEnter: EventListener
165
- onDragLeave: EventListener
166
- onDragOver: EventListener
167
- onDrop: EventListener
168
- }
169
-
170
- /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
171
- interface EventHandlers {
172
- onClick?: (event: ThreeEvent<MouseEvent>) => void
173
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
174
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
175
- /** Fires continuously while dragging over the object */
176
- onDragOver?: (event: ThreeEvent<DragEvent>) => void
177
- /** Fires once when drag enters the object */
178
- onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
179
- /** Fires once when drag leaves the object */
180
- onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
181
- /** Fires when drag misses this object (for objects that have drag handlers) */
182
- onDragOverMissed?: (event: DragEvent) => void
183
- /** Fires when a drop occurs on this object */
184
- onDrop?: (event: ThreeEvent<DragEvent>) => void
185
- /** Fires when a drop misses this object (for objects that have drop handlers) */
186
- onDropMissed?: (event: DragEvent) => void
187
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
188
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
189
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
190
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
191
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
192
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
193
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
194
- onPointerMissed?: (event: MouseEvent) => void
195
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
196
- onWheel?: (event: ThreeEvent<WheelEvent>) => void
197
- onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
198
-
199
- //* Visibility Events --------------------------------
200
- /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
201
- onFramed?: (inView: boolean) => void
202
- /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
203
- onOccluded?: (occluded: boolean) => void
204
- /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
205
- onVisible?: (visible: boolean) => void
206
- }
207
-
208
- type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
209
- type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
210
-
211
- /** Configuration for XR pointer registration (controllers/hands) */
212
- interface XRPointerConfig {
213
- /** Ray origin (updated each frame by XR system) */
214
- ray: THREE$1.Ray
215
- /** Optional: custom compute function for this pointer */
216
- compute?: (state: RootState) => void
217
- /** Pointer type identifier */
218
- type: 'controller' | 'hand' | 'gaze'
219
- /** Which hand (for controller/hand types) */
220
- handedness?: 'left' | 'right'
221
- }
222
-
223
- interface EventManager<TTarget> {
224
- /** Determines if the event layer is active */
225
- enabled: boolean
226
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
227
- priority: number
228
- /** The compute function needs to set up the raycaster and an xy- pointer */
229
- compute?: ComputeFunction
230
- /** The filter can re-order or re-structure the intersections */
231
- filter?: FilterFunction
232
- /** The target node the event layer is tied to */
233
- connected?: TTarget
234
- /** All the pointer event handlers through which the host forwards native events */
235
- handlers?: Events
236
- /** Allows re-connecting to another target */
237
- connect?: (target: TTarget) => void
238
- /** Removes all existing events handlers from the target */
239
- disconnect?: () => void
240
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
241
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
242
- * @param pointerId - Optional pointer ID to update specific pointer only
243
- */
244
- update?: (pointerId?: number) => void
245
- /** Defer pointer move raycasting to frame start (default: true) */
246
- frameTimedRaycasts?: boolean
247
- /** Always fire raycaster immediately on scroll events (default: true) */
248
- alwaysFireOnScroll?: boolean
249
- /** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
250
- updateOnFrame?: boolean
251
- /** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
252
- flush?: () => void
253
- /** Register an XR pointer (controller/hand). Returns assigned pointerId */
254
- registerPointer?: (config: XRPointerConfig) => number
255
- /** Unregister an XR pointer */
256
- unregisterPointer?: (pointerId: number) => void
257
- }
258
-
259
- interface PointerCaptureTarget {
260
- intersection: Intersection
261
- target: Element
262
- }
263
-
264
- //* Visibility System Types =====================================
265
-
266
- /** Entry in the visibility registry for tracking object visibility state */
267
- interface VisibilityEntry {
268
- object: THREE$1.Object3D
269
- handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
270
- lastFramedState: boolean | null
271
- lastOccludedState: boolean | null
272
- lastVisibleState: boolean | null
273
- }
274
-
275
- //* Scheduler Types (useFrame) ==============================
276
- //
277
- // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
278
- // This file re-exports them and layers r3f's RootState-aware frame state on top,
279
- // so existing `#types` imports across the codebase keep resolving unchanged.
280
-
281
-
282
-
283
- // Frame State (r3f-specific) --------------------------------
284
-
285
- /**
286
- * State passed to useFrame callbacks (extends RootState with timing).
287
- */
288
- interface FrameNextState extends RootState, FrameTimingState {}
289
-
290
- /** Alias for FrameNextState */
291
- type FrameState = FrameNextState
292
-
293
- // Callback Types (r3f-specific) --------------------------------
294
-
295
- /**
296
- * Callback function for useFrame. Receives the full r3f RootState plus timing.
297
- */
298
- type FrameNextCallback = FrameCallback$1<RootState>
299
-
300
- /** Alias for FrameNextCallback */
301
- type FrameCallback = FrameNextCallback
302
-
303
- //* Renderer Types ========================================
304
-
305
- /** Default renderer type - union of WebGL and WebGPU renderers */
306
- type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
307
-
308
- //* Core Store Types ========================================
309
-
310
- type Subscription = {
311
- ref: React$1.RefObject<RenderCallback>
312
- priority: number
313
- store: RootStore
314
- }
315
-
316
- /** Per-pointer state for multi-touch and XR support */
317
- type PointerState = {
318
- /** Objects currently hovered by this pointer */
319
- hovered: Map<string, ThreeEvent<DomEvent>>
320
- /** Objects capturing this pointer */
321
- captured: Map<THREE$1.Object3D, PointerCaptureTarget>
322
- /** Initial click position [x, y] */
323
- initialClick: [x: number, y: number]
324
- /** Objects hit on initial click */
325
- initialHits: THREE$1.Object3D[]
326
- }
327
-
328
- type Dpr = number | [min: number, max: number]
329
-
330
- interface Size {
331
- width: number
332
- height: number
333
- top: number
334
- left: number
335
- }
336
-
337
- type Frameloop = 'always' | 'demand' | 'never'
338
-
339
- interface Viewport extends Size {
340
- /** The initial pixel ratio */
341
- initialDpr: number
342
- /** Current pixel ratio */
343
- dpr: number
344
- /** size.width / viewport.width */
345
- factor: number
346
- /** Camera distance */
347
- distance: number
348
- /** Camera aspect ratio: width / height */
349
- aspect: number
350
- }
351
-
352
- type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
353
-
354
- interface Performance {
355
- /** Current performance normal, between min and max */
356
- current: number
357
- /** How low the performance can go, between 0 and max */
358
- min: number
359
- /** How high the performance can go, between min and max */
360
- max: number
361
- /** Time until current returns to max in ms */
362
- debounce: number
363
- /** Sets current to min, puts the system in regression */
364
- regress: () => void
365
- }
366
-
367
- interface InternalState {
368
- interaction: THREE$1.Object3D[]
369
- subscribers: Subscription[]
370
- /** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
371
- pointerMap: Map<number, PointerState>
372
- /** Pointers needing raycast this frame (used with frameTimedRaycasts) */
373
- pointerDirty: Map<number, DomEvent>
374
- /** Last event received (for events.update() compatibility) */
375
- lastEvent: React$1.RefObject<DomEvent | null>
376
- /** @deprecated Use pointerMap.get(pointerId).hovered instead */
377
- hovered: Map<string, ThreeEvent<DomEvent>>
378
- /** @deprecated Use pointerMap.get(pointerId).captured instead */
379
- capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
380
- /** @deprecated Use pointerMap.get(pointerId).initialClick instead */
381
- initialClick: [x: number, y: number]
382
- /** @deprecated Use pointerMap.get(pointerId).initialHits instead */
383
- initialHits: THREE$1.Object3D[]
384
- /** Visibility event registry (onFramed, onOccluded, onVisible) */
385
- visibilityRegistry: Map<string, VisibilityEntry>
386
- /** Whether occlusion queries are enabled (WebGPU only) */
387
- occlusionEnabled: boolean
388
- /** Reference to the invisible occlusion observer mesh */
389
- occlusionObserver: THREE$1.Mesh | null
390
- /** Cached occlusion results from render pass - keyed by Object3D */
391
- occlusionCache: Map<THREE$1.Object3D, boolean | null>
392
- /** Internal helper group for R3F system objects (occlusion observer, etc.) */
393
- helperGroup: THREE$1.Group | null
394
- active: boolean
395
- priority: number
396
- frames: number
397
- subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
398
- /** Internal renderer storage - use state.renderer or state.gl to access */
399
- actualRenderer: R3FRenderer
400
- /** Global scheduler reference (for useFrame hook) */
401
- scheduler: SchedulerApi | null
402
- /**
403
- * Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
404
- * `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
405
- * render-phase takeover. Used by `useRenderPipeline`.
406
- */
407
- renderOverride?: (() => void) | null
408
- /** This root's unique ID in the global scheduler */
409
- rootId?: string
410
- /** Function to unregister this root from the global scheduler */
411
- unregisterRoot?: () => void
412
- /** Container for child attachment (scene for root, original container for portals) */
413
- container?: THREE$1.Object3D
414
- /**
415
- * The CanvasTarget this root sizes and renders through.
416
- *
417
- * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
418
- * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
419
- * R3F created for its own element. Either way there is exactly one target per canvas element,
420
- * and the canvas-target job makes it the renderer's active one before this root renders.
421
- * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
422
- * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
423
- */
424
- canvasTarget?: CanvasTarget
425
- /**
426
- * Set when this root's canvas target has been resized and the backend's cached render pass
427
- * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
428
- *
429
- * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
430
- * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
431
- * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
432
- * invalidate some other canvas's descriptor instead.
433
- *
434
- * @see https://github.com/pmndrs/react-three-fiber/issues/3847
435
- */
436
- canvasTargetSizeDirty?: boolean
437
- /**
438
- * Whether multi-canvas rendering is active.
439
- * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
440
- * When true, setCanvasTarget is called before each render.
441
- */
442
- isMultiCanvas?: boolean
443
- /**
444
- * Whether this canvas is a secondary canvas sharing another's renderer.
445
- * True when `target` prop is used.
446
- */
447
- isSecondary?: boolean
448
- /**
449
- * The id of the primary canvas this secondary canvas targets.
450
- * Only set when isSecondary is true.
451
- */
452
- targetId?: string
453
- /**
454
- * Function to unregister this primary canvas from the registry.
455
- * Only set when this canvas has an `id` prop.
456
- */
457
- unregisterPrimary?: () => void
458
- /** Whether canvas dimensions are forced to even numbers */
459
- forceEven?: boolean
460
- }
461
-
462
- interface XRManager {
463
- connect: () => void
464
- disconnect: () => void
465
- }
466
-
467
- //* Root State Interface ====================================
468
-
469
- interface RootState {
470
- /** Set current state */
471
- set: StoreApi<RootState>['setState']
472
- /** Get current state */
473
- get: StoreApi<RootState>['getState']
474
- /**
475
- * The store of the canvas that owns this root's renderer.
476
- * - For primary/independent canvases: points to its own store (self-reference)
477
- * - For secondary canvases: points to the primary canvas's store
478
- * - Portals copy it from their parent
479
- *
480
- * Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
481
- * resolves through it.
482
- */
483
- primaryStore: RootStore
484
- /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
485
- gl: THREE$1.WebGLRenderer
486
- /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
487
- renderer: R3FRenderer
488
- /** Inspector of the webGPU Renderer. Init in the canvas */
489
- inspector: any // Inspector type from three/webgpu
490
-
491
- /** Default camera */
492
- camera: ThreeCamera
493
- /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
494
- frustum: THREE$1.Frustum
495
- /** Whether to automatically update the frustum each frame (default: true) */
496
- autoUpdateFrustum: boolean
497
- /** Default scene (may be overridden in portals to point to the portal container) */
498
- scene: THREE$1.Scene
499
- /** The actual root THREE.Scene - always points to the true scene, even inside portals */
500
- rootScene: THREE$1.Scene
501
- /** Default raycaster */
502
- raycaster: THREE$1.Raycaster
503
- /** Event layer interface, contains the event handler and the node they're connected to */
504
- events: EventManager<any>
505
- /** XR interface */
506
- xr: XRManager
507
- /** Currently used controls */
508
- controls: THREE$1.EventDispatcher | null
509
- /** Normalized event coordinates */
510
- pointer: THREE$1.Vector2
511
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
512
- mouse: THREE$1.Vector2
513
- /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
514
- textureColorSpace: THREE$1.ColorSpace
515
- /** Render loop flags */
516
- frameloop: Frameloop
517
- performance: Performance
518
- /** Reactive pixel-size of the canvas */
519
- size: Size
520
- /** Reactive size of the viewport in threejs units */
521
- viewport: Viewport & {
522
- getCurrentViewport: (
523
- camera?: ThreeCamera,
524
- target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
525
- size?: Size,
526
- ) => Omit<Viewport, 'dpr' | 'initialDpr'>
527
- }
528
- /** Flags the canvas for render, but doesn't render in itself */
529
- invalidate: (frames?: number, stackFrames?: boolean) => void
530
- /** Advance (render) one step */
531
- advance: (timestamp: number, runGlobalEffects?: boolean) => void
532
- /** Shortcut to setting the event layer */
533
- setEvents: (events: Partial<EventManager<any>>) => void
534
- /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
535
- setSize: (width?: number, height?: number, top?: number, left?: number) => void
536
- /** Shortcut to manual setting the pixel ratio */
537
- setDpr: (dpr: Dpr) => void
538
- /** Shortcut to setting frameloop flags. No args resets to 'always'. */
539
- setFrameloop: (frameloop?: Frameloop) => void
540
- /** Set error state to propagate to error boundary */
541
- setError: (error: Error | null) => void
542
- /** Current error state (null when no error) */
543
- error: Error | null
544
- /** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
545
- textures: Map<string, THREE$1.Texture>
546
- /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
547
- _textureRefs: Map<string, number>
548
- /** Internal: whether setSize() has taken ownership of canvas dimensions */
549
- _sizeImperative: boolean
550
- /** Internal: stored size props from Canvas for reset functionality */
551
- _sizeProps: { width?: number; height?: number } | null
552
- /** When the canvas was clicked but nothing was hit */
553
- onPointerMissed?: (event: MouseEvent) => void
554
- /** When a dragover event has missed any target */
555
- onDragOverMissed?: (event: DragEvent) => void
556
- /** When a drop event has missed any target */
557
- onDropMissed?: (event: DragEvent) => void
558
- /** If this state model is layered (via createPortal) then this contains the previous layer */
559
- previousRoot?: RootStore
560
- /** Internals */
561
- internal: InternalState
562
- // flags for triggers
563
- // if we are using the webGl renderer, this will be true
564
- isLegacy: boolean
565
- // regardless of renderer, if the system supports webGpu, this will be true
566
- webGPUSupported: boolean
567
- //if we are on native
568
- isNative: boolean
569
- }
570
-
571
- type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
572
-
573
- //* Base Renderer Types =====================================
574
-
575
- // Shim for OffscreenCanvas since it was removed from DOM types
576
- interface OffscreenCanvas$1 extends EventTarget {}
577
-
578
- interface BaseRendererProps {
579
- canvas: HTMLCanvasElement | OffscreenCanvas$1
580
- powerPreference?: 'high-performance' | 'low-power' | 'default'
581
- antialias?: boolean
582
- alpha?: boolean
583
- }
584
-
585
- type RendererFactory<TRenderer, TParams> =
586
- | TRenderer
587
- | ((defaultProps: TParams) => TRenderer)
588
- | ((defaultProps: TParams) => Promise<TRenderer>)
589
-
590
- interface Renderer {
591
- render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
592
- }
593
-
594
- //* Color Management Config ==============================
595
-
596
- /**
597
- * Color management configuration shared by both WebGL and WebGPU renderers.
598
- */
599
- interface ColorManagementConfig {
600
- /**
601
- * Color space assigned to 8-bit input textures (color maps).
602
- * Defaults to sRGB. Most textures are authored in sRGB.
603
- * @default THREE.SRGBColorSpace
604
- */
605
- textureColorSpace?: THREE$1.ColorSpace
606
- }
607
-
608
- //* WebGL Renderer Props ==============================
609
-
610
- type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
611
- canvas: HTMLCanvasElement | OffscreenCanvas$1
612
- }
613
-
614
- type GLProps =
615
- | Renderer
616
- | ((defaultProps: DefaultGLProps) => Renderer)
617
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
618
- | (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
619
-
620
- //* WebGPU Renderer Props ==============================
621
-
622
- type DefaultRendererProps = {
623
- canvas: HTMLCanvasElement | OffscreenCanvas$1
624
- [key: string]: any
625
- }
626
-
627
- /**
628
- * Canvas-level scheduler configuration.
629
- * Controls render timing relative to other canvases.
630
- */
631
- interface CanvasSchedulerConfig {
632
- /**
633
- * Run this Canvas root before the referenced Canvas root id(s).
634
- */
635
- before?: string | string[]
636
- /**
637
- * Run this Canvas root after the referenced Canvas root id(s).
638
- */
639
- after?: string | string[]
640
- /**
641
- * Numeric root order. Lower values run first.
642
- */
643
- order?: number
644
- /**
645
- * Limit this Canvas's default render job (frames per second).
646
- */
647
- fps?: number
648
- }
649
-
650
- /**
651
- * Extended renderer configuration for multi-canvas support and color management.
652
- */
653
- interface RendererConfigExtended extends ColorManagementConfig {
654
- /** Share renderer from another canvas (WebGPU only) */
655
- primaryCanvas?: string
656
- /** Canvas-level scheduler options */
657
- scheduler?: CanvasSchedulerConfig
658
- }
659
-
660
- type RendererProps =
661
- | any // WebGPURenderer
662
- | ((defaultProps: DefaultRendererProps) => any)
663
- | ((defaultProps: DefaultRendererProps) => Promise<any>)
664
- | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
665
-
666
- //* Camera Props ==============================
667
-
668
- type CameraProps = (
669
- | THREE$1.Camera
670
- | Partial<
671
- ThreeElement<typeof THREE$1.Camera> &
672
- ThreeElement<typeof THREE$1.PerspectiveCamera> &
673
- ThreeElement<typeof THREE$1.OrthographicCamera>
674
- >
675
- ) & {
676
- /** Flags the camera as manual, putting projection into your own hands */
677
- manual?: boolean
678
- }
679
-
680
- //* Render Props ==============================
681
-
682
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
683
- /**
684
- * Unique identifier for multi-canvas renderer sharing.
685
- * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
686
- * Also sets the HTML `id` attribute on the canvas element.
687
- * @example <Canvas id="main-viewer">...</Canvas>
688
- */
689
- id?: string
690
- /**
691
- * Share the renderer from another canvas instead of creating a new one.
692
- * Pass the `id` of the primary canvas to share its WebGPURenderer.
693
- * Only available with WebGPU (not legacy WebGL).
694
- *
695
- * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
696
- * @internal
697
- */
698
- primaryCanvas?: string
699
- /**
700
- * Canvas-level scheduler options. Controls render timing relative to other canvases.
701
- *
702
- * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
703
- * @internal
704
- */
705
- scheduler?: CanvasSchedulerConfig
706
- /** A threejs renderer instance or props that go into the default renderer */
707
- gl?: GLProps
708
- /** A WebGPU renderer instance or props that go into the default renderer */
709
- renderer?: RendererProps
710
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
711
- size?: Size
712
- /**
713
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
714
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
715
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
716
- */
717
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
718
- /** Creates an orthographic camera */
719
- orthographic?: boolean
720
- /**
721
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
722
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
723
- */
724
- frameloop?: Frameloop
725
- /**
726
- * R3F performance options for adaptive performance.
727
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
728
- */
729
- performance?: Partial<Omit<Performance, 'regress'>>
730
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
731
- dpr?: Dpr
732
- /**
733
- * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
734
- * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
735
- */
736
- raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
737
- /** A `THREE.Scene` instance or props that go into the default scene */
738
- scene?: THREE$1.Scene | Partial<THREE$1.Scene>
739
- /** A `THREE.Camera` instance or props that go into the default camera */
740
- camera?: CameraProps
741
- /** An R3F event manager to manage elements' pointer events */
742
- events?: (store: RootStore) => EventManager<Element>
743
- /** Callback after the canvas has rendered (but not yet committed) */
744
- onCreated?: (state: RootState) => void
745
- /** Response for pointer clicks that have missed any target */
746
- onPointerMissed?: (event: MouseEvent) => void
747
- /** Response for dragover events that have missed any target */
748
- onDragOverMissed?: (event: DragEvent) => void
749
- /** Response for drop events that have missed any target */
750
- onDropMissed?: (event: DragEvent) => void
751
- /** Whether to automatically update the frustum each frame (default: true) */
752
- autoUpdateFrustum?: boolean
753
- /**
754
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
755
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
756
- * Only works with WebGPU renderer - WebGL will log a warning.
757
- */
758
- occlusion?: boolean
759
- /** Internal: stored size props from Canvas for reset functionality */
760
- _sizeProps?: { width?: number; height?: number } | null
761
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
762
- forceEven?: boolean
763
- }
764
-
765
- //* Reconciler Root ==============================
766
-
767
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
768
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
769
- render: (element: ReactNode) => RootStore
770
- unmount: () => void
771
- }
772
-
773
- //* Inject State ==============================
774
-
775
- type InjectState = Partial<
776
- Omit<RootState, 'events'> & {
777
- events?: {
778
- enabled?: boolean
779
- priority?: number
780
- compute?: ComputeFunction
781
- connected?: any
782
- }
783
- /**
784
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
785
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
786
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
787
- */
788
- injectScene?: boolean
789
- }
790
- >
791
-
792
- //* Reconciler Types ==============================
793
-
794
- // FiberRoot is an opaque internal React type - we define it locally
795
- // to avoid bundling @types/react-reconciler which causes absolute path issues
796
- type FiberRoot = any
797
-
798
- interface Root {
799
- fiber: FiberRoot
800
- store: RootStore
801
- }
802
-
803
- type AttachFnType<O = any> = (parent: any, self: O) => () => void
804
- type AttachType<O = any> = string | AttachFnType<O>
805
-
806
- type ConstructorRepresentation<T = any> = new (...args: any[]) => T
807
-
808
- interface Catalogue {
809
- [name: string]: ConstructorRepresentation
810
- }
811
-
812
- // TODO: handle constructor overloads
813
- // https://github.com/pmndrs/react-three-fiber/pull/2931
814
- // https://github.com/microsoft/TypeScript/issues/37079
815
- type Args<T> = T extends ConstructorRepresentation
816
- ? T extends typeof Color$1
817
- ? [r: number, g: number, b: number] | [color: ColorRepresentation]
818
- : ConstructorParameters<T>
819
- : any[]
820
-
821
- type ArgsProp<P> = P extends ConstructorRepresentation
822
- ? IsAllOptional<ConstructorParameters<P>> extends true
823
- ? { args?: Args<P> }
824
- : { args: Args<P> }
825
- : { args: unknown[] }
826
-
827
- type InstanceProps<T = any, P = any> = ArgsProp<P> & {
828
- object?: T
829
- dispose?: null
830
- attach?: AttachType<T>
831
- }
832
-
833
- interface Instance<O = any> {
834
- root: RootStore
835
- type: string
836
- parent: Instance | null
837
- children: Instance[]
838
- props: InstanceProps<O> & Record<string, unknown>
839
- object: O & { __r3f?: Instance<O> }
840
- eventCount: number
841
- handlers: Partial<EventHandlers>
842
- attach?: AttachType<O>
843
- previousAttach?: any
844
- isHidden: boolean
845
- /** Set of props that have been applied via once() */
846
- appliedOnce?: Set<string>
847
- }
848
-
849
- interface HostConfig {
850
- type: string
851
- props: Instance['props']
852
- container: RootStore
853
- instance: Instance
854
- textInstance: void
855
- suspenseInstance: Instance
856
- hydratableInstance: never
857
- formInstance: never
858
- publicInstance: Instance['object']
859
- hostContext: {}
860
- childSet: never
861
- timeoutHandle: number | undefined
862
- noTimeout: -1
863
- TransitionStatus: null
864
- }
865
- declare global {
866
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
867
- }
868
-
869
- //* Loop Types ==============================
870
-
871
- type GlobalRenderCallback = (timestamp: number) => void
872
-
873
- type GlobalEffectType = 'before' | 'after' | 'tail'
874
-
875
- declare const presetsObj: {
876
- apartment: string;
877
- city: string;
878
- dawn: string;
879
- forest: string;
880
- lobby: string;
881
- night: string;
882
- park: string;
883
- studio: string;
884
- sunset: string;
885
- warehouse: string;
886
- };
887
- type PresetsType = keyof typeof presetsObj;
888
-
889
- //* Background Types ==============================
890
-
891
- /**
892
- * Expanded object form for background configuration.
893
- * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
894
- */
895
- interface BackgroundConfig {
896
- /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
897
- preset?: PresetsType
898
- /** Files for cube texture (6 faces) or single HDR/EXR */
899
- files?: string | string[]
900
- /** Separate files for scene.background (visual backdrop) */
901
- backgroundMap?: string | string[]
902
- backgroundRotation?: Euler$1 | [number, number, number]
903
- backgroundBlurriness?: number
904
- backgroundIntensity?: number
905
- /** Separate files for scene.environment (PBR lighting/reflections) */
906
- envMap?: string | string[]
907
- environmentRotation?: Euler$1 | [number, number, number]
908
- environmentIntensity?: number
909
- path?: string
910
- extensions?: (loader: Loader) => void
4
+ import { M as MutableOrReadonlyParameters$1, a as MathRepresentation$1, V as VectorRepresentation$1, b as MathTypes$1, c as MathType$1, d as MathProps$1, e as Vector2$1, f as Vector3$1, g as Vector4$1, C as Color$1, L as Layers$1, Q as Quaternion$1, E as Euler$1, h as Matrix3$1, i as Matrix4$1, R as RaycastableRepresentation$1, j as EventProps$1, G as GeometryTransformProps$1, k as GeometryProps$1, T as TSLNodeInput$1, N as NodeProps$1, l as ReactProps$1, m as ConstructorRepresentation, n as ElementProps$1, o as ThreeElement$1, p as ThreeToJSXElements$1, O as Object3DMethod$1, q as ThreeElementsOf$1, r as ElementOf$1, v as RenderTargetOptions, u as ReconcilerRoot, s as CanvasProps } from './shared/fiber.DAg-9ieU.js';
5
+ export { a7 as Args, a8 as ArgsProp, a4 as AttachFnType, a5 as AttachType, ae as BackgroundConfig, af as BackgroundProp, I as BaseRendererProps, b8 as Block, $ as CameraProps, Y as CanvasSchedulerConfig, a6 as Catalogue, P as ColorManagementConfig, S as DefaultGLProps, X as DefaultRendererProps, aO as DisposeOptions, ay as Environment, aw as EnvironmentCube, aR as EnvironmentLoaderProps, av as EnvironmentMap, ax as EnvironmentPortal, au as EnvironmentProps, b9 as ErrorBoundary, am as Extensions, bD as FROM_REF, a2 as FiberRoot, bE as FromRefMarker, U as GLProps, ai as GLTFLike, ad as GlobalEffectType, ac as GlobalRenderCallback, ab as HostConfig, ak as InferLoadResult, a1 as InjectState, ag as InputLike, aa as Instance, a9 as InstanceProps, aH as IsObject, x as LegacyInternalState, y as LegacyRenderer, t as LegacyRootState, aj as LoaderInstance, ah as LoaderLike, al as LoaderResult, aI as MappedTextureType, bH as ONCE, H as OffscreenCanvas, bJ as OnceValue, b2 as Portal, aA as PresetsType, an as PrimaryCanvasEntry, ba as REACT_INTERNAL_PROPS, bi as RESERVED_PROPS, a0 as RenderProps, K as Renderer, Z as RendererConfigExtended, J as RendererFactory, _ as RendererProps, a3 as Root, aL as Texture, aM as TextureInput, aN as TextureResult, aJ as UseTextureOptions, aP as UseTexturesReturn, z as WebGLDefaultProps, W as WebGLProps, A as WebGLShadowConfig, a$ as _roots, aU as addAfterEffect, aT as addEffect, aV as addTail, aX as advance, bn as applyProps, bk as attach, bd as buildGraph, bo as calculateDpr, aD as createEvents, w as createPointerEvents, b1 as createPortal, b4 as createStore, bl as detach, bm as diffProps, be as dispose, w as events, aY as extend, bb as findInitialRoot, b3 as flushSync, bF as fromRef, bf as getInstanceProps, ap as getPrimary, at as getPrimaryIds, bc as getRootState, B as getThree, bp as getUuidPrefix, bC as hasConstructor, ar as hasPrimary, D as hasThree, aW as invalidate, bh as invalidateInstance, bs as is, bv as isColorRepresentation, bB as isCopyable, bG as isFromRef, by as isLayers, bw as isObject3D, bK as isOnce, bt as isOrthographicCamera, bu as isRef, a_ as isRenderer, bx as isTexture, bz as isUniform, bA as isVectorLike, bI as once, bg as prepare, az as presetsObj, aZ as reconciler, ao as registerPrimary, aC as removeInteractivity, bj as resolve, aB as swapInteractivity, b0 as unmountComponentAtNode, as as unregisterPrimary, bq as updateCamera, br as updateFrustum, b7 as useBridge, aS as useEnvironment, aF as useGraph, aE as useInstanceHandle, b5 as useIsomorphicLayoutEffect, aG as useLoader, b6 as useMutableCallback, aK as useTexture, aQ as useTextures, aq as waitForPrimary, F as whenThree } from './shared/fiber.DAg-9ieU.js';
6
+ import { a0 as R3FRenderTarget } from './shared/fiber.Bw8YnGg5.js';
7
+ export { A as Act, B as Bridge, C as Camera, i as ComputeFunction, w as Disposable, f as DomEvent, D as Dpr, v as EquConfig, g as EventHandlers, k as EventManager, E as Events, h as FilterFunction, $ as ForRegisteredRenderer, G as FrameCallback, z as FrameNextCallback, x as FrameNextState, y as FrameState, F as Frameloop, a5 as InternalState, I as Intersection, e as IntersectionEvent, p as IsAllOptional, o as IsOptional, M as Mutable, N as NonFunctionKeys, u as ObjectMap, K as OcclusionSupport, O as Overwrite, c as Performance, l as PointerCaptureTarget, P as PointerState, n as Properties, a4 as R3FRenderer, a1 as R3FRendererSupport, Z as Register, _ as RegisteredRenderer, b as RenderCallback, Y as RendererProvider, Q as RendererSupport, R as RootExtension, a6 as RootState, d as RootStore, t as SetBlock, a as Size, S as Subscription, q as ThreeCamera, J as ThreeCore, T as ThreeEvent, H as ThreeNamespace, U as UnblockProps, V as Viewport, m as VisibilityEntry, W as WebGLSupport, L as WebGPUSupport, X as XRManager, j as XRPointerConfig, a3 as context, r as registerRootExtension, s as setRenderOverride, a2 as useStore, a7 as useThree } from './shared/fiber.Bw8YnGg5.js';
8
+ export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
9
+ export { useFrame } from './extension.js';
10
+ import 'react';
11
+ import 'react-use-measure';
12
+ import 'zustand';
13
+ import 'zustand/traditional';
14
+ import 'three/tsl';
15
+
16
+ /**
17
+ * The `ReactThreeFiber` namespace of the default entry: the shared element types plus this entry's JSX map.
18
+ *
19
+ * Explicit aliases, not `export type *`: rollup-dts otherwise re-exports the types as namespace values
20
+ * and the built declaration fails to compile for consumers.
21
+ */
22
+
23
+
24
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters$1<T>
25
+ type MathRepresentation = MathRepresentation$1
26
+ type VectorRepresentation = VectorRepresentation$1
27
+ type MathTypes = MathTypes$1
28
+ type MathType<T extends MathTypes$1> = MathType$1<T>
29
+ type MathProps<P> = MathProps$1<P>
30
+ type Vector2 = Vector2$1
31
+ type Vector3 = Vector3$1
32
+ type Vector4 = Vector4$1
33
+ type Color = Color$1
34
+ type Layers = Layers$1
35
+ type Quaternion = Quaternion$1
36
+ type Euler = Euler$1
37
+ type Matrix3 = Matrix3$1
38
+ type Matrix4 = Matrix4$1
39
+ type RaycastableRepresentation = RaycastableRepresentation$1
40
+ type EventProps<P> = EventProps$1<P>
41
+ type GeometryTransformProps = GeometryTransformProps$1
42
+ type GeometryProps<P> = GeometryProps$1<P>
43
+ type TSLNodeInput = TSLNodeInput$1
44
+ type NodeProps<P> = NodeProps$1<P>
45
+ type ReactProps<P> = ReactProps$1<P>
46
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps$1<T, P>
47
+ type ThreeElement<T extends ConstructorRepresentation> = ThreeElement$1<T>
48
+ type ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements$1<T>
49
+ type Object3DMethod = Object3DMethod$1
50
+ type ThreeElementsOf<T extends Record<string, any>> = ThreeElementsOf$1<T>
51
+ type ElementOf<E, K extends string> = ElementOf$1<E, K>
52
+
53
+ type default_d_Color = Color;
54
+ type default_d_ElementOf<E, K extends string> = ElementOf<E, K>;
55
+ type default_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
56
+ type default_d_Euler = Euler;
57
+ type default_d_EventProps<P> = EventProps<P>;
58
+ type default_d_GeometryProps<P> = GeometryProps<P>;
59
+ type default_d_GeometryTransformProps = GeometryTransformProps;
60
+ type default_d_Layers = Layers;
61
+ type default_d_MathProps<P> = MathProps<P>;
62
+ type default_d_MathRepresentation = MathRepresentation;
63
+ type default_d_MathType<T extends MathTypes$1> = MathType<T>;
64
+ type default_d_MathTypes = MathTypes;
65
+ type default_d_Matrix3 = Matrix3;
66
+ type default_d_Matrix4 = Matrix4;
67
+ type default_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
68
+ type default_d_NodeProps<P> = NodeProps<P>;
69
+ type default_d_Object3DMethod = Object3DMethod;
70
+ type default_d_Quaternion = Quaternion;
71
+ type default_d_RaycastableRepresentation = RaycastableRepresentation;
72
+ type default_d_ReactProps<P> = ReactProps<P>;
73
+ type default_d_TSLNodeInput = TSLNodeInput;
74
+ type default_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
75
+ type default_d_ThreeElements = ThreeElements;
76
+ type default_d_ThreeElementsOf<T extends Record<string, any>> = ThreeElementsOf<T>;
77
+ type default_d_ThreeExports = ThreeExports;
78
+ type default_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
79
+ type default_d_Vector2 = Vector2;
80
+ type default_d_Vector3 = Vector3;
81
+ type default_d_Vector4 = Vector4;
82
+ type default_d_VectorRepresentation = VectorRepresentation;
83
+ declare namespace default_d {
84
+ export type { default_d_Color as Color, default_d_ElementOf as ElementOf, default_d_ElementProps as ElementProps, default_d_Euler as Euler, default_d_EventProps as EventProps, default_d_GeometryProps as GeometryProps, default_d_GeometryTransformProps as GeometryTransformProps, default_d_Layers as Layers, default_d_MathProps as MathProps, default_d_MathRepresentation as MathRepresentation, default_d_MathType as MathType, default_d_MathTypes as MathTypes, default_d_Matrix3 as Matrix3, default_d_Matrix4 as Matrix4, default_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, default_d_NodeProps as NodeProps, default_d_Object3DMethod as Object3DMethod, default_d_Quaternion as Quaternion, default_d_RaycastableRepresentation as RaycastableRepresentation, default_d_ReactProps as ReactProps, default_d_TSLNodeInput as TSLNodeInput, default_d_ThreeElement as ThreeElement, default_d_ThreeElements as ThreeElements, default_d_ThreeElementsOf as ThreeElementsOf, default_d_ThreeExports as ThreeExports, default_d_ThreeToJSXElements as ThreeToJSXElements, default_d_Vector2 as Vector2, default_d_Vector3 as Vector3, default_d_Vector4 as Vector4, default_d_VectorRepresentation as VectorRepresentation };
911
85
  }
912
86
 
913
87
  /**
914
- * Background prop type for Canvas.
88
+ * Creates a render target compatible with the current renderer.
915
89
  *
916
- * String detection priority:
917
- * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
918
- * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
919
- * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
90
+ * Both classes live in three's shared core; which one you get follows the renderer this root
91
+ * loaded: a `WebGLRenderTarget` on WebGL, a `RenderTarget` on WebGPU. The return type is the
92
+ * union unless the app registered a renderer (`Register`) or the entry decides it (`/legacy`,
93
+ * `/webgpu`).
920
94
  *
921
- * @example Color
95
+ * @example
922
96
  * ```tsx
923
- * <Canvas background="red" />
924
- * <Canvas background="#ff0000" />
925
- * <Canvas background={0xff0000} />
926
- * ```
97
+ * // Use canvas size
98
+ * const fbo = useRenderTarget()
927
99
  *
928
- * @example Preset
929
- * ```tsx
930
- * <Canvas background="city" />
931
- * ```
100
+ * // Use canvas size with options
101
+ * const fbo = useRenderTarget({ samples: 4 })
932
102
  *
933
- * @example URL
934
- * ```tsx
935
- * <Canvas background="/path/to/env.hdr" />
936
- * <Canvas background="./sky.jpg" />
937
- * ```
103
+ * // Square render target
104
+ * const fbo = useRenderTarget(512)
938
105
  *
939
- * @example Object form
940
- * ```tsx
941
- * <Canvas background={{
942
- * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
943
- * backgroundMap: 'path/to/sky.jpg',
944
- * envMap: 'path/to/lighting.hdr',
945
- * backgroundBlurriness: 0.5,
946
- * }} />
947
- * ```
948
- */
949
- type BackgroundProp =
950
- | ColorRepresentation // "red", "#ff0000", 0xff0000
951
- | string // URL or preset
952
- | BackgroundConfig // Expanded object form
953
-
954
- //* Canvas Types ==============================
955
-
956
- interface CanvasProps
957
- extends
958
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
959
- React$1.HTMLAttributes<HTMLDivElement> {
960
- children?: React$1.ReactNode
961
- ref?: React$1.Ref<HTMLCanvasElement>
962
- /** Canvas fallback content, similar to img's alt prop */
963
- fallback?: React$1.ReactNode
964
- /**
965
- * Options to pass to useMeasure.
966
- * @see https://github.com/pmndrs/react-use-measure#api
967
- */
968
- resize?: Options
969
- /** The target where events are being subscribed to, default: the div that wraps canvas */
970
- eventSource?: Element | React$1.RefObject<Element | null>
971
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
972
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
973
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
974
- hmr?: boolean
975
- /** Canvas resolution width in pixels. If omitted, uses container width. */
976
- width?: number
977
- /** Canvas resolution height in pixels. If omitted, uses container height. */
978
- height?: number
979
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
980
- forceEven?: boolean
981
- /**
982
- * Scene background configuration.
983
- * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
984
- * @see BackgroundProp for full documentation and examples
985
- */
986
- background?: BackgroundProp
987
- }
988
-
989
- //* Loader Types ==============================
990
-
991
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
992
-
993
- // Define a loader-like interface that matches THREE.Loader's load signature
994
- // This works for both generic and non-generic THREE.Loader instances
995
- interface LoaderLike {
996
- load(
997
- url: InputLike,
998
- onLoad?: (result: any) => void,
999
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
1000
- onError?: (error: unknown) => void,
1001
- ): any
1002
- }
1003
-
1004
- type GLTFLike = { scene: THREE$1.Object3D }
1005
-
1006
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1007
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1008
-
1009
- // Infer result type from the load method's callback parameter
1010
- type InferLoadResult<T> = T extends {
1011
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1012
- }
1013
- ? R
1014
- : T extends ConstructorRepresentation<any>
1015
- ? InstanceType<T> extends {
1016
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1017
- }
1018
- ? R
1019
- : any
1020
- : any
1021
-
1022
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1023
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1024
-
1025
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1026
- loader: LoaderInstance<T>,
1027
- ) => void
1028
-
1029
- //* Renderer Props ========================================
1030
-
1031
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1032
-
1033
- type WebGLProps =
1034
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1035
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1036
-
1037
- interface WebGLShadowConfig {
1038
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1039
- }
1040
-
1041
- //* Legacy-specific Types ========================================
1042
-
1043
- /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1044
- type LegacyRenderer = THREE$1.WebGLRenderer
1045
-
1046
- /** Legacy internal state with narrowed renderer type */
1047
- interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1048
- actualRenderer: THREE$1.WebGLRenderer
1049
- }
1050
-
1051
- /**
1052
- * Legacy-specific RootState with narrowed renderer type.
1053
- * Automatically used when importing from `@react-three/fiber/legacy`.
106
+ * // Square render target with options
107
+ * const fbo = useRenderTarget(512, { depthBuffer: true })
1054
108
  *
1055
- * @example
1056
- * ```tsx
1057
- * import { useThree } from '@react-three/fiber/legacy'
109
+ * // Explicit dimensions
110
+ * const fbo = useRenderTarget(512, 256)
1058
111
  *
1059
- * function MyComponent() {
1060
- * const { renderer } = useThree()
1061
- * // renderer is typed as THREE.WebGLRenderer
1062
- * renderer.shadowMap.enabled = true
1063
- * }
112
+ * // Explicit dimensions with options
113
+ * const fbo = useRenderTarget(512, 256, { samples: 4 })
1064
114
  * ```
1065
115
  */
1066
- interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1067
- /** The WebGL renderer instance */
1068
- renderer: THREE$1.WebGLRenderer
1069
- /** Internals with WebGL renderer */
1070
- internal: LegacyInternalState
1071
- }
1072
-
1073
- //* RenderTarget Types ==============================
1074
-
1075
-
1076
- type RenderTargetOptions = RenderTargetOptions$1
1077
-
1078
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1079
-
1080
- interface MathRepresentation {
1081
- set(...args: number[]): any
1082
- }
1083
- interface VectorRepresentation extends MathRepresentation {
1084
- setScalar(value: number): any
1085
- }
1086
- type MathTypes = MathRepresentation | Euler$2 | Color$2
1087
-
1088
- type MathType<T extends MathTypes> = T extends Color$2
1089
- ? Args<typeof Color$2> | ColorRepresentation$1
1090
- : T extends VectorRepresentation | Layers$1 | Euler$2
1091
- ? T | MutableOrReadonlyParameters<T['set']> | number
1092
- : T | MutableOrReadonlyParameters<T['set']>
1093
-
1094
- type MathProps<P> = {
1095
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1096
- }
1097
-
1098
- type Vector2 = MathType<Vector2$1>
1099
- type Vector3 = MathType<Vector3$1>
1100
- type Vector4 = MathType<Vector4$1>
1101
- type Color = MathType<Color$2>
1102
- type Layers = MathType<Layers$1>
1103
- type Quaternion = MathType<Quaternion$1>
1104
- type Euler = MathType<Euler$2>
1105
- type Matrix3 = MathType<Matrix3$1>
1106
- type Matrix4 = MathType<Matrix4$1>
1107
-
1108
- interface RaycastableRepresentation {
1109
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1110
- }
1111
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1112
-
1113
- /**
1114
- * Props for geometry transform methods that can be called with `once()`.
1115
- * These methods modify the geometry in-place and only make sense to call once on mount.
1116
- *
1117
- * @example
1118
- * import { once } from '@react-three/fiber'
1119
- *
1120
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1121
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1122
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1123
- */
1124
- interface GeometryTransformProps {
1125
- /** Rotate the geometry about the X axis (radians). Use with once(). */
1126
- rotateX?: number
1127
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
1128
- rotateY?: number
1129
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
1130
- rotateZ?: number
1131
- /** Translate the geometry (x, y, z). Use with once(). */
1132
- translate?: [x: number, y: number, z: number]
1133
- /** Scale the geometry (x, y, z). Use with once(). */
1134
- scale?: [x: number, y: number, z: number]
1135
- /** Center the geometry based on bounding box. Use with once(). */
1136
- center?: true
1137
- /** Apply a Matrix4 transformation. Use with once(). */
1138
- applyMatrix4?: Matrix4$1
1139
- /** Apply a Quaternion rotation. Use with once(). */
1140
- applyQuaternion?: Quaternion$1
1141
- }
1142
-
1143
- type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
116
+ declare function useRenderTarget(options?: RenderTargetOptions): R3FRenderTarget;
117
+ declare function useRenderTarget(size: number, options?: RenderTargetOptions): R3FRenderTarget;
118
+ declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): R3FRenderTarget;
1144
119
 
120
+ declare const R3F_BUILD_LEGACY = true;
121
+ declare const R3F_BUILD_WEBGPU = true;
1145
122
  /**
1146
- * Workaround for @types/three TSL node type issues.
1147
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1148
- * This transforms `Node | null` properties to accept any object with node-like shape.
123
+ * Create a root on a canvas. Renders with WebGL unless `configure({ renderer })` asks for WebGPU.
1149
124
  */
1150
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1151
-
125
+ declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
1152
126
  /**
1153
- * For node material properties (colorNode, positionNode, etc.), accept broader types
1154
- * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1155
- * `nodeType`, so this structural key test remains neutral to the selected Three entry.
127
+ * A DOM canvas which accepts threejs elements as children. Renders with WebGL by default and with
128
+ * WebGPU when given the `renderer` prop.
129
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
1156
130
  */
1157
- type NodeProps<P> = {
1158
- [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1159
- }
1160
-
1161
- interface ReactProps<P> {
1162
- children?: React.ReactNode
1163
- ref?: React.Ref<P>
1164
- key?: React.Key
1165
- }
1166
-
1167
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1168
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1169
- >
1170
-
1171
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1172
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1173
- >
1174
-
1175
- type ThreeToJSXElements<T extends Record<string, any>> = {
1176
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1177
- }
1178
-
1179
- /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1180
- type Object3DMethod = NonNullable<
1181
- {
1182
- [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1183
- }[keyof Object3D]
1184
- >
1185
-
1186
- type ThreeExports = typeof import('three') & typeof import('three/webgpu')
1187
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1188
-
1189
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1190
- /**
1191
- * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1192
- * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1193
- * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1194
- * methods are left out of the typed surface: they return `this`, so a subclass element's
1195
- * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1196
- */
1197
- primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
1198
- object: object
1199
- ref?: React.Ref<any>
1200
- [prop: string]: unknown
1201
- }
1202
- // Conflicts with DOM types can be accessed through a three* prefix
1203
- threeAudio: ThreeElementsImpl['audio']
1204
- threeSource: ThreeElementsImpl['source']
1205
- threeLine: ThreeElementsImpl['line']
1206
- threePath: ThreeElementsImpl['path']
131
+ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
132
+ /** Three.js constructors available as JSX elements on this entry. */
133
+ type ThreeExports = typeof THREE & typeof ThreeWebGPU;
134
+ interface ThreeElements extends ThreeElementsOf$1<ThreeExports> {
1207
135
  }
1208
-
1209
136
  declare module 'react' {
1210
- namespace JSX {
1211
- interface IntrinsicElements extends ThreeElements {}
1212
- }
1213
- }
1214
-
1215
- declare module 'react/jsx-runtime' {
1216
- namespace JSX {
1217
- interface IntrinsicElements extends ThreeElements {}
1218
- }
1219
- }
1220
-
1221
- declare module 'react/jsx-dev-runtime' {
1222
- namespace JSX {
1223
- interface IntrinsicElements extends ThreeElements {}
1224
- }
1225
- }
1226
-
1227
- type three_d_Color = Color;
1228
- type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1229
- type three_d_Euler = Euler;
1230
- type three_d_EventProps<P> = EventProps<P>;
1231
- type three_d_GeometryProps<P> = GeometryProps<P>;
1232
- type three_d_GeometryTransformProps = GeometryTransformProps;
1233
- type three_d_Layers = Layers;
1234
- type three_d_MathProps<P> = MathProps<P>;
1235
- type three_d_MathRepresentation = MathRepresentation;
1236
- type three_d_MathType<T extends MathTypes> = MathType<T>;
1237
- type three_d_MathTypes = MathTypes;
1238
- type three_d_Matrix3 = Matrix3;
1239
- type three_d_Matrix4 = Matrix4;
1240
- type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1241
- type three_d_NodeProps<P> = NodeProps<P>;
1242
- type three_d_Object3DMethod = Object3DMethod;
1243
- type three_d_Quaternion = Quaternion;
1244
- type three_d_RaycastableRepresentation = RaycastableRepresentation;
1245
- type three_d_ReactProps<P> = ReactProps<P>;
1246
- type three_d_TSLNodeInput = TSLNodeInput;
1247
- type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1248
- type three_d_ThreeElements = ThreeElements;
1249
- type three_d_ThreeElementsImpl = ThreeElementsImpl;
1250
- type three_d_ThreeExports = ThreeExports;
1251
- type three_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
1252
- type three_d_Vector2 = Vector2;
1253
- type three_d_Vector3 = Vector3;
1254
- type three_d_Vector4 = Vector4;
1255
- type three_d_VectorRepresentation = VectorRepresentation;
1256
- declare namespace three_d {
1257
- 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 };
137
+ namespace JSX {
138
+ interface IntrinsicElements extends ThreeElements {
139
+ }
140
+ }
1258
141
  }
1259
142
 
1260
- /**
1261
- * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1262
- *
1263
- * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1264
- * a single WebGPURenderer using Three.js CanvasTarget API.
1265
- *
1266
- * Primary canvas: Has `id` prop, creates its own renderer, registers here
1267
- * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1268
- */
1269
-
1270
- interface PrimaryCanvasEntry {
1271
- /** The WebGPURenderer instance owned by this primary canvas */
1272
- renderer: WebGPURenderer;
1273
- /** The zustand store for this canvas */
1274
- store: RootStore;
1275
- }
1276
- /**
1277
- * Register a primary canvas that can be targeted by secondary canvases.
1278
- *
1279
- * @param id - Unique identifier for this primary canvas
1280
- * @param renderer - The WebGPURenderer owned by this canvas
1281
- * @param store - The zustand store for this canvas
1282
- * @returns Cleanup function to unregister on unmount
1283
- */
1284
- declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1285
- /**
1286
- * Get a registered primary canvas by id.
1287
- *
1288
- * @param id - The id of the primary canvas to look up
1289
- * @returns The primary canvas entry or undefined if not found
1290
- */
1291
- declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1292
- /**
1293
- * Wait for a primary canvas to be registered.
1294
- * Returns immediately if already registered, otherwise waits.
1295
- *
1296
- * @param id - The id of the primary canvas to wait for
1297
- * @param timeout - Optional timeout in ms (default: 5000)
1298
- * @returns Promise that resolves with the primary canvas entry
1299
- */
1300
- declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1301
- /**
1302
- * Check if a primary canvas with the given id exists.
1303
- *
1304
- * @param id - The id to check
1305
- * @returns True if a primary canvas with this id is registered
1306
- */
1307
- declare function hasPrimary(id: string): boolean;
1308
- /**
1309
- * Unregister a primary canvas. Called on unmount.
1310
- *
1311
- * @param id - The id of the primary canvas to unregister
1312
- */
1313
- declare function unregisterPrimary(id: string): void;
1314
- /**
1315
- * Get all registered primary canvas ids. Useful for debugging.
1316
- */
1317
- declare function getPrimaryIds(): string[];
1318
-
1319
- type EnvironmentLoaderProps = {
1320
- files?: string | string[];
1321
- path?: string;
1322
- preset?: PresetsType;
1323
- extensions?: (loader: Loader$1) => void;
1324
- colorSpace?: ColorSpace;
1325
- };
1326
- /**
1327
- * Loads environment textures for reflections and lighting.
1328
- * Supports HDR files, presets, and cubemaps.
1329
- *
1330
- * @example Basic usage
1331
- * ```jsx
1332
- * const texture = useEnvironment({ preset: 'sunset' })
1333
- * ```
1334
- */
1335
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1336
- declare namespace useEnvironment {
1337
- var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1338
- var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1339
- }
1340
- /**
1341
- * Options accepted by `useEnvironment.preload`.
1342
- *
1343
- * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1344
- * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1345
- * advertise an option this function silently ignores.
1346
- *
1347
- * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1348
- * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1349
- * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1350
- */
1351
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1352
- type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1353
-
1354
- /**
1355
- * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1356
- *
1357
- * @property children - React children to render into custom environment portal
1358
- * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1359
- * @property near - Near clipping plane for cube camera (default: 0.1)
1360
- * @property far - Far clipping plane for cube camera (default: 1000)
1361
- * @property resolution - Resolution of the cube render target (default: 256)
1362
- * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1363
- *
1364
- * @property blur - @deprecated Use backgroundBlurriness instead
1365
- * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1366
- * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1367
- * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1368
- * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1369
- * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1370
- *
1371
- * @property map - Pre-existing texture to use as environment map
1372
- * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1373
- * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1374
- * @property ground - Ground projection settings. Use true for defaults or object with:
1375
- * - height: Height of camera used to create env map (default: 15)
1376
- * - radius: Radius of the world (default: 60)
1377
- * - scale: Scale of backside projected sphere (default: 1000)
1378
- *
1379
- * Additional loader props:
1380
- * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1381
- * @property path - Base path for file loading
1382
- * @property extensions - Texture extensions override
1383
- */
1384
- type EnvironmentProps = {
1385
- children?: React$1.ReactNode;
1386
- frames?: number;
1387
- near?: number;
1388
- far?: number;
1389
- resolution?: number;
1390
- background?: boolean | 'only';
1391
- /** deprecated, use backgroundBlurriness */
1392
- blur?: number;
1393
- backgroundBlurriness?: number;
1394
- backgroundIntensity?: number;
1395
- backgroundRotation?: Euler;
1396
- environmentIntensity?: number;
1397
- environmentRotation?: Euler;
1398
- map?: Texture$1;
1399
- preset?: PresetsType;
1400
- scene?: Scene | React$1.RefObject<Scene>;
1401
- ground?: boolean | {
1402
- radius?: number;
1403
- height?: number;
1404
- scale?: number;
1405
- };
1406
- /** Solid color for background (alternative to files/preset) */
1407
- color?: ColorRepresentation$1;
1408
- /** Separate files for background (when different from environment files) */
1409
- backgroundFiles?: string | string[];
1410
- } & EnvironmentLoaderProps;
1411
- /**
1412
- * Internal component that applies a pre-existing texture as environment map.
1413
- * Sets scene.environment and optionally scene.background.
1414
- *
1415
- * @example
1416
- * ```jsx
1417
- * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1418
- * ```
1419
- */
1420
- declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1421
- /**
1422
- * Internal component that loads environment textures from files or presets.
1423
- * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1424
- * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1425
- *
1426
- * @example With preset
1427
- * ```jsx
1428
- * <EnvironmentCube preset="sunset" />
1429
- * ```
1430
- *
1431
- * @example From HDR file
1432
- * ```jsx
1433
- * <EnvironmentCube files="environment.hdr" />
1434
- * ```
1435
- *
1436
- * @example From gainmap (smallest footprint)
1437
- * ```jsx
1438
- * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1439
- * ```
1440
- *
1441
- * @example From cube faces
1442
- * ```jsx
1443
- * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1444
- * ```
1445
- */
1446
- declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1447
- /**
1448
- * Internal component that renders custom environment using a portal and cube camera.
1449
- * Renders children into an off-buffer and films with a cube camera to create environment map.
1450
- * Can be static (frames=1) or animated (frames=Infinity).
1451
- *
1452
- * @example Custom environment with sphere
1453
- * ```jsx
1454
- * <EnvironmentPortal background near={1} far={1000} resolution={256}>
1455
- * <mesh scale={100}>
1456
- * <sphereGeometry args={[1, 64, 64]} />
1457
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1458
- * </mesh>
1459
- * </EnvironmentPortal>
1460
- * ```
1461
- *
1462
- * @example Animated environment
1463
- * ```jsx
1464
- * <EnvironmentPortal frames={Infinity} resolution={256}>
1465
- * <Float>
1466
- * <mesh />
1467
- * </Float>
1468
- * </EnvironmentPortal>
1469
- * ```
1470
- *
1471
- * @example Mixed with preset
1472
- * ```jsx
1473
- * <EnvironmentPortal preset="warehouse">
1474
- * <mesh />
1475
- * </EnvironmentPortal>
1476
- * ```
1477
- */
1478
- declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
1479
- declare module '@react-three/fiber' {
1480
- interface ThreeElements {
1481
- groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
1482
- }
1483
- }
1484
- /**
1485
- * Sets up a global environment map for PBR materials and backgrounds.
1486
- * Affects scene.environment and optionally scene.background unless a custom scene is passed.
1487
- *
1488
- * Supports multiple input methods:
1489
- * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1490
- * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
1491
- * - **Texture**: Pre-existing cube texture via `map` prop
1492
- * - **Custom Scene**: Render children into environment using portal and cube camera
1493
- * - **Ground Projection**: Project environment onto ground plane
1494
- *
1495
- * @remarks
1496
- * - Preset property is NOT meant for production and may fail (relies on CDNs)
1497
- * - Gainmap format has the smallest file footprint
1498
- * - Use `frames={Infinity}` for animated environments with low resolution for performance
1499
- * - Ground projection places models on the "ground" within the environment map
1500
- * - Supports self-hosting with @pmndrs/assets using dynamic imports
1501
- *
1502
- * @example Basic preset usage
1503
- * ```jsx
1504
- * <Environment preset="sunset" />
1505
- * ```
1506
- *
1507
- * @example From HDR file
1508
- * ```jsx
1509
- * <Environment files="/hdr/environment.hdr" />
1510
- * ```
1511
- *
1512
- * @example From gainmap (smallest footprint)
1513
- * ```jsx
1514
- * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1515
- * ```
1516
- *
1517
- * @example With self-hosted assets
1518
- * ```jsx
1519
- * import { suspend } from 'suspend-react'
1520
- * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
1521
- *
1522
- * <Environment files={suspend(city)} />
1523
- * ```
1524
- *
1525
- * @example From existing texture
1526
- * ```jsx
1527
- * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
1528
- * ```
1529
- *
1530
- * @example Custom environment scene
1531
- * ```jsx
1532
- * <Environment background near={1} far={1000} resolution={256}>
1533
- * <mesh scale={100}>
1534
- * <sphereGeometry args={[1, 64, 64]} />
1535
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1536
- * </mesh>
1537
- * </Environment>
1538
- * ```
1539
- *
1540
- * @example Animated environment
1541
- * ```jsx
1542
- * <Environment frames={Infinity} resolution={256}>
1543
- * <Float>
1544
- * <mesh />
1545
- * </Float>
1546
- * </Environment>
1547
- * ```
1548
- *
1549
- * @example Mixed custom scene with preset
1550
- * ```jsx
1551
- * <Environment background preset="warehouse">
1552
- * <mesh />
1553
- * </Environment>
1554
- * ```
1555
- *
1556
- * @example With ground projection
1557
- * ```jsx
1558
- * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
1559
- * ```
1560
- *
1561
- * @example As background only
1562
- * ```jsx
1563
- * <Environment background="only" preset="sunset" />
1564
- * ```
1565
- *
1566
- * @example With rotation and intensity
1567
- * ```jsx
1568
- * <Environment
1569
- * background
1570
- * backgroundBlurriness={0.5}
1571
- * backgroundIntensity={0.8}
1572
- * backgroundRotation={[0, Math.PI / 2, 0]}
1573
- * environmentIntensity={1.2}
1574
- * environmentRotation={[0, Math.PI / 4, 0]}
1575
- * preset="studio"
1576
- * />
1577
- * ```
1578
- */
1579
- declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
1580
-
1581
- /**
1582
- * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1583
- *
1584
- * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1585
- * instance. Removing the old object from the interaction state and registering the new one from
1586
- * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1587
- * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1588
- * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1589
- * swap the user never asked to see (#3744).
1590
- *
1591
- * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1592
- * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1593
- *
1594
- * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1595
- * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1596
- * cannot outlive the object it described.
1597
- */
1598
- declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
1599
- declare function removeInteractivity(store: RootStore, object: Object3D): void;
1600
- declare function createEvents(store: RootStore): {
1601
- handlePointer: (name: string) => (event: DomEvent) => void;
1602
- flushDeferredPointers: () => void;
1603
- processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1604
- };
1605
- /** Default R3F event manager for web */
1606
- declare function createPointerEvents(store: RootStore): EventManager<Element>;
1607
-
1608
- interface RootExtension {
1609
- /** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
1610
- * set up are not set up a second time, but get the new entry's dispose and hmr. */
1611
- name: string;
1612
- /**
1613
- * Called once per root, after its renderer exists and before `onCreated` and the first frame.
1614
- * `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
1615
- * to the primary canvas. Return fields to merge into the root's state, or nothing.
1616
- */
1617
- setup?(store: RootStore): Partial<RootState> | void;
1618
- /** Called when a root this extension set up unmounts. */
1619
- dispose?(store: RootStore): void;
1620
- /** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
1621
- hmr?(store: RootStore): void;
1622
- }
1623
- /**
1624
- * Register an extension. It is set up on every live root immediately, and on every root created
1625
- * afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
1626
- * it already set up keep its state and still get its dispose when they unmount.
1627
- */
1628
- declare function registerRootExtension(extension: RootExtension): () => void;
1629
- /**
1630
- * Point a root's default render job at a different render function, or back at
1631
- * `renderer.render(scene, camera)` with `null`.
1632
- *
1633
- * The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
1634
- * boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
1635
- */
1636
- declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
1637
-
1638
- /**
1639
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1640
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1641
- */
1642
- declare function useStore(): RootStore;
1643
- /**
1644
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1645
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1646
- */
1647
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
1648
-
1649
- /**
1650
- * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
1651
- * This allows external code to access loader methods like abort().
1652
- */
1653
- declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
1654
- /**
1655
- * Synchronously loads and caches assets with a three loader.
1656
- *
1657
- * Note: this hook's caller must be wrapped with `React.Suspense`
1658
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1659
- */
1660
- declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
1661
- declare namespace useLoader {
1662
- var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike) => void;
1663
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
1664
- var loader: typeof getLoader;
1665
- }
1666
-
1667
- /**
1668
- * Frame hook with phase-based ordering, priority, and FPS throttling.
1669
- *
1670
- * Always delivers full RootState — works both inside and outside Canvas context:
1671
- * - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
1672
- * - Outside Canvas: The job registers immediately but the callback is held until a
1673
- * Canvas adopts it, then runs with full RootState. For hostless / standalone
1674
- * frame loops with no Canvas, use `@pmndrs/scheduler` directly.
1675
- *
1676
- * Returns a controls object for manual stepping, pausing, and resuming.
1677
- *
1678
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1679
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1680
- * @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
1681
- *
1682
- * @example
1683
- * // Simple priority (backwards compat)
1684
- * useFrame((state, delta) => { ... }, 5)
1685
- *
1686
- * @example
1687
- * // With phase-based ordering
1688
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
1689
- *
1690
- * @example
1691
- * // Outside Canvas - callback waits for a Canvas, then always has full state
1692
- * function UI() {
1693
- * useFrame((state, delta) => { syncUI(state.camera) });
1694
- * return <button>...</button>;
1695
- * }
1696
- *
1697
- * @example
1698
- * // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
1699
- * import { getScheduler } from '@pmndrs/scheduler'
1700
- * getScheduler().register((state, delta) => { updateGame(delta) })
1701
- *
1702
- * @example
1703
- * // Scheduler-only access (no callback)
1704
- * const { scheduler } = useFrame()
1705
- * scheduler.pauseJob('some-job-id')
1706
- *
1707
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1708
- */
1709
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
1710
-
1711
- declare const IsObject: (url: unknown) => url is Record<string, string>;
1712
- type TextureArray<T> = T extends string[] ? Texture$1[] : never;
1713
- type TextureRecord<T> = T extends Record<string, string> ? {
1714
- [key in keyof T]: Texture$1;
1715
- } : never;
1716
- type SingleTexture<T> = T extends string ? Texture$1 : never;
1717
- type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
1718
- /** Options for useTexture hook */
1719
- type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
1720
- /** Callback when texture(s) finish loading */
1721
- onLoad?: (texture: MappedTextureType<Url>) => void;
1722
- /**
1723
- * Register the texture(s) in R3F's global texture registry for access via useTextures().
1724
- * When true (the default):
1725
- * - Textures persist until explicitly disposed
1726
- * - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
1727
- *
1728
- * Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
1729
- * changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
1730
- *
1731
- * Pass `false` to opt out of registry enrollment entirely.
1732
- * @default true
1733
- */
1734
- cache?: boolean;
1735
- };
1736
- /**
1737
- * Load texture(s) using Three's TextureLoader with Suspense support.
1738
- *
1739
- * @param input - URL string, array of URLs, or object mapping keys to URLs
1740
- * @param optionsOrOnLoad - Options object or legacy onLoad callback
1741
- *
1742
- * @example
1743
- * ```tsx
1744
- * // Single texture
1745
- * const diffuse = useTexture('/textures/diffuse.png')
1746
- *
1747
- * // Multiple textures (array)
1748
- * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
1749
- *
1750
- * // Named textures (object)
1751
- * const { diffuse, normal } = useTexture({
1752
- * diffuse: '/diffuse.png',
1753
- * normal: '/normal.png'
1754
- * })
1755
- *
1756
- * // Textures are registered in the global registry by default — the same texture
1757
- * // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
1758
- * const diffuse = useTexture('/diffuse.png')
1759
- * diffuse.colorSpace = THREE.SRGBColorSpace
1760
- *
1761
- * // Another component gets the SAME texture with colorSpace already set
1762
- * const sameDiffuse = useTexture('/diffuse.png')
1763
- *
1764
- * // Opt out of registry enrollment for a one-off texture
1765
- * const scratch = useTexture('/scratch.png', { cache: false })
1766
- *
1767
- * // Access the registry directly
1768
- * const { get } = useTextures()
1769
- * const cached = get('/diffuse.png')
1770
- * ```
1771
- */
1772
- declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
1773
- declare namespace useTexture {
1774
- var preload: (url: string | string[]) => void;
1775
- var clear: (input: string | string[]) => void;
1776
- }
1777
- declare const Texture: ({ children, input, onLoad, cache, }: {
1778
- children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
1779
- input: Parameters<typeof useTexture>[0];
1780
- onLoad?: Parameters<typeof useTexture>[1];
1781
- cache?: boolean;
1782
- }) => react_jsx_runtime.JSX.Element;
1783
-
1784
- /** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
1785
- type TextureInput = string | string[] | Record<string, string>;
1786
- /** Result of a `get()` read, mirroring the input shape. */
1787
- type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
1788
- [K in keyof Input]: Texture$1 | undefined;
1789
- };
1790
- /** Options for `dispose()`. */
1791
- interface DisposeOptions {
1792
- /** Dispose even if the texture still has active references (default false). */
1793
- force?: boolean;
1794
- }
1795
- interface UseTexturesReturn {
1796
- /** The live registry Map (key → Texture). Treat as read-only. */
1797
- readonly all: Map<string, Texture$1>;
1798
- /** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
1799
- get<Input extends TextureInput>(input: Input): TextureResult<Input>;
1800
- /** Check whether a key exists in the registry. */
1801
- has(key: string): boolean;
1802
- /**
1803
- * Register a texture (or a record of textures) that has no URL — e.g. a render
1804
- * target or procedural texture. URL-loaded textures are registered automatically
1805
- * by `useTexture` (registry enrollment is on by default).
1806
- */
1807
- add(key: string, texture: Texture$1): void;
1808
- add(record: Record<string, Texture$1>): void;
1809
- /**
1810
- * Dispose a texture's GPU resources and remove it from the registry.
1811
- * Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
1812
- * skipped (with a warning) unless `{ force: true }` is passed.
1813
- * @returns true if disposed, false if skipped.
1814
- */
1815
- dispose(key: string, options?: DisposeOptions): boolean;
1816
- /** Dispose every texture in the registry and clear it. Use on scene teardown. */
1817
- disposeAll(): void;
1818
- }
1819
- /**
1820
- * Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
1821
- *
1822
- * This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
1823
- * a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
1824
- * `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
1825
- *
1826
- * The returned handle is **reactive**: the calling component re-renders when the registry
1827
- * changes. Pass a selector to scope the subscription to a single read.
1828
- *
1829
- * @example
1830
- * ```tsx
1831
- * // Load + register once (anywhere in the tree) — registered by default
1832
- * useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
1833
- *
1834
- * // Reach them from another component — record form lands straight into a material
1835
- * const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
1836
- * return <meshStandardMaterial map={map} normalMap={normalMap} />
1837
- *
1838
- * // A set of heightmaps at once
1839
- * const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
1840
- *
1841
- * // Register a non-URL texture (render target / procedural)
1842
- * useTextures().add('rt-main', renderTarget.texture)
1843
- *
1844
- * // Deliberate GPU cleanup (refcount-aware; force to override)
1845
- * useTextures().dispose('/diffuse.jpg')
1846
- * useTextures().disposeAll() // scene teardown
1847
- * ```
1848
- *
1849
- * @remarks
1850
- * **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
1851
- * intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
1852
- * populate the registry without Suspense, at the cost of putting loading back into this hook. It
1853
- * will be added only if a concrete consumer needs imperative loading; for now, loading lives in
1854
- * `useTexture`.
1855
- */
1856
- declare function useTextures(): UseTexturesReturn;
1857
- declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
1858
-
1859
- /**
1860
- * Creates a render target compatible with the current renderer.
1861
- *
1862
- * - Legacy build: Returns WebGLRenderTarget
1863
- * - WebGPU build: Returns RenderTarget
1864
- * - Default build: Returns whichever matches the active renderer
1865
- *
1866
- * @example
1867
- * ```tsx
1868
- * // Use canvas size
1869
- * const fbo = useRenderTarget()
1870
- *
1871
- * // Use canvas size with options
1872
- * const fbo = useRenderTarget({ samples: 4 })
1873
- *
1874
- * // Square render target
1875
- * const fbo = useRenderTarget(512)
1876
- *
1877
- * // Square render target with options
1878
- * const fbo = useRenderTarget(512, { depthBuffer: true })
1879
- *
1880
- * // Explicit dimensions
1881
- * const fbo = useRenderTarget(512, 256)
1882
- *
1883
- * // Explicit dimensions with options
1884
- * const fbo = useRenderTarget(512, 256, { samples: 4 })
1885
- * ```
1886
- */
1887
- declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
1888
- declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
1889
- declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
1890
-
1891
- /**
1892
- * Exposes an object's {@link Instance}.
1893
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1894
- *
1895
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1896
- */
1897
- declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
1898
- /**
1899
- * Returns a node graph of an object with named nodes & materials.
1900
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1901
- */
1902
- declare function useGraph(object: Object3D): ObjectMap;
1903
-
1904
- /**
1905
- * Adds a global render callback which is called each frame BEFORE rendering.
1906
- *
1907
- * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
1908
- * This function will be removed in a future version.
1909
- *
1910
- * @param callback - Function called each frame with timestamp
1911
- * @returns Unsubscribe function
1912
- *
1913
- * @example
1914
- * // OLD (deprecated)
1915
- * const unsub = addEffect((timestamp) => { ... })
1916
- *
1917
- * // NEW
1918
- * useFrame((state, delta) => { ... }, { phase: 'start' })
1919
- *
1920
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1921
- */
1922
- declare function addEffect(callback: GlobalRenderCallback): () => void;
1923
- /**
1924
- * Adds a global after-render callback which is called each frame AFTER rendering.
1925
- *
1926
- * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
1927
- * This function will be removed in a future version.
1928
- *
1929
- * @param callback - Function called each frame with timestamp
1930
- * @returns Unsubscribe function
1931
- *
1932
- * @example
1933
- * // OLD (deprecated)
1934
- * const unsub = addAfterEffect((timestamp) => { ... })
1935
- *
1936
- * // NEW
1937
- * useFrame((state, delta) => { ... }, { phase: 'finish' })
1938
- *
1939
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1940
- */
1941
- declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
1942
- /**
1943
- * Adds a global callback which is called when rendering stops.
1944
- *
1945
- * @deprecated Use `scheduler.onIdle(callback)` instead.
1946
- * This function will be removed in a future version.
1947
- *
1948
- * @param callback - Function called when rendering stops
1949
- * @returns Unsubscribe function
1950
- *
1951
- * @example
1952
- * // OLD (deprecated)
1953
- * const unsub = addTail((timestamp) => { ... })
1954
- *
1955
- * // NEW
1956
- * const { scheduler } = useFrame()
1957
- * const unsub = scheduler.onIdle((timestamp) => { ... })
1958
- *
1959
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1960
- */
1961
- declare function addTail(callback: GlobalRenderCallback): () => void;
1962
- /**
1963
- * Invalidates the view, requesting a frame to be rendered.
1964
- * In demand mode, this triggers the scheduler to run frames.
1965
- *
1966
- * With a state argument, only that root's jobs run on the requested frames; other
1967
- * roots on 'demand' stay idle. Without one, every registered root is invalidated.
1968
- *
1969
- * @param state - Optional root state; targets the invalidation at that root
1970
- * @param frames - Number of frames to request (default: 1)
1971
- * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
1972
- *
1973
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1974
- */
1975
- declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
1976
- /**
1977
- * Advances the frameloop and runs render effects.
1978
- * Useful for when manually rendering via `frameloop="never"`.
1979
- *
1980
- * With a state argument, only that root is stepped. Without one, every
1981
- * registered root is stepped for backwards compatibility.
1982
- *
1983
- * @param timestamp - The timestamp to use for this frame
1984
- * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
1985
- * @param state - Optional root state; targets the manual step at that root
1986
- *
1987
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1988
- */
1989
- declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
1990
-
1991
- /* eslint-disable @definitelytyped/no-unnecessary-generics */
1992
- declare function ReactReconciler<
1993
- Type,
1994
- Props,
1995
- Container,
1996
- Instance,
1997
- TextInstance,
1998
- SuspenseInstance,
1999
- HydratableInstance,
2000
- FormInstance,
2001
- PublicInstance,
2002
- HostContext,
2003
- ChildSet,
2004
- TimeoutHandle,
2005
- NoTimeout,
2006
- TransitionStatus,
2007
- >(
2008
- /* eslint-enable @definitelytyped/no-unnecessary-generics */
2009
- config: ReactReconciler.HostConfig<
2010
- Type,
2011
- Props,
2012
- Container,
2013
- Instance,
2014
- TextInstance,
2015
- SuspenseInstance,
2016
- HydratableInstance,
2017
- FormInstance,
2018
- PublicInstance,
2019
- HostContext,
2020
- ChildSet,
2021
- TimeoutHandle,
2022
- NoTimeout,
2023
- TransitionStatus
2024
- >,
2025
- ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
2026
-
2027
- declare namespace ReactReconciler {
2028
- interface HostConfig<
2029
- Type,
2030
- Props,
2031
- Container,
2032
- Instance,
2033
- TextInstance,
2034
- SuspenseInstance,
2035
- HydratableInstance,
2036
- FormInstance,
2037
- PublicInstance,
2038
- HostContext,
2039
- ChildSet,
2040
- TimeoutHandle,
2041
- NoTimeout,
2042
- TransitionStatus,
2043
- > {
2044
- // -------------------
2045
- // Modes
2046
- // -------------------
2047
- /**
2048
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2049
- *
2050
- * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`, and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART, and the classic React Native renderer.
2051
- *
2052
- * ```js
2053
- * const HostConfig = {
2054
- * // ...
2055
- * supportsMutation: true,
2056
- * // ...
2057
- * }
2058
- * ```
2059
- *
2060
- * Depending on the mode, the reconciler will call different methods on your host config.
2061
- *
2062
- * If you're not sure which one you want, you likely need the mutation mode.
2063
- */
2064
- supportsMutation: boolean;
2065
-
2066
- /**
2067
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2068
- *
2069
- * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode, existing nodes are never mutated, and instead every change clones the parent tree and then replaces the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed "Fabric".
2070
- *
2071
- * ```js
2072
- * const HostConfig = {
2073
- * // ...
2074
- * supportsPersistence: true,
2075
- * // ...
2076
- * }
2077
- * ```
2078
- *
2079
- * Depending on the mode, the reconciler will call different methods on your host config.
2080
- *
2081
- * If you're not sure which one you want, you likely need the mutation mode.
2082
- */
2083
- supportsPersistence: boolean;
2084
-
2085
- // -------------------
2086
- // Core Methods
2087
- // -------------------
2088
-
2089
- /**
2090
- * This method should return a newly created node. For example, the DOM renderer would call `document.createElement(type)` here and then set the properties from `props`.
2091
- *
2092
- * You can use `rootContainer` to access the root container associated with that tree. For example, in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.
2093
- *
2094
- * The `hostContext` parameter lets you keep track of some information about your current place in the tree. To learn more about it, see `getChildHostContext` below.
2095
- *
2096
- * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
2097
- *
2098
- * This method happens **in the render phase**. It can (and usually should) mutate the node it has just created before returning it, but it must not modify any other nodes. It must not register any event handlers on the parent tree. This is because an instance being created doesn't guarantee it would be placed in the tree — it could be left unused and later collected by GC. If you need to do something when an instance is definitely in the tree, look at `commitMount` instead.
2099
- */
2100
- createInstance(
2101
- type: Type,
2102
- props: Props,
2103
- rootContainer: Container,
2104
- hostContext: HostContext,
2105
- internalHandle: OpaqueHandle,
2106
- ): Instance;
2107
-
2108
- /**
2109
- * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
2110
- */
2111
- createTextInstance(
2112
- text: string,
2113
- rootContainer: Container,
2114
- hostContext: HostContext,
2115
- internalHandle: OpaqueHandle,
2116
- ): TextInstance;
2117
-
2118
- /**
2119
- * This method should mutate the `parentInstance` and add the child to its list of children. For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.
2120
- *
2121
- * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it must not modify any other nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.
2122
- */
2123
- appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
2124
-
2125
- /**
2126
- * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`, by the time `finalizeInitialChildren` is called, all the initial children have already been added to the `instance`, but the instance itself has not yet been connected to the tree on the screen.
2127
- *
2128
- * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.
2129
- *
2130
- * There is a second purpose to this method. It lets you specify whether there is some work that needs to happen when the node is connected to the tree on the screen. If you return `true`, the instance will receive a `commitMount` call later. See its documentation below.
2131
- *
2132
- * If you don't want to do anything here, you should return `false`.
2133
- */
2134
- finalizeInitialChildren(
2135
- instance: Instance,
2136
- type: Type,
2137
- props: Props,
2138
- rootContainer: Container,
2139
- hostContext: HostContext,
2140
- ): boolean;
2141
-
2142
- /**
2143
- * Some target platforms support setting an instance's text content without manually creating a text node. For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.
2144
- *
2145
- * If you return `true` from this method, React will assume that this node's children are text, and will not create nodes for them. It will instead rely on you to have filled that text during `createInstance`. This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`, you will need to implement `resetTextContent` too.
2146
- *
2147
- * If you don't want to do anything here, you should return `false`.
2148
- *
2149
- * This method happens **in the render phase**. Do not mutate the tree from it.
2150
- */
2151
- shouldSetTextContent(type: Type, props: Props): boolean;
2152
-
2153
- /**
2154
- * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
2155
- *
2156
- * If you don't intend to use host context, you can return `null`.
2157
- *
2158
- * This method happens **in the render phase**. Do not mutate the tree from it.
2159
- */
2160
- getRootHostContext(rootContainer: Container): HostContext | null;
2161
-
2162
- /**
2163
- * Host context lets you track some information about where you are in the tree so that it's available inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be different for them.
2164
- *
2165
- * If the node of this `type` does not influence the context you want to pass down, you can return `parentHostContext`. Alternatively, you can return any custom object representing the information you want to pass down.
2166
- *
2167
- * If you don't want to do anything here, return `parentHostContext`.
2168
- *
2169
- * This method happens **in the render phase**. Do not mutate the tree from it.
2170
- */
2171
- getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
2172
-
2173
- /**
2174
- * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But in some cases it might make sense to only expose some part of it.
2175
- *
2176
- * If you don't want to do anything here, return `instance`.
2177
- */
2178
- getPublicInstance(instance: Instance | TextInstance): PublicInstance;
2179
-
2180
- /**
2181
- * This method lets you store some information before React starts making changes to the tree on the screen. For example, the DOM renderer stores the current text selection so that it can later restore it. This method is mirrored by `resetAfterCommit`.
2182
- *
2183
- * Even if you don't want to do anything here, you need to return `null` from it.
2184
- */
2185
- prepareForCommit(containerInfo: Container): Record<string, any> | null;
2186
-
2187
- /**
2188
- * This method is called right after React has performed the tree mutations. You can use it to restore something you've stored in `prepareForCommit` — for example, text selection.
2189
- *
2190
- * You can leave it empty.
2191
- */
2192
- resetAfterCommit(containerInfo: Container): void;
2193
-
2194
- /**
2195
- * This method is called for a container that's used as a portal target. Usually you can leave it empty.
2196
- */
2197
- preparePortalMount(containerInfo: Container): void;
2198
-
2199
- /**
2200
- * You can proxy this to `setTimeout` or its equivalent in your environment.
2201
- */
2202
- scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
2203
-
2204
- /**
2205
- * You can proxy this to `clearTimeout` or its equivalent in your environment.
2206
- */
2207
- cancelTimeout(id: TimeoutHandle): void;
2208
-
2209
- /**
2210
- * This is a property (not a function) that should be set to something that can never be a valid timeout ID. For example, you can set it to `-1`.
2211
- */
2212
- noTimeout: NoTimeout;
2213
-
2214
- /**
2215
- * Set this to true to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism.
2216
- */
2217
- supportsMicrotasks?: boolean;
2218
-
2219
- /**
2220
- * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
2221
- */
2222
- scheduleMicrotask?(fn: () => unknown): void;
2223
-
2224
- /**
2225
- * This is a property (not a function) that should be set to `true` if your renderer is the main one on the page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.
2226
- */
2227
- isPrimaryRenderer: boolean;
2228
-
2229
- /**
2230
- * Whether the renderer shouldn't trigger missing `act()` warnings
2231
- */
2232
- warnsIfNotActing?: boolean;
2233
-
2234
- getInstanceFromNode(node: any): Fiber | null | undefined;
2235
-
2236
- beforeActiveInstanceBlur(): void;
2237
-
2238
- afterActiveInstanceBlur(): void;
2239
-
2240
- prepareScopeUpdate(scopeInstance: any, instance: any): void;
2241
-
2242
- getInstanceFromScope(scopeInstance: any): null | Instance;
2243
-
2244
- detachDeletedInstance(node: Instance): void;
2245
-
2246
- // -------------------
2247
- // Mutation Methods
2248
- // (optional)
2249
- // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
2250
- // -------------------
2251
-
2252
- /**
2253
- * This method should mutate the `parentInstance` and add the child to its list of children. For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.
2254
- *
2255
- * Although this method currently runs in the commit phase, you still should not mutate any other nodes in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.
2256
- */
2257
- appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
2258
-
2259
- /**
2260
- * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
2261
- */
2262
- appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
2263
-
2264
- /**
2265
- * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.
2266
- *
2267
- * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.
2268
- */
2269
- insertBefore?(
2270
- parentInstance: Instance,
2271
- child: Instance | TextInstance,
2272
- beforeChild: Instance | TextInstance | SuspenseInstance,
2273
- ): void;
2274
-
2275
- /**
2276
- * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
2277
- */
2278
- insertInContainerBefore?(
2279
- container: Container,
2280
- child: Instance | TextInstance,
2281
- beforeChild: Instance | TextInstance | SuspenseInstance,
2282
- ): void;
2283
-
2284
- /**
2285
- * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
2286
- *
2287
- * React will only call it for the top-level node that is being removed. It is expected that garbage collection would take care of the whole subtree. You are not expected to traverse the child tree in it.
2288
- */
2289
- removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
2290
-
2291
- /**
2292
- * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
2293
- */
2294
- removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
2295
-
2296
- /**
2297
- * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from `shouldSetTextContent` for the next props, React will call this method so that you can clear the text content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.
2298
- *
2299
- * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
2300
- */
2301
- resetTextContent?(instance: Instance): void;
2302
-
2303
- /**
2304
- * This method should mutate the `textInstance` and update its text content to `nextText`.
2305
- *
2306
- * Here, `textInstance` is a node created by `createTextInstance`.
2307
- */
2308
- commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
2309
-
2310
- /**
2311
- * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
2312
- *
2313
- * It lets you do some additional work after the node is actually attached to the tree on the screen for the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.
2314
- *
2315
- * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the `instance` itself. For example, if it registers some events on some node above, it will be your responsibility to traverse the tree in `removeChild` and clean them up, which is not ideal.
2316
- *
2317
- * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
2318
- *
2319
- * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
2320
- */
2321
- commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
2322
-
2323
- /**
2324
- * This method should mutate the instance to match nextProps.
2325
- *
2326
- * The internalHandle data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
2327
- */
2328
- commitUpdate?(
2329
- instance: Instance,
2330
- type: Type,
2331
- prevProps: Props,
2332
- nextProps: Props,
2333
- internalHandle: OpaqueHandle,
2334
- ): void;
2335
-
2336
- /**
2337
- * This method should make the `instance` invisible without removing it from the tree. For example, it can apply visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.
2338
- */
2339
- hideInstance?(instance: Instance): void;
2340
-
2341
- /**
2342
- * Same as `hideInstance`, but for nodes created by `createTextInstance`.
2343
- */
2344
- hideTextInstance?(textInstance: TextInstance): void;
2345
-
2346
- /**
2347
- * This method should make the `instance` visible, undoing what `hideInstance` did.
2348
- */
2349
- unhideInstance?(instance: Instance, props: Props): void;
2350
-
2351
- /**
2352
- * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
2353
- */
2354
- unhideTextInstance?(textInstance: TextInstance, text: string): void;
2355
-
2356
- /**
2357
- * This method should mutate the `container` root node and remove all children from it.
2358
- */
2359
- clearContainer?(container: Container): void;
2360
-
2361
- // -------------------
2362
- // Persistence Methods
2363
- // (optional)
2364
- // If you use the persistent mode instead of the mutation mode, you would still need the "Core Methods". However, instead of the Mutation Methods above you will implement a different set of methods that performs cloning nodes and replacing them at the root level. You can find a list of them in the "Persistence" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help.
2365
- // -------------------
2366
- cloneInstance?(
2367
- instance: Instance,
2368
- type: Type,
2369
- oldProps: Props,
2370
- newProps: Props,
2371
- keepChildren: boolean,
2372
- recyclableInstance: null | Instance,
2373
- ): Instance;
2374
- createContainerChildSet?(container: Container): ChildSet;
2375
- appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
2376
- finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
2377
- replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
2378
- cloneHiddenInstance?(
2379
- instance: Instance,
2380
- type: Type,
2381
- props: Props,
2382
- internalInstanceHandle: OpaqueHandle,
2383
- ): Instance;
2384
- cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
2385
-
2386
- // -------------------
2387
- // Hydration Methods
2388
- // (optional)
2389
- // You can optionally implement hydration to "attach" to the existing tree during the initial render instead of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.
2390
- //
2391
- // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help.
2392
- // -------------------
2393
- supportsHydration: boolean;
2394
-
2395
- canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
2396
-
2397
- canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
2398
-
2399
- canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
2400
-
2401
- isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
2402
-
2403
- isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
2404
-
2405
- registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
2406
-
2407
- getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
2408
-
2409
- getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
2410
-
2411
- hydrateInstance?(
2412
- instance: Instance,
2413
- type: Type,
2414
- props: Props,
2415
- rootContainerInstance: Container,
2416
- hostContext: HostContext,
2417
- internalInstanceHandle: any,
2418
- ): null | any[];
2419
-
2420
- hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
2421
-
2422
- hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
2423
-
2424
- getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
2425
-
2426
- // Returns the SuspenseInstance if this node is a direct child of a
2427
- // SuspenseInstance. I.e. if its previous sibling is a Comment with
2428
- // SUSPENSE_x_START_DATA. Otherwise, null.
2429
- getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
2430
-
2431
- commitHydratedContainer?(container: Container): void;
2432
-
2433
- commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
2434
-
2435
- didNotMatchHydratedContainerTextInstance?(
2436
- parentContainer: Container,
2437
- textInstance: TextInstance,
2438
- text: string,
2439
- ): void;
2440
-
2441
- didNotMatchHydratedTextInstance?(
2442
- parentType: Type,
2443
- parentProps: Props,
2444
- parentInstance: Instance,
2445
- textInstance: TextInstance,
2446
- text: string,
2447
- ): void;
2448
-
2449
- didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
2450
-
2451
- didNotHydrateInstance?(
2452
- parentType: Type,
2453
- parentProps: Props,
2454
- parentInstance: Instance,
2455
- instance: HydratableInstance,
2456
- ): void;
2457
-
2458
- didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
2459
-
2460
- didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
2461
-
2462
- didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
2463
-
2464
- didNotFindHydratableInstance?(
2465
- parentType: Type,
2466
- parentProps: Props,
2467
- parentInstance: Instance,
2468
- type: Type,
2469
- props: Props,
2470
- ): void;
2471
-
2472
- didNotFindHydratableTextInstance?(
2473
- parentType: Type,
2474
- parentProps: Props,
2475
- parentInstance: Instance,
2476
- text: string,
2477
- ): void;
2478
-
2479
- didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
2480
-
2481
- errorHydratingContainer?(parentContainer: Container): void;
2482
-
2483
- // Undocumented
2484
- // https://github.com/facebook/react/pull/26722
2485
- NotPendingTransition: TransitionStatus | null;
2486
- HostTransitionContext: ReactContext<TransitionStatus>;
2487
-
2488
- // https://github.com/facebook/react/pull/28751
2489
- setCurrentUpdatePriority(newPriority: EventPriority): void;
2490
- getCurrentUpdatePriority(): EventPriority;
2491
- resolveUpdatePriority(): EventPriority;
2492
-
2493
- // https://github.com/facebook/react/pull/28804
2494
- resetFormInstance(form: FormInstance): void;
2495
-
2496
- // https://github.com/facebook/react/pull/25105
2497
- requestPostPaintCallback(callback: (time: number) => void): void;
2498
-
2499
- // https://github.com/facebook/react/pull/26025
2500
- shouldAttemptEagerTransition(): boolean;
2501
-
2502
- // https://github.com/facebook/react/pull/31528
2503
- trackSchedulerEvent(): void;
2504
-
2505
- // https://github.com/facebook/react/pull/31008
2506
- resolveEventType(): null | string;
2507
- resolveEventTimeStamp(): number;
2508
-
2509
- /**
2510
- * This method is called during render to determine if the Host Component type and props require some kind of loading process to complete before committing an update.
2511
- */
2512
- maySuspendCommit(type: Type, props: Props): boolean;
2513
-
2514
- /**
2515
- * This method may be called during render if the Host Component type and props might suspend a commit. It can be used to initiate any work that might shorten the duration of a suspended commit.
2516
- */
2517
- preloadInstance(type: Type, props: Props): boolean;
2518
-
2519
- /**
2520
- * This method is called just before the commit phase. Use it to set up any necessary state while any Host Components that might suspend this commit are evaluated to determine if the commit must be suspended.
2521
- */
2522
- startSuspendingCommit(): void;
2523
-
2524
- /**
2525
- * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
2526
- */
2527
- suspendInstance(type: Type, props: Props): void;
2528
-
2529
- /**
2530
- * This method is called after all `suspendInstance` calls are complete.
2531
- *
2532
- * Return `null` if the commit can happen immediately.
2533
- *
2534
- * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this callback will initiate the commit when called. The return value is a cancellation function that the Reconciler can use to abort the commit.
2535
- */
2536
- waitForCommitToBeReady():
2537
- | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
2538
- | null;
2539
- }
2540
-
2541
- interface Thenable<T> {
2542
- then(resolve: () => T, reject?: () => T): T;
2543
- }
2544
-
2545
- type RootTag = 0 | 1 | 2;
2546
-
2547
- type WorkTag =
2548
- | 0
2549
- | 1
2550
- | 2
2551
- | 3
2552
- | 4
2553
- | 5
2554
- | 6
2555
- | 7
2556
- | 8
2557
- | 9
2558
- | 10
2559
- | 11
2560
- | 12
2561
- | 13
2562
- | 14
2563
- | 15
2564
- | 16
2565
- | 17
2566
- | 18
2567
- | 19
2568
- | 20
2569
- | 21
2570
- | 22
2571
- | 23
2572
- | 24;
2573
-
2574
- type HookType =
2575
- | "useState"
2576
- | "useReducer"
2577
- | "useContext"
2578
- | "useRef"
2579
- | "useEffect"
2580
- | "useLayoutEffect"
2581
- | "useCallback"
2582
- | "useMemo"
2583
- | "useImperativeHandle"
2584
- | "useDebugValue"
2585
- | "useDeferredValue"
2586
- | "useTransition"
2587
- | "useMutableSource"
2588
- | "useOpaqueIdentifier"
2589
- | "useCacheRefresh";
2590
-
2591
- interface Source {
2592
- fileName: string;
2593
- lineNumber: number;
2594
- }
2595
-
2596
- // TODO: Ideally these types would be opaque but that doesn't work well with
2597
- // our reconciler fork infra, since these leak into non-reconciler packages.
2598
- type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
2599
-
2600
- type Lanes = number;
2601
- type Lane = number;
2602
-
2603
- type Flags = number;
2604
-
2605
- type TypeOfMode = number;
2606
-
2607
- type EventPriority = number;
2608
-
2609
- interface ReactProvider<T> {
2610
- $$typeof: symbol | number;
2611
- type: ReactProviderType<T>;
2612
- key: null | string;
2613
- ref: null;
2614
- props: {
2615
- value: T;
2616
- children?: ReactNode;
2617
- };
2618
- }
2619
-
2620
- interface ReactProviderType<T> {
2621
- $$typeof: symbol | number;
2622
- _context: ReactContext<T>;
2623
- }
2624
-
2625
- interface ReactConsumer<T> {
2626
- $$typeof: symbol | number;
2627
- type: ReactContext<T>;
2628
- key: null | string;
2629
- ref: null;
2630
- props: {
2631
- children: (value: T) => ReactNode;
2632
- unstable_observedBits?: number;
2633
- };
2634
- }
2635
-
2636
- interface ReactContext<T> {
2637
- $$typeof: symbol | number;
2638
- Consumer: ReactContext<T>;
2639
- Provider: ReactProviderType<T>;
2640
- _currentValue: T;
2641
- _currentValue2: T;
2642
- _threadCount: number;
2643
- // DEV only
2644
- _currentRenderer?: {
2645
- [key: string]: any;
2646
- } | null;
2647
- _currentRenderer2?: {
2648
- [key: string]: any;
2649
- } | null;
2650
- // This value may be added by application code
2651
- // to improve DEV tooling display names
2652
- displayName?: string;
2653
- }
2654
-
2655
- interface ReactPortal {
2656
- $$typeof: symbol | number;
2657
- key: null | string;
2658
- containerInfo: any;
2659
- children: ReactNode;
2660
- // TODO: figure out the API for cross-renderer implementation.
2661
- implementation: any;
2662
- }
2663
-
2664
- interface RefObject {
2665
- current: any;
2666
- }
2667
-
2668
- interface ContextDependency<T> {
2669
- context: ReactContext<T>;
2670
- observedBits: number;
2671
- next: ContextDependency<unknown> | null;
2672
- }
2673
-
2674
- interface Dependencies {
2675
- lanes: Lanes;
2676
- firstContext: ContextDependency<unknown> | null;
2677
- }
2678
-
2679
- interface Fiber {
2680
- // These first fields are conceptually members of an Instance. This used to
2681
- // be split into a separate type and intersected with the other Fiber fields,
2682
- // but until Flow fixes its intersection bugs, we've merged them into a
2683
- // single type.
2684
-
2685
- // An Instance is shared between all versions of a component. We can easily
2686
- // break this out into a separate object to avoid copying so much to the
2687
- // alternate versions of the tree. We put this on a single object for now to
2688
- // minimize the number of objects created during the initial render.
2689
-
2690
- // Tag identifying the type of fiber.
2691
- tag: WorkTag;
2692
-
2693
- // Unique identifier of this child.
2694
- key: null | string;
2695
-
2696
- // The value of element.type which is used to preserve the identity during
2697
- // reconciliation of this child.
2698
- elementType: any;
2699
-
2700
- // The resolved function/class/ associated with this fiber.
2701
- type: any;
2702
-
2703
- // The local state associated with this fiber.
2704
- stateNode: any;
2705
-
2706
- // Conceptual aliases
2707
- // parent : Instance -> return The parent happens to be the same as the
2708
- // return fiber since we've merged the fiber and instance.
2709
-
2710
- // Remaining fields belong to Fiber
2711
-
2712
- // The Fiber to return to after finishing processing this one.
2713
- // This is effectively the parent, but there can be multiple parents (two)
2714
- // so this is only the parent of the thing we're currently processing.
2715
- // It is conceptually the same as the return address of a stack frame.
2716
- return: Fiber | null;
2717
-
2718
- // Singly Linked List Tree Structure.
2719
- child: Fiber | null;
2720
- sibling: Fiber | null;
2721
- index: number;
2722
-
2723
- // The ref last used to attach this node.
2724
- // I'll avoid adding an owner field for prod and model that as functions.
2725
- ref:
2726
- | null
2727
- | (((handle: unknown) => void) & {
2728
- _stringRef?: string | null;
2729
- })
2730
- | RefObject;
2731
-
2732
- // Input is the data coming into process this fiber. Arguments. Props.
2733
- pendingProps: any; // This type will be more specific once we overload the tag.
2734
- memoizedProps: any; // The props used to create the output.
2735
-
2736
- // A queue of state updates and callbacks.
2737
- updateQueue: unknown;
2738
-
2739
- // The state used to create the output
2740
- memoizedState: any;
2741
-
2742
- // Dependencies (contexts, events) for this fiber, if it has any
2743
- dependencies: Dependencies | null;
2744
-
2745
- // Bitfield that describes properties about the fiber and its subtree. E.g.
2746
- // the ConcurrentMode flag indicates whether the subtree should be async-by-
2747
- // default. When a fiber is created, it inherits the mode of its
2748
- // parent. Additional flags can be set at creation time, but after that the
2749
- // value should remain unchanged throughout the fiber's lifetime, particularly
2750
- // before its child fibers are created.
2751
- mode: TypeOfMode;
2752
-
2753
- // Effect
2754
- flags: Flags;
2755
- subtreeFlags: Flags;
2756
- deletions: Fiber[] | null;
2757
-
2758
- // Singly linked list fast path to the next fiber with side-effects.
2759
- nextEffect: Fiber | null;
2760
-
2761
- // The first and last fiber with side-effect within this subtree. This allows
2762
- // us to reuse a slice of the linked list when we reuse the work done within
2763
- // this fiber.
2764
- firstEffect: Fiber | null;
2765
- lastEffect: Fiber | null;
2766
-
2767
- lanes: Lanes;
2768
- childLanes: Lanes;
2769
-
2770
- // This is a pooled version of a Fiber. Every fiber that gets updated will
2771
- // eventually have a pair. There are cases when we can clean up pairs to save
2772
- // memory if we need to.
2773
- alternate: Fiber | null;
2774
-
2775
- // Time spent rendering this Fiber and its descendants for the current update.
2776
- // This tells us how well the tree makes use of sCU for memoization.
2777
- // It is reset to 0 each time we render and only updated when we don't bailout.
2778
- // This field is only set when the enableProfilerTimer flag is enabled.
2779
- actualDuration?: number;
2780
-
2781
- // If the Fiber is currently active in the "render" phase,
2782
- // This marks the time at which the work began.
2783
- // This field is only set when the enableProfilerTimer flag is enabled.
2784
- actualStartTime?: number;
2785
-
2786
- // Duration of the most recent render time for this Fiber.
2787
- // This value is not updated when we bailout for memoization purposes.
2788
- // This field is only set when the enableProfilerTimer flag is enabled.
2789
- selfBaseDuration?: number;
2790
-
2791
- // Sum of base times for all descendants of this Fiber.
2792
- // This value bubbles up during the "complete" phase.
2793
- // This field is only set when the enableProfilerTimer flag is enabled.
2794
- treeBaseDuration?: number;
2795
-
2796
- // Conceptual aliases
2797
- // workInProgress : Fiber -> alternate The alternate used for reuse happens
2798
- // to be the same as work in progress.
2799
- // __DEV__ only
2800
- _debugID?: number;
2801
- _debugSource?: Source | null;
2802
- _debugOwner?: Fiber | null;
2803
- _debugIsCurrentlyTiming?: boolean;
2804
- _debugNeedsRemount?: boolean;
2805
-
2806
- // Used to verify that the order of hooks does not change between renders.
2807
- _debugHookTypes?: HookType[] | null;
2808
- }
2809
-
2810
- type FiberRoot = any;
2811
-
2812
- // Concurrent related struct
2813
- type MutableSource = any;
2814
-
2815
- type OpaqueHandle = any;
2816
- type OpaqueRoot = any;
2817
-
2818
- // 0 is PROD, 1 is DEV.
2819
- // Might add PROFILE later.
2820
- type BundleType = 0 | 1;
2821
-
2822
- interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
2823
- bundleType: BundleType;
2824
- version: string;
2825
- rendererPackageName: string;
2826
- // Note: this actually *does* depend on Fiber internal fields.
2827
- // Used by "inspect clicked DOM element" in React DevTools.
2828
- findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
2829
- rendererConfig?: RendererInspectionConfig;
2830
- }
2831
-
2832
- interface SuspenseHydrationCallbacks<SuspenseInstance> {
2833
- onHydrated?: (suspenseInstance: SuspenseInstance) => void;
2834
- onDeleted?: (suspenseInstance: SuspenseInstance) => void;
2835
- }
2836
-
2837
- interface TransitionTracingCallbacks {
2838
- onTransitionStart?: (transitionName: string, startTime: number) => void;
2839
- onTransitionProgress?: (
2840
- transitionName: string,
2841
- startTime: number,
2842
- currentTime: number,
2843
- pending: Array<{ name: null | string }>,
2844
- ) => void;
2845
- onTransitionIncomplete?: (
2846
- transitionName: string,
2847
- startTime: number,
2848
- deletions: Array<{
2849
- type: string;
2850
- name?: string;
2851
- newName?: string;
2852
- endTime: number;
2853
- }>,
2854
- ) => void;
2855
- onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
2856
- onMarkerProgress?: (
2857
- transitionName: string,
2858
- marker: string,
2859
- startTime: number,
2860
- currentTime: number,
2861
- pending: Array<{ name: null | string }>,
2862
- ) => void;
2863
- onMarkerIncomplete?: (
2864
- transitionName: string,
2865
- marker: string,
2866
- startTime: number,
2867
- deletions: Array<{
2868
- type: string;
2869
- name?: string;
2870
- newName?: string;
2871
- endTime: number;
2872
- }>,
2873
- ) => void;
2874
- onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
2875
- }
2876
-
2877
- interface ComponentSelector {
2878
- $$typeof: symbol | number;
2879
- value: React$AbstractComponent<never, unknown>;
2880
- }
2881
-
2882
- interface HasPseudoClassSelector {
2883
- $$typeof: symbol | number;
2884
- value: Selector[];
2885
- }
2886
-
2887
- interface RoleSelector {
2888
- $$typeof: symbol | number;
2889
- value: string;
2890
- }
2891
-
2892
- interface TextSelector {
2893
- $$typeof: symbol | number;
2894
- value: string;
2895
- }
2896
-
2897
- interface TestNameSelector {
2898
- $$typeof: symbol | number;
2899
- value: string;
2900
- }
2901
-
2902
- type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
2903
-
2904
- // TODO can not find React$AbstractComponent def
2905
- type React$AbstractComponent<Config, Instance = any> = any;
2906
-
2907
- interface BoundingRect {
2908
- x: number;
2909
- y: number;
2910
- width: number;
2911
- height: number;
2912
- }
2913
-
2914
- type IntersectionObserverOptions = any;
2915
-
2916
- interface BaseErrorInfo {
2917
- componentStack?: string;
2918
- }
2919
-
2920
- interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
2921
- createContainer(
2922
- containerInfo: Container,
2923
- tag: RootTag,
2924
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
2925
- isStrictMode: boolean,
2926
- concurrentUpdatesByDefaultOverride: null | boolean,
2927
- identifierPrefix: string,
2928
- onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
2929
- onCaughtError: (error: Error, info: BaseErrorInfo) => void,
2930
- onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
2931
- onDefaultTransitionIndicator: () => void,
2932
- transitionCallbacks: null | TransitionTracingCallbacks,
2933
- ): OpaqueRoot;
2934
-
2935
- createPortal(
2936
- children: ReactNode,
2937
- containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
2938
- implementation: any,
2939
- key?: string | null,
2940
- ): ReactPortal;
2941
-
2942
- registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
2943
-
2944
- createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
2945
-
2946
- createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
2947
-
2948
- createRoleSelector(role: string): RoleSelector;
2949
-
2950
- createTextSelector(text: string): TextSelector;
2951
-
2952
- createTestNameSelector(id: string): TestNameSelector;
2953
-
2954
- getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
2955
-
2956
- findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
2957
-
2958
- findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
2959
-
2960
- focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
2961
-
2962
- observeVisibleRects(
2963
- hostRoot: Instance,
2964
- selectors: Selector[],
2965
- callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
2966
- options?: IntersectionObserverOptions,
2967
- ): { disconnect: () => void };
2968
-
2969
- createHydrationContainer(
2970
- initialChildren: ReactNode,
2971
- callback: (() => void) | null | undefined,
2972
- containerInfo: Container,
2973
- tag: RootTag,
2974
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
2975
- isStrictMode: boolean,
2976
- concurrentUpdatesByDefaultOverride: null | boolean,
2977
- identifierPrefix: string,
2978
- onRecoverableError: (error: Error) => void,
2979
- transitionCallbacks: null | TransitionTracingCallbacks,
2980
- ): OpaqueRoot;
2981
-
2982
- updateContainer(
2983
- element: ReactNode,
2984
- container: OpaqueRoot,
2985
- parentComponent?: Component<any, any> | null,
2986
- callback?: (() => void) | null,
2987
- ): Lane;
2988
-
2989
- batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
2990
-
2991
- deferredUpdates<A>(fn: () => A): A;
2992
-
2993
- discreteUpdates<A, B, C, D, R>(fn: (arg0: A, arg1: B, arg2: C, arg3: D) => R, a: A, b: B, c: C, d: D): R;
2994
-
2995
- flushControlled(fn: () => any): void;
2996
-
2997
- flushSync(): void;
2998
- flushSync<R>(fn: () => R): R;
2999
-
3000
- isAlreadyRendering(): boolean;
3001
-
3002
- flushPassiveEffects(): boolean;
3003
-
3004
- getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
3005
-
3006
- attemptSynchronousHydration(fiber: Fiber): void;
3007
-
3008
- attemptDiscreteHydration(fiber: Fiber): void;
3009
-
3010
- attemptContinuousHydration(fiber: Fiber): void;
3011
-
3012
- attemptHydrationAtCurrentPriority(fiber: Fiber): void;
3013
-
3014
- getCurrentUpdatePriority(): LanePriority;
3015
-
3016
- runWithPriority<T>(priority: LanePriority, fn: () => T): T;
3017
-
3018
- findHostInstance(component: any): PublicInstance | null;
3019
-
3020
- findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
3021
-
3022
- findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
3023
-
3024
- shouldError(fiber: Fiber): boolean | undefined;
3025
-
3026
- shouldSuspend(fiber: Fiber): boolean;
3027
-
3028
- injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
3029
- }
3030
- }
3031
-
3032
- declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3033
- declare function extend<T extends Catalogue>(objects: T): void;
3034
- declare function extend(objects: Record<string, unknown>): void;
3035
- declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3036
-
3037
- declare const isRenderer: (def: any) => boolean;
3038
- interface OffscreenCanvas extends EventTarget {
3039
- }
3040
- declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3041
- declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3042
- declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3043
- declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3044
- interface PortalProps {
3045
- children: ReactNode;
3046
- state?: InjectState;
3047
- container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3048
- }
3049
- declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3050
- /**
3051
- * Force React to flush any updates inside the provided callback synchronously and immediately.
3052
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
3053
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
3054
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
3055
- */
3056
- declare function flushSync<R>(fn: () => R): R;
3057
-
3058
- declare const context: React$1.Context<RootStore>;
3059
-
3060
- declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3061
-
3062
- /**
3063
- * An SSR-friendly useLayoutEffect.
3064
- *
3065
- * React currently throws a warning when using useLayoutEffect on the server.
3066
- * To get around it, we can conditionally useEffect on the server (no-op) and
3067
- * useLayoutEffect elsewhere.
3068
- *
3069
- * @see https://github.com/facebook/react/issues/14927
3070
- */
3071
- declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
3072
- /**
3073
- * Creates a stable ref that always contains the latest callback.
3074
- * Useful for avoiding dependency arrays while ensuring the latest closure is called.
3075
- *
3076
- * @param fn - The callback function to wrap
3077
- * @returns A ref containing the current callback
3078
- */
3079
- declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
3080
- /**
3081
- * Bridges renderer Context and StrictMode from a primary renderer.
3082
- * Used to maintain React context when rendering into portals or secondary canvases.
3083
- *
3084
- * @returns A Bridge component that wraps children with the parent renderer's context
3085
- */
3086
- declare function useBridge(): Bridge;
3087
- /**
3088
- * Internal component that blocks rendering until a promise resolves.
3089
- * Used for suspense-like blocking behavior.
3090
- *
3091
- * @param set - Function to set the blocking promise
3092
- */
3093
- declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
3094
- /**
3095
- * Error boundary component for catching and handling errors in the React tree.
3096
- * Forwards errors to a state setter for external handling.
3097
- *
3098
- * NOTE: static members get down-level transpiled to mutations which break tree-shaking
3099
- */
3100
- declare const ErrorBoundary: {
3101
- new (props: {
3102
- set: React$1.Dispatch<Error | undefined>;
3103
- children: React$1.ReactNode;
3104
- }): {
3105
- state: {
3106
- error: boolean;
3107
- };
3108
- componentDidCatch(err: Error): void;
3109
- render(): React$1.ReactNode;
3110
- context: unknown;
3111
- setState<K extends "error">(state: {
3112
- error: boolean;
3113
- } | ((prevState: Readonly<{
3114
- error: boolean;
3115
- }>, props: Readonly<{
3116
- set: React$1.Dispatch<Error | undefined>;
3117
- children: React$1.ReactNode;
3118
- }>) => {
3119
- error: boolean;
3120
- } | Pick<{
3121
- error: boolean;
3122
- }, K> | null) | Pick<{
3123
- error: boolean;
3124
- }, K> | null, callback?: (() => void) | undefined): void;
3125
- forceUpdate(callback?: (() => void) | undefined): void;
3126
- readonly props: Readonly<{
3127
- set: React$1.Dispatch<Error | undefined>;
3128
- children: React$1.ReactNode;
3129
- }>;
3130
- componentDidMount?(): void;
3131
- shouldComponentUpdate?(nextProps: Readonly<{
3132
- set: React$1.Dispatch<Error | undefined>;
3133
- children: React$1.ReactNode;
3134
- }>, nextState: Readonly<{
3135
- error: boolean;
3136
- }>, nextContext: any): boolean;
3137
- componentWillUnmount?(): void;
3138
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3139
- set: React$1.Dispatch<Error | undefined>;
3140
- children: React$1.ReactNode;
3141
- }>, prevState: Readonly<{
3142
- error: boolean;
3143
- }>): any;
3144
- componentDidUpdate?(prevProps: Readonly<{
3145
- set: React$1.Dispatch<Error | undefined>;
3146
- children: React$1.ReactNode;
3147
- }>, prevState: Readonly<{
3148
- error: boolean;
3149
- }>, snapshot?: any): void;
3150
- componentWillMount?(): void;
3151
- UNSAFE_componentWillMount?(): void;
3152
- componentWillReceiveProps?(nextProps: Readonly<{
3153
- set: React$1.Dispatch<Error | undefined>;
3154
- children: React$1.ReactNode;
3155
- }>, nextContext: any): void;
3156
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3157
- set: React$1.Dispatch<Error | undefined>;
3158
- children: React$1.ReactNode;
3159
- }>, nextContext: any): void;
3160
- componentWillUpdate?(nextProps: Readonly<{
3161
- set: React$1.Dispatch<Error | undefined>;
3162
- children: React$1.ReactNode;
3163
- }>, nextState: Readonly<{
3164
- error: boolean;
3165
- }>, nextContext: any): void;
3166
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3167
- set: React$1.Dispatch<Error | undefined>;
3168
- children: React$1.ReactNode;
3169
- }>, nextState: Readonly<{
3170
- error: boolean;
3171
- }>, nextContext: any): void;
3172
- };
3173
- new (props: {
3174
- set: React$1.Dispatch<Error | undefined>;
3175
- children: React$1.ReactNode;
3176
- }, context: any): {
3177
- state: {
3178
- error: boolean;
3179
- };
3180
- componentDidCatch(err: Error): void;
3181
- render(): React$1.ReactNode;
3182
- context: unknown;
3183
- setState<K extends "error">(state: {
3184
- error: boolean;
3185
- } | ((prevState: Readonly<{
3186
- error: boolean;
3187
- }>, props: Readonly<{
3188
- set: React$1.Dispatch<Error | undefined>;
3189
- children: React$1.ReactNode;
3190
- }>) => {
3191
- error: boolean;
3192
- } | Pick<{
3193
- error: boolean;
3194
- }, K> | null) | Pick<{
3195
- error: boolean;
3196
- }, K> | null, callback?: (() => void) | undefined): void;
3197
- forceUpdate(callback?: (() => void) | undefined): void;
3198
- readonly props: Readonly<{
3199
- set: React$1.Dispatch<Error | undefined>;
3200
- children: React$1.ReactNode;
3201
- }>;
3202
- componentDidMount?(): void;
3203
- shouldComponentUpdate?(nextProps: Readonly<{
3204
- set: React$1.Dispatch<Error | undefined>;
3205
- children: React$1.ReactNode;
3206
- }>, nextState: Readonly<{
3207
- error: boolean;
3208
- }>, nextContext: any): boolean;
3209
- componentWillUnmount?(): void;
3210
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3211
- set: React$1.Dispatch<Error | undefined>;
3212
- children: React$1.ReactNode;
3213
- }>, prevState: Readonly<{
3214
- error: boolean;
3215
- }>): any;
3216
- componentDidUpdate?(prevProps: Readonly<{
3217
- set: React$1.Dispatch<Error | undefined>;
3218
- children: React$1.ReactNode;
3219
- }>, prevState: Readonly<{
3220
- error: boolean;
3221
- }>, snapshot?: any): void;
3222
- componentWillMount?(): void;
3223
- UNSAFE_componentWillMount?(): void;
3224
- componentWillReceiveProps?(nextProps: Readonly<{
3225
- set: React$1.Dispatch<Error | undefined>;
3226
- children: React$1.ReactNode;
3227
- }>, nextContext: any): void;
3228
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3229
- set: React$1.Dispatch<Error | undefined>;
3230
- children: React$1.ReactNode;
3231
- }>, nextContext: any): void;
3232
- componentWillUpdate?(nextProps: Readonly<{
3233
- set: React$1.Dispatch<Error | undefined>;
3234
- children: React$1.ReactNode;
3235
- }>, nextState: Readonly<{
3236
- error: boolean;
3237
- }>, nextContext: any): void;
3238
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3239
- set: React$1.Dispatch<Error | undefined>;
3240
- children: React$1.ReactNode;
3241
- }>, nextState: Readonly<{
3242
- error: boolean;
3243
- }>, nextContext: any): void;
3244
- };
3245
- getDerivedStateFromError: () => {
3246
- error: boolean;
3247
- };
3248
- contextType?: React$1.Context<any> | undefined;
3249
- propTypes?: any;
3250
- };
3251
-
3252
- /**
3253
- * React internal props that should not be passed to Three.js objects.
3254
- */
3255
- declare const REACT_INTERNAL_PROPS: string[];
3256
- /**
3257
- * Returns the instance's initial (outermost) root.
3258
- * Traverses through previousRoot links to find the original root store.
3259
- *
3260
- * @param instance - R3F instance to find root for
3261
- * @returns The outermost root store
3262
- */
3263
- declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
3264
- /**
3265
- * Returns instance root state.
3266
- * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
3267
- * traverses ancestors to find the nearest managed parent.
3268
- *
3269
- * @param obj - Three.js object to get root state for
3270
- * @returns Root state if found, undefined otherwise
3271
- */
3272
- declare function getRootState<T extends Object3D = Object3D>(obj: T): RootState | undefined;
3273
- /**
3274
- * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
3275
- * Handles duplicate material names by appending UUID prefixes.
3276
- *
3277
- * @param object - Root object to traverse
3278
- * @returns ObjectMap containing named nodes, materials, and meshes
3279
- *
3280
- * @example
3281
- * const { nodes, materials, meshes } = buildGraph(gltf.scene)
3282
- * // Access by name: nodes.Head, materials.Metal, meshes.Body
3283
- */
3284
- declare function buildGraph(object: Object3D): ObjectMap;
3285
- /**
3286
- * Disposes an object and all its disposable properties.
3287
- * Skips Scene objects as they should not be disposed automatically.
3288
- *
3289
- * @param obj - Object to dispose
3290
- */
3291
- declare function dispose<T extends Disposable>(obj: T): void;
3292
- /**
3293
- * Extracts instance props from React reconciler fiber props.
3294
- * Filters out React-internal props (children, key, ref).
3295
- *
3296
- * @param queue - Pending props from reconciler fiber
3297
- * @returns Props object without React-internal keys
3298
- */
3299
- declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
3300
- /**
3301
- * Creates or retrieves an R3F instance descriptor for a Three.js object.
3302
- * Each object in the scene carries a LocalState descriptor (__r3f).
3303
- *
3304
- * @param target - Target object to prepare
3305
- * @param root - Root store for this instance
3306
- * @param type - String identifier for the object type
3307
- * @param props - Initial props for the instance
3308
- * @returns Instance descriptor
3309
- */
3310
- declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3311
- /**
3312
- * Triggers an update for an instance.
3313
- * Invalidates the frame if the root is in demand mode.
3314
- *
3315
- * @param instance - Instance to invalidate
3316
- */
3317
- declare function invalidateInstance(instance: Instance): void;
3318
-
3319
- /**
3320
- * Reserved prop names that should not be applied to Three.js objects.
3321
- */
3322
- declare const RESERVED_PROPS: string[];
3323
- /**
3324
- * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
3325
- * First tries the entire key as a single property, then attempts piercing.
3326
- *
3327
- * @param root - Root object to resolve from
3328
- * @param key - Property key (may contain dashes for piercing)
3329
- * @returns Object containing root, key, and target value
3330
- *
3331
- * @example
3332
- * resolve(mesh, 'material-color')
3333
- * // => { root: mesh.material, key: 'color', target: mesh.material.color }
3334
- */
3335
- declare function resolve(root: any, key: string): {
3336
- root: any;
3337
- key: string;
3338
- target: any;
3339
- };
3340
- /**
3341
- * Attaches a child instance to a parent instance.
3342
- * Handles both string-based attachment (e.g., 'geometry', 'material-map')
3343
- * and function-based attachment for custom logic.
3344
- *
3345
- * @param parent - Parent instance
3346
- * @param child - Child instance to attach
3347
- *
3348
- * @example
3349
- * // String attachment
3350
- * <bufferGeometry attach="geometry" />
3351
- * // Array attachment
3352
- * <light attach="lights-0" />
3353
- * // Function attachment
3354
- * <thing attach={(parent, self) => { parent.customProp = self }} />
3355
- */
3356
- declare function attach(parent: Instance, child: Instance): void;
3357
- /**
3358
- * Detaches a child instance from a parent instance.
3359
- * Restores the previous value or deletes the property if it was never set.
3360
- *
3361
- * @param parent - Parent instance
3362
- * @param child - Child instance to detach
3363
- */
3364
- declare function detach(parent: Instance, child: Instance): void;
3365
- /**
3366
- * Compares old and new props to determine which properties have changed.
3367
- * Also handles resetting removed props for HMR/fast-refresh.
3368
- *
3369
- * @param instance - Instance to diff props for
3370
- * @param newProps - New props to compare against
3371
- * @returns Object containing only changed props
3372
- *
3373
- * @example
3374
- * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
3375
- * // => { position: [1, 2, 3] } (only if position changed)
3376
- */
3377
- declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
3378
- /**
3379
- * Applies a set of props to a Three.js object.
3380
- * Handles special cases like colors, vectors, textures, events, and pierced props.
3381
- *
3382
- * @param object - Three.js object to apply props to
3383
- * @param props - Props to apply
3384
- * @returns The object with props applied
3385
- *
3386
- * @example
3387
- * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
3388
- */
3389
- declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
3390
-
3391
- /**
3392
- * Calculates the device pixel ratio for rendering.
3393
- * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
3394
- *
3395
- * @param dpr - Target DPR value or [min, max] range
3396
- * @returns Calculated DPR value
3397
- *
3398
- * @example
3399
- * calculateDpr(2) // => 2
3400
- * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
3401
- */
3402
- declare function calculateDpr(dpr: Dpr): number;
3403
- /**
3404
- * Extracts the first segment of a UUID string (before the first hyphen).
3405
- * Used for creating unique material names when duplicates exist.
3406
- *
3407
- * @param uuid - UUID string to extract prefix from
3408
- * @returns First segment of the UUID
3409
- *
3410
- * @example
3411
- * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
3412
- */
3413
- declare function getUuidPrefix(uuid: string): string;
3414
- /**
3415
- * Updates camera projection based on viewport size.
3416
- * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
3417
- * Respects camera.manual flag - manual cameras are not modified.
3418
- *
3419
- * @param camera - Camera to update
3420
- * @param size - Current viewport size
3421
- */
3422
- declare function updateCamera(camera: ThreeCamera, size: Size): void;
3423
- /**
3424
- * Updates a frustum from a camera's projection and world matrices.
3425
- * If no target frustum is provided, creates and returns a new one.
3426
- *
3427
- * @param camera - Camera to extract frustum from
3428
- * @param frustum - Optional existing frustum to update (creates new if not provided)
3429
- * @returns The updated or newly created frustum
3430
- *
3431
- * @example
3432
- * // Create new frustum
3433
- * const frustum = updateFrustum(camera)
3434
- *
3435
- * // Update existing frustum (no allocation)
3436
- * updateFrustum(camera, existingFrustum)
3437
- *
3438
- * // Use for visibility checks
3439
- * if (frustum.containsPoint(point)) { ... }
3440
- * if (frustum.intersectsObject(mesh)) { ... }
3441
- */
3442
- declare function updateFrustum(camera: ThreeCamera, frustum?: Frustum): Frustum;
3443
-
3444
- declare const is: {
3445
- obj: (a: any) => boolean;
3446
- fun: (a: any) => a is Function;
3447
- str: (a: any) => a is string;
3448
- num: (a: any) => a is number;
3449
- boo: (a: any) => a is boolean;
3450
- und: (a: any) => boolean;
3451
- nul: (a: any) => boolean;
3452
- arr: (a: any) => a is any[];
3453
- equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
3454
- };
3455
- declare const isOrthographicCamera: (def: ThreeCamera) => def is OrthographicCamera;
3456
- declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
3457
- declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation$1;
3458
- declare const isObject3D: (object: any) => object is Object3D;
3459
- declare const isTexture: (value: unknown) => value is Texture$1;
3460
- type VectorLike = {
3461
- set: (...args: any[]) => void;
3462
- constructor?: Function;
3463
- };
3464
- declare const isVectorLike: (object: unknown) => object is VectorLike;
3465
- type Copyable = {
3466
- copy: (...args: any[]) => void;
3467
- constructor?: Function;
3468
- };
3469
- declare const isCopyable: (object: unknown) => object is Copyable;
3470
- declare const hasConstructor: (object: unknown) => object is {
3471
- constructor?: Function;
3472
- };
3473
-
3474
- /**
3475
- * Symbol marker for deferred ref resolution.
3476
- * Used to identify values that should be resolved from refs after mount.
3477
- */
3478
- declare const FROM_REF: unique symbol;
3479
- /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3480
- interface FromRefMarker<T = unknown, R = T> {
3481
- [FROM_REF]: React$1.RefObject<T | null>;
3482
- /** Optional transform applied to the resolved ref before assignment. */
3483
- transform?: (value: T) => R;
3484
- }
3485
- /**
3486
- * Defers prop application until the referenced object is available.
3487
- * Useful for props like `target` that need sibling refs to be populated.
3488
- *
3489
- * Only top-level props on a three element are resolved: a marker nested inside another value
3490
- * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3491
- * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3492
- * what gets assigned.
3493
- *
3494
- * @param ref - React ref object to resolve at mount time
3495
- * @param transform - Optional mapping from the resolved object to the value the prop expects
3496
- * @returns A marker value that the reconciler resolves after mount
3497
- *
3498
- * @example
3499
- * const targetRef = useRef<THREE.Object3D>(null)
3500
- *
3501
- * <group ref={targetRef} position={[-3, -2, -15]} />
3502
- * <spotLight target={fromRef(targetRef)} intensity={100} />
3503
- *
3504
- * @example
3505
- * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3506
- * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3507
- */
3508
- declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3509
- declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3510
- /**
3511
- * Type guard to check if a value is a fromRef marker.
3512
- *
3513
- * @param value - Value to check
3514
- * @returns True if value is a fromRef marker
3515
- */
3516
- declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3517
-
3518
- /**
3519
- * Symbol marker for mount-only method calls.
3520
- * Used to identify methods that should only be called once on initial mount.
3521
- */
3522
- declare const ONCE: unique symbol;
3523
- /**
3524
- * Marks a method call to be executed only on initial mount.
3525
- * Useful for geometry transforms that should not be reapplied on every render.
3526
- *
3527
- * When `args` prop changes (triggering reconstruction), the method will be
3528
- * called again on the new instance since appliedOnce is not carried over.
3529
- *
3530
- * @param args - Arguments to pass to the method
3531
- * @returns A marker value that applyProps will execute once
3532
- *
3533
- * @example
3534
- * // Rotate geometry on mount
3535
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
3536
- *
3537
- * // Multiple arguments
3538
- * <bufferGeometry applyMatrix4={once(matrix)} />
3539
- *
3540
- * // No arguments
3541
- * <geometry center={once()} />
3542
- */
3543
- declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3544
- /**
3545
- * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3546
- * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3547
- * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3548
- *
3549
- * The runtime value is always the marker object; only the declared type follows the prop.
3550
- */
3551
- type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3552
- /**
3553
- * Type guard to check if a value is a once marker.
3554
- *
3555
- * @param value - Value to check
3556
- * @returns True if value is a once marker
3557
- */
3558
- declare function isOnce(value: unknown): value is {
3559
- [ONCE]: any[] | true;
3560
- };
3561
-
3562
- /**
3563
- * A DOM canvas which accepts threejs elements as children.
3564
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3565
- */
3566
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3567
-
3568
- 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 };
3569
- 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 };
143
+ export { Canvas, CanvasProps, Color$1 as Color, ConstructorRepresentation, ElementOf$1 as ElementOf, ElementProps$1 as ElementProps, Euler$1 as Euler, EventProps$1 as EventProps, GeometryProps$1 as GeometryProps, GeometryTransformProps$1 as GeometryTransformProps, Layers$1 as Layers, MathProps$1 as MathProps, MathRepresentation$1 as MathRepresentation, MathType$1 as MathType, MathTypes$1 as MathTypes, Matrix3$1 as Matrix3, Matrix4$1 as Matrix4, MutableOrReadonlyParameters$1 as MutableOrReadonlyParameters, NodeProps$1 as NodeProps, Object3DMethod$1 as Object3DMethod, Quaternion$1 as Quaternion, R3FRenderTarget, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, RaycastableRepresentation$1 as RaycastableRepresentation, ReactProps$1 as ReactProps, default_d as ReactThreeFiber, ReconcilerRoot, RenderTargetOptions, TSLNodeInput$1 as TSLNodeInput, ThreeElement$1 as ThreeElement, ThreeElementsOf$1 as ThreeElementsOf, ThreeToJSXElements$1 as ThreeToJSXElements, Vector2$1 as Vector2, Vector3$1 as Vector3, Vector4$1 as Vector4, VectorRepresentation$1 as VectorRepresentation, createRoot, useRenderTarget };
144
+ export type { ThreeElements, ThreeExports };