@gnsx/react-three-fiber 10.0.0

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.
@@ -0,0 +1,4769 @@
1
+ import * as three_webgpu from 'three/webgpu';
2
+ import { RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera, WebGPURendererParameters } from 'three/webgpu';
3
+ import { Inspector } from 'three/addons/inspector/Inspector.js';
4
+ import * as THREE$1 from 'three';
5
+ import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
+ import * as React$1 from 'react';
7
+ import { ReactNode, Component, RefObject, JSX } from 'react';
8
+ import { StoreApi } from 'zustand';
9
+ import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
10
+ import { Options } from 'react-use-measure';
11
+ import * as react_jsx_runtime from 'react/jsx-runtime';
12
+ import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
13
+ import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
14
+
15
+ function _mergeNamespaces(n, m) {
16
+ m.forEach(function (e) {
17
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default' && !(k in n)) {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ });
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ /**
31
+ * @fileoverview Internal Three.js re-exports - WEBGPU ONLY ENTRY
32
+ *
33
+ * Pure WebGPU path - no WebGL legacy.
34
+ * Use this for the explicit webgpu import path: @react-three/fiber/webgpu
35
+ *
36
+ * This is for apps that want ONLY WebGPU with no legacy fallback.
37
+ * Attempting to use WebGLRenderer will cause type/runtime errors (intentional).
38
+ */
39
+ declare const R3F_BUILD_LEGACY = false;
40
+ declare const R3F_BUILD_WEBGPU = true;
41
+
42
+ declare const WebGLRenderer: {
43
+ new (): {};
44
+ };
45
+ type WebGLRendererParameters = never;
46
+ type WebGLShadowMap = never;
47
+
48
+ declare const WebGLRenderTarget: any;
49
+
50
+ var THREE = /*#__PURE__*/_mergeNamespaces({
51
+ __proto__: null,
52
+ Inspector: Inspector,
53
+ R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
54
+ R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
55
+ RenderTargetCompat: RenderTarget,
56
+ WebGLRenderTarget: WebGLRenderTarget,
57
+ WebGLRenderer: WebGLRenderer,
58
+ WebGLRendererParameters: WebGLRendererParameters,
59
+ WebGLShadowMap: WebGLShadowMap
60
+ }, [three_webgpu]);
61
+
62
+ //* Utility Types ==============================
63
+
64
+ type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
65
+ type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
66
+ type Properties<T> = Pick<T, NonFunctionKeys<T>>
67
+ type Mutable<P> = { -readonly [K in keyof P]: P[K] }
68
+ type IsOptional<T> = undefined extends T ? true : false
69
+ type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
70
+ ? IsOptional<First> extends true
71
+ ? IsAllOptional<Rest>
72
+ : false
73
+ : true
74
+
75
+ //* Camera Types ==============================
76
+
77
+ type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
78
+
79
+ //* Act Type ==============================
80
+
81
+ type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
82
+
83
+ //* Bridge & Block Types ==============================
84
+
85
+ type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
86
+
87
+ type SetBlock = false | Promise<null> | null
88
+ type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
89
+
90
+ //* Object Map Type ==============================
91
+
92
+ /* Original version
93
+ export interface ObjectMap {
94
+ nodes: { [name: string]: THREE.Object3D }
95
+ materials: { [name: string]: THREE.Material }
96
+ meshes: { [name: string]: THREE.Mesh }
97
+ }
98
+ */
99
+ /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
100
+ It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
101
+ I will keep the use here)
102
+ https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
103
+ His description is:
104
+ The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
105
+ */
106
+ interface ObjectMap<
107
+ T extends { nodes?: string; materials?: string; meshes?: string } = {
108
+ nodes: string
109
+ materials: string
110
+ meshes: string
111
+ },
112
+ > {
113
+ nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
114
+ materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
115
+ meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
116
+ }
117
+
118
+ //* Equality Config ==============================
119
+
120
+ interface EquConfig {
121
+ /** Compare arrays by reference equality a === b (default), or by shallow equality */
122
+ arrays?: 'reference' | 'shallow'
123
+ /** Compare objects by reference equality a === b (default), or by shallow equality */
124
+ objects?: 'reference' | 'shallow'
125
+ /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
126
+ strict?: boolean
127
+ }
128
+
129
+ //* Disposable Type ==============================
130
+
131
+ interface Disposable {
132
+ type?: string
133
+ dispose?: () => void
134
+ }
135
+
136
+ //* Event-related Types =====================================
137
+
138
+ interface Intersection extends THREE$1.Intersection {
139
+ /** The event source (the object which registered the handler) */
140
+ eventObject: THREE$1.Object3D
141
+ }
142
+
143
+ type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
144
+
145
+ interface IntersectionEvent<TSourceEvent> extends Intersection {
146
+ /** The event source (the object which registered the handler) */
147
+ eventObject: THREE$1.Object3D
148
+ /** An array of intersections */
149
+ intersections: Intersection[]
150
+ /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
151
+ unprojectedPoint: THREE$1.Vector3
152
+ /** Normalized event coordinates */
153
+ pointer: THREE$1.Vector2
154
+ /** pointerId of the original event for multiple pointer events */
155
+ pointerId: number
156
+ /** Delta between first click and this event */
157
+ delta: number
158
+ /** The ray that pierced it */
159
+ ray: THREE$1.Ray
160
+ /** The camera that was used by the raycaster */
161
+ camera: Camera
162
+ /** stopPropagation will stop underlying handlers from firing */
163
+ stopPropagation: () => void
164
+ /** The original host event */
165
+ nativeEvent: TSourceEvent
166
+ /** If the event was stopped by calling stopPropagation */
167
+ stopped: boolean
168
+ }
169
+
170
+ type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
171
+ type DomEvent = PointerEvent | MouseEvent | WheelEvent
172
+
173
+ /** DOM event handlers registered on the canvas element */
174
+ interface Events {
175
+ onClick: EventListener
176
+ onContextMenu: EventListener
177
+ onDoubleClick: EventListener
178
+ onWheel: EventListener
179
+ onPointerDown: EventListener
180
+ onPointerUp: EventListener
181
+ onPointerLeave: EventListener
182
+ onPointerMove: EventListener
183
+ onPointerCancel: EventListener
184
+ onLostPointerCapture: EventListener
185
+ onDragEnter: EventListener
186
+ onDragLeave: EventListener
187
+ onDragOver: EventListener
188
+ onDrop: EventListener
189
+ }
190
+
191
+ /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
192
+ interface EventHandlers {
193
+ onClick?: (event: ThreeEvent<MouseEvent>) => void
194
+ onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
195
+ onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
196
+ /** Fires continuously while dragging over the object */
197
+ onDragOver?: (event: ThreeEvent<DragEvent>) => void
198
+ /** Fires once when drag enters the object */
199
+ onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
200
+ /** Fires once when drag leaves the object */
201
+ onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
202
+ /** Fires when drag misses this object (for objects that have drag handlers) */
203
+ onDragOverMissed?: (event: DragEvent) => void
204
+ /** Fires when a drop occurs on this object */
205
+ onDrop?: (event: ThreeEvent<DragEvent>) => void
206
+ /** Fires when a drop misses this object (for objects that have drop handlers) */
207
+ onDropMissed?: (event: DragEvent) => void
208
+ onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
209
+ onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
210
+ onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
211
+ onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
212
+ onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
213
+ onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
214
+ onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
215
+ onPointerMissed?: (event: MouseEvent) => void
216
+ onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
217
+ onWheel?: (event: ThreeEvent<WheelEvent>) => void
218
+ onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
219
+
220
+ //* Visibility Events --------------------------------
221
+ /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
222
+ onFramed?: (inView: boolean) => void
223
+ /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
224
+ onOccluded?: (occluded: boolean) => void
225
+ /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
226
+ onVisible?: (visible: boolean) => void
227
+ }
228
+
229
+ type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
230
+ type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
231
+
232
+ /** Configuration for XR pointer registration (controllers/hands) */
233
+ interface XRPointerConfig {
234
+ /** Ray origin (updated each frame by XR system) */
235
+ ray: THREE$1.Ray
236
+ /** Optional: custom compute function for this pointer */
237
+ compute?: (state: RootState) => void
238
+ /** Pointer type identifier */
239
+ type: 'controller' | 'hand' | 'gaze'
240
+ /** Which hand (for controller/hand types) */
241
+ handedness?: 'left' | 'right'
242
+ }
243
+
244
+ interface EventManager<TTarget> {
245
+ /** Determines if the event layer is active */
246
+ enabled: boolean
247
+ /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
248
+ priority: number
249
+ /** The compute function needs to set up the raycaster and an xy- pointer */
250
+ compute?: ComputeFunction
251
+ /** The filter can re-order or re-structure the intersections */
252
+ filter?: FilterFunction
253
+ /** The target node the event layer is tied to */
254
+ connected?: TTarget
255
+ /** All the pointer event handlers through which the host forwards native events */
256
+ handlers?: Events
257
+ /** Allows re-connecting to another target */
258
+ connect?: (target: TTarget) => void
259
+ /** Removes all existing events handlers from the target */
260
+ disconnect?: () => void
261
+ /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
262
+ * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
263
+ * @param pointerId - Optional pointer ID to update specific pointer only
264
+ */
265
+ update?: (pointerId?: number) => void
266
+ /** Defer pointer move raycasting to frame start (default: true) */
267
+ frameTimedRaycasts?: boolean
268
+ /** Always fire raycaster immediately on scroll events (default: true) */
269
+ alwaysFireOnScroll?: boolean
270
+ /** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
271
+ updateOnFrame?: boolean
272
+ /** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
273
+ flush?: () => void
274
+ /** Register an XR pointer (controller/hand). Returns assigned pointerId */
275
+ registerPointer?: (config: XRPointerConfig) => number
276
+ /** Unregister an XR pointer */
277
+ unregisterPointer?: (pointerId: number) => void
278
+ }
279
+
280
+ interface PointerCaptureTarget {
281
+ intersection: Intersection
282
+ target: Element
283
+ }
284
+
285
+ //* Visibility System Types =====================================
286
+
287
+ /** Entry in the visibility registry for tracking object visibility state */
288
+ interface VisibilityEntry {
289
+ object: THREE$1.Object3D
290
+ handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
291
+ lastFramedState: boolean | null
292
+ lastOccludedState: boolean | null
293
+ lastVisibleState: boolean | null
294
+ }
295
+
296
+ //* Scheduler Types (useFrame) ==============================
297
+
298
+
299
+
300
+ // Public Options --------------------------------
301
+
302
+ /**
303
+ * Options for useFrame hook
304
+ */
305
+ interface UseFrameNextOptions {
306
+ /** Optional stable id for the job. Auto-generated if not provided */
307
+ id?: string
308
+ /** Named phase to run in. Default: 'update' */
309
+ phase?: string
310
+ /** Run before this phase or job id */
311
+ before?: string | string[]
312
+ /** Run after this phase or job id */
313
+ after?: string | string[]
314
+ /** Priority within phase. Higher runs first. Default: 0 */
315
+ priority?: number
316
+ /** Max frames per second for this job */
317
+ fps?: number
318
+ /** If true, skip frames when behind. If false, try to catch up. Default: true */
319
+ drop?: boolean
320
+ /** Enable/disable without unregistering. Default: true */
321
+ enabled?: boolean
322
+ }
323
+
324
+ /** Alias for UseFrameNextOptions */
325
+ type UseFrameOptions = UseFrameNextOptions
326
+
327
+ /**
328
+ * Options for addPhase
329
+ */
330
+ interface AddPhaseOptions {
331
+ /** Insert this phase before the specified phase */
332
+ before?: string
333
+ /** Insert this phase after the specified phase */
334
+ after?: string
335
+ }
336
+
337
+ // Frame State --------------------------------
338
+
339
+ /**
340
+ * Timing-only state for independent/outside mode (no RootState)
341
+ */
342
+ interface FrameTimingState {
343
+ /** High-resolution timestamp from RAF (ms) */
344
+ time: number
345
+ /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
346
+ delta: number
347
+ /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
348
+ elapsed: number
349
+ /** Incrementing frame counter */
350
+ frame: number
351
+ }
352
+
353
+ /**
354
+ * State passed to useFrame callbacks (extends RootState with timing)
355
+ */
356
+ interface FrameNextState extends RootState, FrameTimingState {}
357
+
358
+ /** Alias for FrameNextState */
359
+ type FrameState = FrameNextState
360
+
361
+ // Root Options --------------------------------
362
+
363
+ /**
364
+ * Options for registerRoot
365
+ */
366
+ interface RootOptions {
367
+ /** State provider for callbacks. Optional in independent mode. */
368
+ getState?: () => any
369
+ /** Error handler for job errors. Falls back to console.error if not provided. */
370
+ onError?: (error: Error) => void
371
+ }
372
+
373
+ // Callback Types --------------------------------
374
+
375
+ /**
376
+ * Callback function for useFrame
377
+ */
378
+ type FrameNextCallback = (state: FrameNextState, delta: number) => void
379
+
380
+ /** Alias for FrameNextCallback */
381
+ type FrameCallback = FrameNextCallback
382
+
383
+ // Controls returned from useFrame --------------------------------
384
+
385
+ /**
386
+ * Controls object returned from useFrame hook
387
+ */
388
+ interface FrameNextControls {
389
+ /** The job's unique ID */
390
+ id: string
391
+ /** Access to the global scheduler for frame loop control */
392
+ scheduler: SchedulerApi
393
+ /** Manually step this job only (bypasses FPS limiting) */
394
+ step(timestamp?: number): void
395
+ /** Manually step ALL jobs in the scheduler */
396
+ stepAll(timestamp?: number): void
397
+ /** Pause this job (set enabled=false) */
398
+ pause(): void
399
+ /** Resume this job (set enabled=true) */
400
+ resume(): void
401
+ /** Reactive paused state - automatically triggers re-render when changed */
402
+ isPaused: boolean
403
+ }
404
+
405
+ /** Alias for FrameNextControls */
406
+ type FrameControls = FrameNextControls
407
+
408
+ // Scheduler Interface --------------------------------
409
+
410
+ /**
411
+ * Public interface for the global Scheduler
412
+ */
413
+ interface SchedulerApi {
414
+ //* Phase Management --------------------------------
415
+
416
+ /** Add a named phase to the scheduler */
417
+ addPhase(name: string, options?: AddPhaseOptions): void
418
+ /** Get the ordered list of phase names */
419
+ readonly phases: string[]
420
+ /** Check if a phase exists */
421
+ hasPhase(name: string): boolean
422
+
423
+ //* Root Management --------------------------------
424
+
425
+ /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
426
+ registerRoot(id: string, options?: RootOptions): () => void
427
+ /** Unregister a root */
428
+ unregisterRoot(id: string): void
429
+ /** Generate a unique root ID */
430
+ generateRootId(): string
431
+ /** Get the number of registered roots */
432
+ getRootCount(): number
433
+ /** Check if any root is registered and ready */
434
+ readonly isReady: boolean
435
+ /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
436
+ onRootReady(callback: () => void): () => void
437
+
438
+ //* Job Registration --------------------------------
439
+
440
+ /** Register a job with the scheduler (returns unsubscribe function) */
441
+ register(
442
+ callback: FrameNextCallback,
443
+ options?: {
444
+ id?: string
445
+ rootId?: string
446
+ phase?: string
447
+ before?: string | string[]
448
+ after?: string | string[]
449
+ priority?: number
450
+ fps?: number
451
+ drop?: boolean
452
+ enabled?: boolean
453
+ },
454
+ ): () => void
455
+ /** Update a job's options */
456
+ updateJob(
457
+ id: string,
458
+ options: {
459
+ priority?: number
460
+ fps?: number
461
+ drop?: boolean
462
+ enabled?: boolean
463
+ phase?: string
464
+ before?: string | string[]
465
+ after?: string | string[]
466
+ },
467
+ ): void
468
+ /** Unregister a job by ID */
469
+ unregister(id: string, rootId?: string): void
470
+ /** Get the number of registered jobs */
471
+ getJobCount(): number
472
+ /** Get all job IDs */
473
+ getJobIds(): string[]
474
+
475
+ //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
476
+
477
+ /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
478
+ registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
479
+
480
+ //* Idle Callbacks (for legacy addTail) --------------------------------
481
+
482
+ /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
483
+ onIdle(callback: (timestamp: number) => void): () => void
484
+
485
+ //* Frame Loop Control --------------------------------
486
+
487
+ /** Start the scheduler loop */
488
+ start(): void
489
+ /** Stop the scheduler loop */
490
+ stop(): void
491
+ /** Check if the scheduler is running */
492
+ readonly isRunning: boolean
493
+ /** Get/set the frameloop mode ('always', 'demand', 'never') */
494
+ frameloop: Frameloop
495
+ /** Independent mode - runs without Canvas, callbacks receive timing-only state */
496
+ independent: boolean
497
+
498
+ //* Manual Stepping --------------------------------
499
+
500
+ /** Manually step all jobs once (for frameloop='never' or testing) */
501
+ step(timestamp?: number): void
502
+ /** Manually step a single job by ID */
503
+ stepJob(id: string, timestamp?: number): void
504
+ /** Request frame(s) to be rendered (for frameloop='demand') */
505
+ invalidate(frames?: number): void
506
+
507
+ //* Per-Job Control --------------------------------
508
+
509
+ /** Check if a job is paused */
510
+ isJobPaused(id: string): boolean
511
+ /** Pause a job */
512
+ pauseJob(id: string): void
513
+ /** Resume a job */
514
+ resumeJob(id: string): void
515
+ /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
516
+ subscribeJobState(id: string, listener: () => void): () => void
517
+ }
518
+
519
+ //* Buffer Types (useBuffers) ========================================
520
+
521
+ /**
522
+ * Buffer-like types for GPU compute and storage operations.
523
+ * Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
524
+ *
525
+ * @example
526
+ * ```tsx
527
+ * const { positions, velocities } = useBuffers(() => ({
528
+ * positions: instancedArray(count, 'vec3'), // StorageBufferNode
529
+ * velocities: new Float32Array(count * 3), // TypedArray
530
+ * }), 'particles')
531
+ * ```
532
+ */
533
+ type BufferLike =
534
+ | Float32Array
535
+ | Uint32Array
536
+ | Int32Array
537
+ | Float64Array
538
+ | Uint8Array
539
+ | Int8Array
540
+ | Uint16Array
541
+ | Int16Array
542
+ | THREE$1.BufferAttribute // Base class for all buffer attributes
543
+ | Node // TSL buffer nodes (instancedArray, storage)
544
+
545
+ /** Flat record of buffer-like values (no nested scopes) */
546
+ type BufferRecord = Record<string, BufferLike>
547
+
548
+ /**
549
+ * Buffer store that can contain both root-level buffers and scoped buffer objects.
550
+ * Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
551
+ */
552
+ type BufferStore = Record<string, BufferLike | BufferRecord>
553
+
554
+ //* Storage Types (useGPUStorage) ========================================
555
+
556
+ /**
557
+ * GPU storage types for texture-based storage operations.
558
+ * Includes Three.js storage textures and TSL storage texture nodes.
559
+ *
560
+ * @example
561
+ * ```tsx
562
+ * const { heightMap } = useGPUStorage(() => ({
563
+ * heightMap: new StorageTexture(512, 512),
564
+ * }), 'terrain')
565
+ * ```
566
+ */
567
+ type StorageLike =
568
+ | StorageTexture // GPU storage texture
569
+ | Data3DTexture // 3D texture (can be used as storage)
570
+ | Node // TSL storage texture nodes (storageTexture)
571
+
572
+ /** Flat record of storage-like values (no nested scopes) */
573
+ type StorageRecord = Record<string, StorageLike>
574
+
575
+ /**
576
+ * Storage store that can contain both root-level storage and scoped storage objects.
577
+ * Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
578
+ */
579
+ type StorageStore = Record<string, StorageLike | StorageRecord>
580
+
581
+ //* Renderer Types ========================================
582
+
583
+ /** Default renderer type - union of WebGL and WebGPU renderers */
584
+ type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
585
+
586
+ //* Core Store Types ========================================
587
+
588
+ type Subscription = {
589
+ ref: React$1.RefObject<RenderCallback>
590
+ priority: number
591
+ store: RootStore
592
+ }
593
+
594
+ /** Per-pointer state for multi-touch and XR support */
595
+ type PointerState = {
596
+ /** Objects currently hovered by this pointer */
597
+ hovered: Map<string, ThreeEvent<DomEvent>>
598
+ /** Objects capturing this pointer */
599
+ captured: Map<THREE$1.Object3D, PointerCaptureTarget>
600
+ /** Initial click position [x, y] */
601
+ initialClick: [x: number, y: number]
602
+ /** Objects hit on initial click */
603
+ initialHits: THREE$1.Object3D[]
604
+ }
605
+
606
+ type Dpr = number | [min: number, max: number]
607
+
608
+ interface Size {
609
+ width: number
610
+ height: number
611
+ top: number
612
+ left: number
613
+ }
614
+
615
+ type Frameloop = 'always' | 'demand' | 'never'
616
+
617
+ interface Viewport extends Size {
618
+ /** The initial pixel ratio */
619
+ initialDpr: number
620
+ /** Current pixel ratio */
621
+ dpr: number
622
+ /** size.width / viewport.width */
623
+ factor: number
624
+ /** Camera distance */
625
+ distance: number
626
+ /** Camera aspect ratio: width / height */
627
+ aspect: number
628
+ }
629
+
630
+ type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
631
+
632
+ interface Performance {
633
+ /** Current performance normal, between min and max */
634
+ current: number
635
+ /** How low the performance can go, between 0 and max */
636
+ min: number
637
+ /** How high the performance can go, between min and max */
638
+ max: number
639
+ /** Time until current returns to max in ms */
640
+ debounce: number
641
+ /** Sets current to min, puts the system in regression */
642
+ regress: () => void
643
+ }
644
+
645
+ interface InternalState {
646
+ interaction: THREE$1.Object3D[]
647
+ subscribers: Subscription[]
648
+ /** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
649
+ pointerMap: Map<number, PointerState>
650
+ /** Pointers needing raycast this frame (used with frameTimedRaycasts) */
651
+ pointerDirty: Map<number, DomEvent>
652
+ /** Last event received (for events.update() compatibility) */
653
+ lastEvent: React$1.RefObject<DomEvent | null>
654
+ /** @deprecated Use pointerMap.get(pointerId).hovered instead */
655
+ hovered: Map<string, ThreeEvent<DomEvent>>
656
+ /** @deprecated Use pointerMap.get(pointerId).captured instead */
657
+ capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
658
+ /** @deprecated Use pointerMap.get(pointerId).initialClick instead */
659
+ initialClick: [x: number, y: number]
660
+ /** @deprecated Use pointerMap.get(pointerId).initialHits instead */
661
+ initialHits: THREE$1.Object3D[]
662
+ /** Visibility event registry (onFramed, onOccluded, onVisible) */
663
+ visibilityRegistry: Map<string, VisibilityEntry>
664
+ /** Whether occlusion queries are enabled (WebGPU only) */
665
+ occlusionEnabled: boolean
666
+ /** Reference to the invisible occlusion observer mesh */
667
+ occlusionObserver: THREE$1.Mesh | null
668
+ /** Cached occlusion results from render pass - keyed by Object3D */
669
+ occlusionCache: Map<THREE$1.Object3D, boolean | null>
670
+ /** Internal helper group for R3F system objects (occlusion observer, etc.) */
671
+ helperGroup: THREE$1.Group | null
672
+ active: boolean
673
+ priority: number
674
+ frames: number
675
+ subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
676
+ /** Internal renderer storage - use state.renderer or state.gl to access */
677
+ actualRenderer: R3FRenderer
678
+ /** Global scheduler reference (for useFrame hook) */
679
+ scheduler: SchedulerApi | null
680
+ /** This root's unique ID in the global scheduler */
681
+ rootId?: string
682
+ /** Function to unregister this root from the global scheduler */
683
+ unregisterRoot?: () => void
684
+ /** Container for child attachment (scene for root, original container for portals) */
685
+ container?: THREE$1.Object3D
686
+ /**
687
+ * CanvasTarget for multi-canvas WebGPU rendering.
688
+ * Created for all WebGPU canvases to support renderer sharing.
689
+ * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
690
+ */
691
+ canvasTarget?: CanvasTarget
692
+ /**
693
+ * Whether multi-canvas rendering is active.
694
+ * True when any canvas uses `target` prop to share a renderer.
695
+ * When true, setCanvasTarget is called before each render.
696
+ */
697
+ isMultiCanvas?: boolean
698
+ /**
699
+ * Whether this canvas is a secondary canvas sharing another's renderer.
700
+ * True when `target` prop is used.
701
+ */
702
+ isSecondary?: boolean
703
+ /**
704
+ * The id of the primary canvas this secondary canvas targets.
705
+ * Only set when isSecondary is true.
706
+ */
707
+ targetId?: string
708
+ /**
709
+ * Function to unregister this primary canvas from the registry.
710
+ * Only set when this canvas has an `id` prop.
711
+ */
712
+ unregisterPrimary?: () => void
713
+ /** Whether canvas dimensions are forced to even numbers */
714
+ forceEven?: boolean
715
+ }
716
+
717
+ interface XRManager {
718
+ connect: () => void
719
+ disconnect: () => void
720
+ }
721
+
722
+ //* Root State Interface ====================================
723
+
724
+ interface RootState {
725
+ /** Set current state */
726
+ set: StoreApi<RootState>['setState']
727
+ /** Get current state */
728
+ get: StoreApi<RootState>['getState']
729
+ /**
730
+ * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
731
+ * - For primary/independent canvases: points to its own store (self-reference)
732
+ * - For secondary canvases: points to the primary canvas's store
733
+ *
734
+ * Hooks like useNodes/useUniforms should read from primaryStore to ensure
735
+ * consistent shared state across all canvases sharing a renderer.
736
+ */
737
+ primaryStore: RootStore
738
+ /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
739
+ gl: THREE$1.WebGLRenderer
740
+ /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
741
+ renderer: R3FRenderer
742
+ /** Inspector of the webGPU Renderer. Init in the canvas */
743
+ inspector: any // Inspector type from three/webgpu
744
+
745
+ /** Default camera */
746
+ camera: ThreeCamera
747
+ /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
748
+ frustum: THREE$1.Frustum
749
+ /** Whether to automatically update the frustum each frame (default: true) */
750
+ autoUpdateFrustum: boolean
751
+ /** Default scene (may be overridden in portals to point to the portal container) */
752
+ scene: THREE$1.Scene
753
+ /** The actual root THREE.Scene - always points to the true scene, even inside portals */
754
+ rootScene: THREE$1.Scene
755
+ /** Default raycaster */
756
+ raycaster: THREE$1.Raycaster
757
+ /** Event layer interface, contains the event handler and the node they're connected to */
758
+ events: EventManager<any>
759
+ /** XR interface */
760
+ xr: XRManager
761
+ /** Currently used controls */
762
+ controls: THREE$1.EventDispatcher | null
763
+ /** Normalized event coordinates */
764
+ pointer: THREE$1.Vector2
765
+ /** @deprecated Normalized event coordinates, use "pointer" instead! */
766
+ mouse: THREE$1.Vector2
767
+ /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
768
+ textureColorSpace: THREE$1.ColorSpace
769
+ /** Render loop flags */
770
+ frameloop: Frameloop
771
+ performance: Performance
772
+ /** Reactive pixel-size of the canvas */
773
+ size: Size
774
+ /** Reactive size of the viewport in threejs units */
775
+ viewport: Viewport & {
776
+ getCurrentViewport: (
777
+ camera?: ThreeCamera,
778
+ target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
779
+ size?: Size,
780
+ ) => Omit<Viewport, 'dpr' | 'initialDpr'>
781
+ }
782
+ /** Flags the canvas for render, but doesn't render in itself */
783
+ invalidate: (frames?: number, stackFrames?: boolean) => void
784
+ /** Advance (render) one step */
785
+ advance: (timestamp: number, runGlobalEffects?: boolean) => void
786
+ /** Shortcut to setting the event layer */
787
+ setEvents: (events: Partial<EventManager<any>>) => void
788
+ /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
789
+ setSize: (width?: number, height?: number, top?: number, left?: number) => void
790
+ /** Shortcut to manual setting the pixel ratio */
791
+ setDpr: (dpr: Dpr) => void
792
+ /** Shortcut to setting frameloop flags */
793
+ setFrameloop: (frameloop: Frameloop) => void
794
+ /** Set error state to propagate to error boundary */
795
+ setError: (error: Error | null) => void
796
+ /** Current error state (null when no error) */
797
+ error: Error | null
798
+ /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
799
+ uniforms: UniformStore
800
+ /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
801
+ nodes: Record<string, any>
802
+ /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
803
+ buffers: BufferStore
804
+ /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
805
+ gpuStorage: StorageStore
806
+ /** Global TSL texture nodes - use useTextures() hook for operations */
807
+ textures: Map<string, any>
808
+ /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
809
+ renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
810
+ /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
811
+ passes: Record<string, any>
812
+ /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
813
+ _hmrVersion: number
814
+ /** Internal: whether setSize() has taken ownership of canvas dimensions */
815
+ _sizeImperative: boolean
816
+ /** Internal: stored size props from Canvas for reset functionality */
817
+ _sizeProps: { width?: number; height?: number } | null
818
+ /** When the canvas was clicked but nothing was hit */
819
+ onPointerMissed?: (event: MouseEvent) => void
820
+ /** When a dragover event has missed any target */
821
+ onDragOverMissed?: (event: DragEvent) => void
822
+ /** When a drop event has missed any target */
823
+ onDropMissed?: (event: DragEvent) => void
824
+ /** If this state model is layered (via createPortal) then this contains the previous layer */
825
+ previousRoot?: RootStore
826
+ /** Internals */
827
+ internal: InternalState
828
+ // flags for triggers
829
+ // if we are using the webGl renderer, this will be true
830
+ isLegacy: boolean
831
+ // regardless of renderer, if the system supports webGpu, this will be true
832
+ webGPUSupported: boolean
833
+ //if we are on native
834
+ isNative: boolean
835
+ }
836
+
837
+ type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
838
+
839
+ //* Base Renderer Types =====================================
840
+
841
+ // Shim for OffscreenCanvas since it was removed from DOM types
842
+ interface OffscreenCanvas$1 extends EventTarget {}
843
+
844
+ interface BaseRendererProps {
845
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
846
+ powerPreference?: 'high-performance' | 'low-power' | 'default'
847
+ antialias?: boolean
848
+ alpha?: boolean
849
+ }
850
+
851
+ type RendererFactory<TRenderer, TParams> =
852
+ | TRenderer
853
+ | ((defaultProps: TParams) => TRenderer)
854
+ | ((defaultProps: TParams) => Promise<TRenderer>)
855
+
856
+ interface Renderer {
857
+ render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
858
+ }
859
+
860
+ //* Color Management Config ==============================
861
+
862
+ /**
863
+ * Color management configuration shared by both WebGL and WebGPU renderers.
864
+ */
865
+ interface ColorManagementConfig {
866
+ /**
867
+ * Color space assigned to 8-bit input textures (color maps).
868
+ * Defaults to sRGB. Most textures are authored in sRGB.
869
+ * @default THREE.SRGBColorSpace
870
+ */
871
+ textureColorSpace?: THREE$1.ColorSpace
872
+ }
873
+
874
+ //* WebGL Renderer Props ==============================
875
+
876
+ type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
877
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
878
+ }
879
+
880
+ type GLProps =
881
+ | Renderer
882
+ | ((defaultProps: DefaultGLProps) => Renderer)
883
+ | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
884
+ | (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
885
+
886
+ //* WebGPU Renderer Props ==============================
887
+
888
+ type DefaultRendererProps = {
889
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
890
+ [key: string]: any
891
+ }
892
+
893
+ /**
894
+ * Canvas-level scheduler configuration.
895
+ * Controls render timing relative to other canvases.
896
+ */
897
+ interface CanvasSchedulerConfig {
898
+ /**
899
+ * Render this canvas after another canvas completes.
900
+ * Pass the `id` of another canvas.
901
+ */
902
+ after?: string
903
+ /**
904
+ * Limit this canvas's render rate (frames per second).
905
+ */
906
+ fps?: number
907
+ }
908
+
909
+ /**
910
+ * Extended renderer configuration for multi-canvas support and color management.
911
+ */
912
+ interface RendererConfigExtended extends ColorManagementConfig {
913
+ /** Share renderer from another canvas (WebGPU only) */
914
+ primaryCanvas?: string
915
+ /** Canvas-level scheduler options */
916
+ scheduler?: CanvasSchedulerConfig
917
+ }
918
+
919
+ type RendererProps =
920
+ | any // WebGPURenderer
921
+ | ((defaultProps: DefaultRendererProps) => any)
922
+ | ((defaultProps: DefaultRendererProps) => Promise<any>)
923
+ | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
924
+
925
+ //* Camera Props ==============================
926
+
927
+ type CameraProps = (
928
+ | THREE$1.Camera
929
+ | Partial<
930
+ ThreeElement<typeof THREE$1.Camera> &
931
+ ThreeElement<typeof THREE$1.PerspectiveCamera> &
932
+ ThreeElement<typeof THREE$1.OrthographicCamera>
933
+ >
934
+ ) & {
935
+ /** Flags the camera as manual, putting projection into your own hands */
936
+ manual?: boolean
937
+ }
938
+
939
+ //* Render Props ==============================
940
+
941
+ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
942
+ /**
943
+ * Unique identifier for multi-canvas renderer sharing.
944
+ * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
945
+ * Also sets the HTML `id` attribute on the canvas element.
946
+ * @example <Canvas id="main-viewer">...</Canvas>
947
+ */
948
+ id?: string
949
+ /**
950
+ * Share the renderer from another canvas instead of creating a new one.
951
+ * Pass the `id` of the primary canvas to share its WebGPURenderer.
952
+ * Only available with WebGPU (not legacy WebGL).
953
+ *
954
+ * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
955
+ * @internal
956
+ */
957
+ primaryCanvas?: string
958
+ /**
959
+ * Canvas-level scheduler options. Controls render timing relative to other canvases.
960
+ *
961
+ * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
962
+ * @internal
963
+ */
964
+ scheduler?: CanvasSchedulerConfig
965
+ /** A threejs renderer instance or props that go into the default renderer */
966
+ gl?: GLProps
967
+ /** A WebGPU renderer instance or props that go into the default renderer */
968
+ renderer?: RendererProps
969
+ /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
970
+ size?: Size
971
+ /**
972
+ * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
973
+ * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
974
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
975
+ */
976
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
977
+ /** Creates an orthographic camera */
978
+ orthographic?: boolean
979
+ /**
980
+ * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
981
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
982
+ */
983
+ frameloop?: Frameloop
984
+ /**
985
+ * R3F performance options for adaptive performance.
986
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
987
+ */
988
+ performance?: Partial<Omit<Performance, 'regress'>>
989
+ /** Target pixel ratio. Can clamp between a range: `[min, max]` */
990
+ dpr?: Dpr
991
+ /** Props that go into the default raycaster */
992
+ raycaster?: Partial<THREE$1.Raycaster>
993
+ /** A `THREE.Scene` instance or props that go into the default scene */
994
+ scene?: THREE$1.Scene | Partial<THREE$1.Scene>
995
+ /** A `THREE.Camera` instance or props that go into the default camera */
996
+ camera?: CameraProps
997
+ /** An R3F event manager to manage elements' pointer events */
998
+ events?: (store: RootStore) => EventManager<HTMLElement>
999
+ /** Callback after the canvas has rendered (but not yet committed) */
1000
+ onCreated?: (state: RootState) => void
1001
+ /** Response for pointer clicks that have missed any target */
1002
+ onPointerMissed?: (event: MouseEvent) => void
1003
+ /** Response for dragover events that have missed any target */
1004
+ onDragOverMissed?: (event: DragEvent) => void
1005
+ /** Response for drop events that have missed any target */
1006
+ onDropMissed?: (event: DragEvent) => void
1007
+ /** Whether to automatically update the frustum each frame (default: true) */
1008
+ autoUpdateFrustum?: boolean
1009
+ /**
1010
+ * Enable WebGPU occlusion queries for onOccluded/onVisible events.
1011
+ * Auto-enabled when any object uses onOccluded or onVisible handlers.
1012
+ * Only works with WebGPU renderer - WebGL will log a warning.
1013
+ */
1014
+ occlusion?: boolean
1015
+ /** Internal: stored size props from Canvas for reset functionality */
1016
+ _sizeProps?: { width?: number; height?: number } | null
1017
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1018
+ forceEven?: boolean
1019
+ }
1020
+
1021
+ //* Reconciler Root ==============================
1022
+
1023
+ interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
1024
+ configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
1025
+ render: (element: ReactNode) => RootStore
1026
+ unmount: () => void
1027
+ }
1028
+
1029
+ //* Inject State ==============================
1030
+
1031
+ type InjectState = Partial<
1032
+ Omit<RootState, 'events'> & {
1033
+ events?: {
1034
+ enabled?: boolean
1035
+ priority?: number
1036
+ compute?: ComputeFunction
1037
+ connected?: any
1038
+ }
1039
+ /**
1040
+ * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
1041
+ * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
1042
+ * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
1043
+ */
1044
+ injectScene?: boolean
1045
+ }
1046
+ >
1047
+
1048
+ //* Reconciler Types ==============================
1049
+
1050
+ // FiberRoot is an opaque internal React type - we define it locally
1051
+ // to avoid bundling @types/react-reconciler which causes absolute path issues
1052
+ type FiberRoot = any
1053
+
1054
+ interface Root {
1055
+ fiber: FiberRoot
1056
+ store: RootStore
1057
+ }
1058
+
1059
+ type AttachFnType<O = any> = (parent: any, self: O) => () => void
1060
+ type AttachType<O = any> = string | AttachFnType<O>
1061
+
1062
+ type ConstructorRepresentation<T = any> = new (...args: any[]) => T
1063
+
1064
+ interface Catalogue {
1065
+ [name: string]: ConstructorRepresentation
1066
+ }
1067
+
1068
+ // TODO: handle constructor overloads
1069
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
1070
+ // https://github.com/microsoft/TypeScript/issues/37079
1071
+ type Args<T> = T extends ConstructorRepresentation
1072
+ ? T extends typeof Color$1
1073
+ ? [r: number, g: number, b: number] | [color: ColorRepresentation]
1074
+ : ConstructorParameters<T>
1075
+ : any[]
1076
+
1077
+ type ArgsProp<P> = P extends ConstructorRepresentation
1078
+ ? IsAllOptional<ConstructorParameters<P>> extends true
1079
+ ? { args?: Args<P> }
1080
+ : { args: Args<P> }
1081
+ : { args: unknown[] }
1082
+
1083
+ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
1084
+ object?: T
1085
+ dispose?: null
1086
+ attach?: AttachType<T>
1087
+ onUpdate?: (self: T) => void
1088
+ }
1089
+
1090
+ interface Instance<O = any> {
1091
+ root: RootStore
1092
+ type: string
1093
+ parent: Instance | null
1094
+ children: Instance[]
1095
+ props: InstanceProps<O> & Record<string, unknown>
1096
+ object: O & { __r3f?: Instance<O> }
1097
+ eventCount: number
1098
+ handlers: Partial<EventHandlers>
1099
+ attach?: AttachType<O>
1100
+ previousAttach?: any
1101
+ isHidden: boolean
1102
+ /** Deferred ref props to apply in commitMount */
1103
+ deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
1104
+ /** Set of props that have been applied via once() */
1105
+ appliedOnce?: Set<string>
1106
+ }
1107
+
1108
+ interface HostConfig {
1109
+ type: string
1110
+ props: Instance['props']
1111
+ container: RootStore
1112
+ instance: Instance
1113
+ textInstance: void
1114
+ suspenseInstance: Instance
1115
+ hydratableInstance: never
1116
+ formInstance: never
1117
+ publicInstance: Instance['object']
1118
+ hostContext: {}
1119
+ childSet: never
1120
+ timeoutHandle: number | undefined
1121
+ noTimeout: -1
1122
+ TransitionStatus: null
1123
+ }
1124
+ declare global {
1125
+ var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
1126
+ }
1127
+
1128
+ //* Loop Types ==============================
1129
+
1130
+ type GlobalRenderCallback = (timestamp: number) => void
1131
+
1132
+ type GlobalEffectType = 'before' | 'after' | 'tail'
1133
+
1134
+ declare const presetsObj: {
1135
+ apartment: string;
1136
+ city: string;
1137
+ dawn: string;
1138
+ forest: string;
1139
+ lobby: string;
1140
+ night: string;
1141
+ park: string;
1142
+ studio: string;
1143
+ sunset: string;
1144
+ warehouse: string;
1145
+ };
1146
+ type PresetsType = keyof typeof presetsObj;
1147
+
1148
+ //* Background Types ==============================
1149
+
1150
+ /**
1151
+ * Expanded object form for background configuration.
1152
+ * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
1153
+ */
1154
+ interface BackgroundConfig {
1155
+ /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
1156
+ preset?: PresetsType
1157
+ /** Files for cube texture (6 faces) or single HDR/EXR */
1158
+ files?: string | string[]
1159
+ /** Separate files for scene.background (visual backdrop) */
1160
+ backgroundMap?: string | string[]
1161
+ backgroundRotation?: Euler$1 | [number, number, number]
1162
+ backgroundBlurriness?: number
1163
+ backgroundIntensity?: number
1164
+ /** Separate files for scene.environment (PBR lighting/reflections) */
1165
+ envMap?: string | string[]
1166
+ environmentRotation?: Euler$1 | [number, number, number]
1167
+ environmentIntensity?: number
1168
+ path?: string
1169
+ extensions?: (loader: Loader) => void
1170
+ }
1171
+
1172
+ /**
1173
+ * Background prop type for Canvas.
1174
+ *
1175
+ * String detection priority:
1176
+ * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1177
+ * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
1178
+ * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
1179
+ *
1180
+ * @example Color
1181
+ * ```tsx
1182
+ * <Canvas background="red" />
1183
+ * <Canvas background="#ff0000" />
1184
+ * <Canvas background={0xff0000} />
1185
+ * ```
1186
+ *
1187
+ * @example Preset
1188
+ * ```tsx
1189
+ * <Canvas background="city" />
1190
+ * ```
1191
+ *
1192
+ * @example URL
1193
+ * ```tsx
1194
+ * <Canvas background="/path/to/env.hdr" />
1195
+ * <Canvas background="./sky.jpg" />
1196
+ * ```
1197
+ *
1198
+ * @example Object form
1199
+ * ```tsx
1200
+ * <Canvas background={{
1201
+ * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1202
+ * backgroundMap: 'path/to/sky.jpg',
1203
+ * envMap: 'path/to/lighting.hdr',
1204
+ * backgroundBlurriness: 0.5,
1205
+ * }} />
1206
+ * ```
1207
+ */
1208
+ type BackgroundProp =
1209
+ | ColorRepresentation // "red", "#ff0000", 0xff0000
1210
+ | string // URL or preset
1211
+ | BackgroundConfig // Expanded object form
1212
+
1213
+ //* Canvas Types ==============================
1214
+
1215
+ interface CanvasProps
1216
+ extends
1217
+ Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1218
+ React$1.HTMLAttributes<HTMLDivElement> {
1219
+ children?: React$1.ReactNode
1220
+ ref?: React$1.Ref<HTMLCanvasElement>
1221
+ /** Canvas fallback content, similar to img's alt prop */
1222
+ fallback?: React$1.ReactNode
1223
+ /**
1224
+ * Options to pass to useMeasure.
1225
+ * @see https://github.com/pmndrs/react-use-measure#api
1226
+ */
1227
+ resize?: Options
1228
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
1229
+ eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1230
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1231
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1232
+ /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1233
+ hmr?: boolean
1234
+ /** Canvas resolution width in pixels. If omitted, uses container width. */
1235
+ width?: number
1236
+ /** Canvas resolution height in pixels. If omitted, uses container height. */
1237
+ height?: number
1238
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1239
+ forceEven?: boolean
1240
+ /**
1241
+ * Scene background configuration.
1242
+ * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1243
+ * @see BackgroundProp for full documentation and examples
1244
+ */
1245
+ background?: BackgroundProp
1246
+ }
1247
+
1248
+ //* Loader Types ==============================
1249
+
1250
+ type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1251
+
1252
+ // Define a loader-like interface that matches THREE.Loader's load signature
1253
+ // This works for both generic and non-generic THREE.Loader instances
1254
+ interface LoaderLike {
1255
+ load(
1256
+ url: InputLike,
1257
+ onLoad?: (result: any) => void,
1258
+ onProgress?: (event: ProgressEvent<EventTarget>) => void,
1259
+ onError?: (error: unknown) => void,
1260
+ ): any
1261
+ }
1262
+
1263
+ type GLTFLike = { scene: THREE$1.Object3D }
1264
+
1265
+ type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1266
+ T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1267
+
1268
+ // Infer result type from the load method's callback parameter
1269
+ type InferLoadResult<T> = T extends {
1270
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1271
+ }
1272
+ ? R
1273
+ : T extends ConstructorRepresentation<any>
1274
+ ? InstanceType<T> extends {
1275
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1276
+ }
1277
+ ? R
1278
+ : any
1279
+ : any
1280
+
1281
+ type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1282
+ InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1283
+
1284
+ type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1285
+ loader: LoaderInstance<T>,
1286
+ ) => void
1287
+
1288
+ //* Renderer Props ========================================
1289
+
1290
+ type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1291
+
1292
+ type WebGLProps =
1293
+ | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1294
+ | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1295
+
1296
+ interface WebGLShadowConfig {
1297
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1298
+ }
1299
+
1300
+ //* Legacy-specific Types ========================================
1301
+
1302
+ /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1303
+ type LegacyRenderer = THREE$1.WebGLRenderer
1304
+
1305
+ /** Legacy internal state with narrowed renderer type */
1306
+ interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1307
+ actualRenderer: THREE$1.WebGLRenderer
1308
+ }
1309
+
1310
+ /**
1311
+ * Legacy-specific RootState with narrowed renderer type.
1312
+ * Automatically used when importing from `@react-three/fiber/legacy`.
1313
+ *
1314
+ * @example
1315
+ * ```tsx
1316
+ * import { useThree } from '@react-three/fiber/legacy'
1317
+ *
1318
+ * function MyComponent() {
1319
+ * const { renderer } = useThree()
1320
+ * // renderer is typed as THREE.WebGLRenderer
1321
+ * renderer.shadowMap.enabled = true
1322
+ * }
1323
+ * ```
1324
+ */
1325
+ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1326
+ /** The WebGL renderer instance */
1327
+ renderer: THREE$1.WebGLRenderer
1328
+ /** Internals with WebGL renderer */
1329
+ internal: LegacyInternalState
1330
+ }
1331
+
1332
+ //* RenderTarget Types ==============================
1333
+
1334
+
1335
+ type RenderTargetOptions = RenderTargetOptions$1
1336
+
1337
+ //* Global Types ==============================
1338
+
1339
+ declare global {
1340
+ /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
1341
+ interface UniformNode<T = unknown> extends Node {
1342
+ value: T
1343
+ }
1344
+
1345
+ /**
1346
+ * ShaderCallable - the return type of Fn()
1347
+ * A callable shader function node that can be invoked with parameters.
1348
+ * The function returns a ShaderNodeObject when called.
1349
+ *
1350
+ * @example
1351
+ * ```tsx
1352
+ * // Define a shader function
1353
+ * const blendColorFn = Fn(([color1, color2, factor]) => {
1354
+ * return mix(color1, color2, factor)
1355
+ * })
1356
+ *
1357
+ * // Type when retrieving from nodes store
1358
+ * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1359
+ *
1360
+ * // Or with specific return type
1361
+ * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1362
+ * ```
1363
+ */
1364
+ type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1365
+
1366
+ /**
1367
+ * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1368
+ * This is the common return type for TSL operations (add, mul, sin, etc.)
1369
+ *
1370
+ * @example
1371
+ * ```tsx
1372
+ * const { wobble } = nodes as { wobble: ShaderNodeRef }
1373
+ * ```
1374
+ */
1375
+ type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1376
+
1377
+ /**
1378
+ * TSLNodeType - Union of all common TSL node types
1379
+ * Used by ScopedStore to properly type node access from the store.
1380
+ *
1381
+ * Includes:
1382
+ * - Node: base Three.js node type
1383
+ * - ShaderCallable: function nodes created with Fn()
1384
+ * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1385
+ *
1386
+ * @example
1387
+ * ```tsx
1388
+ * // In useLocalNodes, nodes are typed as TSLNodeType
1389
+ * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1390
+ * positionNode: nodes.myPosition, // Works - Node is in union
1391
+ * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1392
+ * }))
1393
+ *
1394
+ * // Can narrow with type guard or assertion when needed
1395
+ * if (typeof blendColorFn === 'function') {
1396
+ * blendColorFn(someColor, 0.5)
1397
+ * }
1398
+ * ```
1399
+ */
1400
+ type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1401
+
1402
+ /** Flat record of uniform nodes (no nested scopes) */
1403
+ type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1404
+
1405
+ /**
1406
+ * Uniform store that can contain both root-level uniforms and scoped uniform objects
1407
+ * Used by state.uniforms which has structure like:
1408
+ * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1409
+ */
1410
+ type UniformStore = Record<string, UniformNode | UniformRecord>
1411
+
1412
+ /**
1413
+ * Helper to safely access a uniform node from the store.
1414
+ * Use this when accessing state.uniforms to get proper typing.
1415
+ * @example
1416
+ * const uTime = uniforms.uTime as UniformNode<number>
1417
+ * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1418
+ */
1419
+ type GetUniform<T = unknown> = UniformNode<T>
1420
+
1421
+ /**
1422
+ * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1423
+ * Supports:
1424
+ * - Primitives: number, string (color), boolean
1425
+ * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1426
+ * - Plain objects: { x, y, z, w } converted to vectors
1427
+ * - TSL nodes: color(), vec3(), float() for type casting
1428
+ * - UniformNode: existing uniforms (reused as-is)
1429
+ */
1430
+ type UniformValue =
1431
+ | number
1432
+ | string
1433
+ | boolean
1434
+ | three_webgpu.Color
1435
+ | three_webgpu.Vector2
1436
+ | three_webgpu.Vector3
1437
+ | three_webgpu.Vector4
1438
+ | three_webgpu.Matrix3
1439
+ | three_webgpu.Matrix4
1440
+ | three_webgpu.Euler
1441
+ | three_webgpu.Quaternion
1442
+ | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1443
+ | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1444
+ | Node // TSL nodes like color(), vec3(), float() for type casting
1445
+ | UniformNode
1446
+
1447
+ /** Input record for useUniforms - accepts raw values or UniformNodes */
1448
+ type UniformInputRecord = Record<string, UniformValue>
1449
+ }
1450
+
1451
+ //* Module Augmentation ==============================
1452
+
1453
+ declare module 'three/tsl' {
1454
+ /**
1455
+ * Fn with array parameter destructuring
1456
+ * @example Fn(([uv, skew]) => { ... })
1457
+ */
1458
+ export function Fn<R extends Node = Node>(
1459
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1460
+ ): ShaderCallable<R>
1461
+
1462
+ /**
1463
+ * Fn with object parameter destructuring
1464
+ * @example Fn(({ color, intensity }) => { ... })
1465
+ */
1466
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1467
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1468
+ ): ShaderCallable<R>
1469
+
1470
+ /**
1471
+ * Fn with array params + layout
1472
+ * @example Fn(([a, b]) => { ... }, { layout: [...] })
1473
+ */
1474
+ export function Fn<R extends Node = Node>(
1475
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1476
+ layout: { layout?: unknown },
1477
+ ): ShaderCallable<R>
1478
+
1479
+ /**
1480
+ * Fn with object params + layout
1481
+ */
1482
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1483
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1484
+ layout: { layout?: unknown },
1485
+ ): ShaderCallable<R>
1486
+ }
1487
+
1488
+ /**
1489
+ * RenderPipeline Types for useRenderPipeline hook (WebGPU only)
1490
+ */
1491
+
1492
+
1493
+
1494
+ declare global {
1495
+ /** Pass record - stores TSL pass nodes for render pipeline */
1496
+ type PassRecord = Record<string, any>
1497
+
1498
+ /** Setup callback - runs first to configure MRT, create additional passes */
1499
+ type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1500
+
1501
+ /** Main callback - runs second to configure outputNode, create effect passes */
1502
+ type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1503
+
1504
+ /** Return type for useRenderPipeline hook */
1505
+ interface UseRenderPipelineReturn {
1506
+ /** Current passes from state */
1507
+ passes: PassRecord
1508
+ /** RenderPipeline instance (null if not initialized) */
1509
+ renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
1510
+ /** Clear all passes from state */
1511
+ clearPasses: () => void
1512
+ /** Reset RenderPipeline entirely (clears PP + passes) */
1513
+ reset: () => void
1514
+ /** Re-run setup/main callbacks with current closure values */
1515
+ rebuild: () => void
1516
+ /** True when RenderPipeline is configured and ready */
1517
+ isReady: boolean
1518
+ }
1519
+ }
1520
+
1521
+ //* useFrameNext Types ==============================
1522
+
1523
+
1524
+
1525
+ //* Global Type Declarations ==============================
1526
+
1527
+ declare global {
1528
+ // Job --------------------------------
1529
+
1530
+ /**
1531
+ * Internal job representation in the scheduler
1532
+ */
1533
+ interface Job {
1534
+ /** Unique identifier */
1535
+ id: string
1536
+ /** The callback to execute */
1537
+ callback: FrameNextCallback
1538
+ /** Phase this job belongs to */
1539
+ phase: string
1540
+ /** Run before these phases/job ids */
1541
+ before: Set<string>
1542
+ /** Run after these phases/job ids */
1543
+ after: Set<string>
1544
+ /** Priority within phase (higher first) */
1545
+ priority: number
1546
+ /** Insertion order for deterministic tie-breaking */
1547
+ index: number
1548
+ /** Max FPS for this job (undefined = no limit) */
1549
+ fps?: number
1550
+ /** Drop frames when behind (true) or catch up (false) */
1551
+ drop: boolean
1552
+ /** Last run timestamp (ms) */
1553
+ lastRun?: number
1554
+ /** Whether job is enabled */
1555
+ enabled: boolean
1556
+ /** Internal flag: system jobs (like default render) don't block user render takeover */
1557
+ system?: boolean
1558
+ }
1559
+
1560
+ // Phase Graph --------------------------------
1561
+
1562
+ /**
1563
+ * A node in the phase graph
1564
+ */
1565
+ interface PhaseNode {
1566
+ /** Phase name */
1567
+ name: string
1568
+ /** Whether this was auto-generated from a before/after constraint */
1569
+ isAutoGenerated: boolean
1570
+ }
1571
+
1572
+ /**
1573
+ * Options for creating a job from hook options
1574
+ */
1575
+ interface JobOptions {
1576
+ id?: string
1577
+ phase?: string
1578
+ before?: string | string[]
1579
+ after?: string | string[]
1580
+ priority?: number
1581
+ fps?: number
1582
+ drop?: boolean
1583
+ enabled?: boolean
1584
+ }
1585
+
1586
+ // Frame Loop State --------------------------------
1587
+
1588
+ /**
1589
+ * Internal frame loop state
1590
+ */
1591
+ interface FrameLoopState {
1592
+ /** Whether the loop is running */
1593
+ running: boolean
1594
+ /** Current RAF handle */
1595
+ rafHandle: number | null
1596
+ /** Last frame timestamp in ms (null = uninitialized) */
1597
+ lastTime: number | null
1598
+ /** Frame counter */
1599
+ frameCount: number
1600
+ /** Elapsed time since first frame in ms */
1601
+ elapsedTime: number
1602
+ /** createdAt timestamp in ms */
1603
+ createdAt: number
1604
+ }
1605
+
1606
+ // Root Entry --------------------------------
1607
+
1608
+ /**
1609
+ * Internal representation of a registered root (Canvas).
1610
+ * Tracks jobs and manages rebuild state for this root.
1611
+ * @internal
1612
+ */
1613
+ interface RootEntry {
1614
+ /** Unique identifier for this root */
1615
+ id: string
1616
+ /** Function to get the root's current state. Returns any to support independent mode. */
1617
+ getState: () => any
1618
+ /** Map of job IDs to Job objects */
1619
+ jobs: Map<string, Job>
1620
+ /** Cached sorted job list for execution order */
1621
+ sortedJobs: Job[]
1622
+ /** Whether sortedJobs needs rebuilding */
1623
+ needsRebuild: boolean
1624
+ }
1625
+
1626
+ /**
1627
+ * Internal representation of a global job (deprecated API).
1628
+ * Global jobs run once per frame, not per-root.
1629
+ * Used by legacy addEffect/addAfterEffect APIs.
1630
+ * @internal
1631
+ * @deprecated Use useFrame with phases instead
1632
+ */
1633
+ interface GlobalJob {
1634
+ /** Unique identifier for this global job */
1635
+ id: string
1636
+ /** Callback invoked with RAF timestamp in ms */
1637
+ callback: (timestamp: number) => void
1638
+ }
1639
+
1640
+ // HMR Support --------------------------------
1641
+
1642
+ /**
1643
+ * Hot Module Replacement data structure for preserving scheduler state
1644
+ * @internal
1645
+ */
1646
+ interface HMRData {
1647
+ /** Shared data object for storing values across reloads */
1648
+ data: Record<string, any>
1649
+ /** Optional function to accept HMR updates */
1650
+ accept?: () => void
1651
+ }
1652
+
1653
+ // Default Phases --------------------------------
1654
+
1655
+ /**
1656
+ * Default phase names for the scheduler
1657
+ */
1658
+ type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1659
+ }
1660
+
1661
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1662
+
1663
+ interface MathRepresentation {
1664
+ set(...args: number[]): any
1665
+ }
1666
+ interface VectorRepresentation extends MathRepresentation {
1667
+ setScalar(value: number): any
1668
+ }
1669
+ type MathTypes = MathRepresentation | Euler$2 | Color$2
1670
+
1671
+ type MathType<T extends MathTypes> = T extends Color$2
1672
+ ? Args<typeof Color$2> | ColorRepresentation$1
1673
+ : T extends VectorRepresentation | Layers$1 | Euler$2
1674
+ ? T | MutableOrReadonlyParameters<T['set']> | number
1675
+ : T | MutableOrReadonlyParameters<T['set']>
1676
+
1677
+ type MathProps<P> = {
1678
+ [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1679
+ }
1680
+
1681
+ type Vector2 = MathType<Vector2$1>
1682
+ type Vector3 = MathType<Vector3$1>
1683
+ type Vector4 = MathType<Vector4$1>
1684
+ type Color = MathType<Color$2>
1685
+ type Layers = MathType<Layers$1>
1686
+ type Quaternion = MathType<Quaternion$1>
1687
+ type Euler = MathType<Euler$2>
1688
+ type Matrix3 = MathType<Matrix3$1>
1689
+ type Matrix4 = MathType<Matrix4$1>
1690
+
1691
+ interface RaycastableRepresentation {
1692
+ raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1693
+ }
1694
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1695
+
1696
+ /**
1697
+ * Props for geometry transform methods that can be called with `once()`.
1698
+ * These methods modify the geometry in-place and only make sense to call once on mount.
1699
+ *
1700
+ * @example
1701
+ * import { once } from '@react-three/fiber'
1702
+ *
1703
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1704
+ * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1705
+ * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1706
+ */
1707
+ interface GeometryTransformProps {
1708
+ /** Rotate the geometry about the X axis (radians). Use with once(). */
1709
+ rotateX?: number
1710
+ /** Rotate the geometry about the Y axis (radians). Use with once(). */
1711
+ rotateY?: number
1712
+ /** Rotate the geometry about the Z axis (radians). Use with once(). */
1713
+ rotateZ?: number
1714
+ /** Translate the geometry (x, y, z). Use with once(). */
1715
+ translate?: [x: number, y: number, z: number]
1716
+ /** Scale the geometry (x, y, z). Use with once(). */
1717
+ scale?: [x: number, y: number, z: number]
1718
+ /** Center the geometry based on bounding box. Use with once(). */
1719
+ center?: true
1720
+ /** Apply a Matrix4 transformation. Use with once(). */
1721
+ applyMatrix4?: Matrix4$1
1722
+ /** Apply a Quaternion rotation. Use with once(). */
1723
+ applyQuaternion?: Quaternion$1
1724
+ }
1725
+
1726
+ type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
1727
+
1728
+ /**
1729
+ * Workaround for @types/three TSL node type issues.
1730
+ * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1731
+ * This transforms `Node | null` properties to accept any object with node-like shape.
1732
+ */
1733
+ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1734
+
1735
+ /**
1736
+ * For node material properties (colorNode, positionNode, etc.), accept broader types
1737
+ * since @types/three has broken inheritance for TSL node subclasses.
1738
+ */
1739
+ type NodeProps<P> = {
1740
+ [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1741
+ }
1742
+
1743
+ interface ReactProps<P> {
1744
+ children?: React.ReactNode
1745
+ ref?: React.Ref<P>
1746
+ key?: React.Key
1747
+ }
1748
+
1749
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1750
+ Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1751
+ >
1752
+
1753
+ type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1754
+ Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1755
+ >
1756
+
1757
+ type ThreeToJSXElements<T extends Record<string, any>> = {
1758
+ [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1759
+ }
1760
+
1761
+ type ThreeExports = typeof import('three/webgpu')
1762
+ type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1763
+
1764
+ interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1765
+ primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1766
+ // Conflicts with DOM types can be accessed through a three* prefix
1767
+ threeAudio: ThreeElementsImpl['audio']
1768
+ threeSource: ThreeElementsImpl['source']
1769
+ threeLine: ThreeElementsImpl['line']
1770
+ threePath: ThreeElementsImpl['path']
1771
+ }
1772
+
1773
+ declare module 'react' {
1774
+ namespace JSX {
1775
+ interface IntrinsicElements extends ThreeElements {}
1776
+ }
1777
+ }
1778
+
1779
+ declare module 'react/jsx-runtime' {
1780
+ namespace JSX {
1781
+ interface IntrinsicElements extends ThreeElements {}
1782
+ }
1783
+ }
1784
+
1785
+ declare module 'react/jsx-dev-runtime' {
1786
+ namespace JSX {
1787
+ interface IntrinsicElements extends ThreeElements {}
1788
+ }
1789
+ }
1790
+
1791
+ type three_d_Color = Color;
1792
+ type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1793
+ type three_d_Euler = Euler;
1794
+ type three_d_EventProps<P> = EventProps<P>;
1795
+ type three_d_GeometryProps<P> = GeometryProps<P>;
1796
+ type three_d_GeometryTransformProps = GeometryTransformProps;
1797
+ type three_d_Layers = Layers;
1798
+ type three_d_MathProps<P> = MathProps<P>;
1799
+ type three_d_MathRepresentation = MathRepresentation;
1800
+ type three_d_MathType<T extends MathTypes> = MathType<T>;
1801
+ type three_d_MathTypes = MathTypes;
1802
+ type three_d_Matrix3 = Matrix3;
1803
+ type three_d_Matrix4 = Matrix4;
1804
+ type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1805
+ type three_d_NodeProps<P> = NodeProps<P>;
1806
+ type three_d_Quaternion = Quaternion;
1807
+ type three_d_RaycastableRepresentation = RaycastableRepresentation;
1808
+ type three_d_ReactProps<P> = ReactProps<P>;
1809
+ type three_d_TSLNodeInput = TSLNodeInput;
1810
+ type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1811
+ type three_d_ThreeElements = ThreeElements;
1812
+ type three_d_ThreeElementsImpl = ThreeElementsImpl;
1813
+ type three_d_ThreeExports = ThreeExports;
1814
+ type three_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
1815
+ type three_d_Vector2 = Vector2;
1816
+ type three_d_Vector3 = Vector3;
1817
+ type three_d_Vector4 = Vector4;
1818
+ type three_d_VectorRepresentation = VectorRepresentation;
1819
+ declare namespace three_d {
1820
+ export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1821
+ }
1822
+
1823
+ /**
1824
+ * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1825
+ *
1826
+ * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1827
+ * a single WebGPURenderer using Three.js CanvasTarget API.
1828
+ *
1829
+ * Primary canvas: Has `id` prop, creates its own renderer, registers here
1830
+ * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1831
+ */
1832
+
1833
+ interface PrimaryCanvasEntry {
1834
+ /** The WebGPURenderer instance owned by this primary canvas */
1835
+ renderer: WebGPURenderer;
1836
+ /** The zustand store for this canvas */
1837
+ store: RootStore;
1838
+ }
1839
+ /**
1840
+ * Register a primary canvas that can be targeted by secondary canvases.
1841
+ *
1842
+ * @param id - Unique identifier for this primary canvas
1843
+ * @param renderer - The WebGPURenderer owned by this canvas
1844
+ * @param store - The zustand store for this canvas
1845
+ * @returns Cleanup function to unregister on unmount
1846
+ */
1847
+ declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1848
+ /**
1849
+ * Get a registered primary canvas by id.
1850
+ *
1851
+ * @param id - The id of the primary canvas to look up
1852
+ * @returns The primary canvas entry or undefined if not found
1853
+ */
1854
+ declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1855
+ /**
1856
+ * Wait for a primary canvas to be registered.
1857
+ * Returns immediately if already registered, otherwise waits.
1858
+ *
1859
+ * @param id - The id of the primary canvas to wait for
1860
+ * @param timeout - Optional timeout in ms (default: 5000)
1861
+ * @returns Promise that resolves with the primary canvas entry
1862
+ */
1863
+ declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1864
+ /**
1865
+ * Check if a primary canvas with the given id exists.
1866
+ *
1867
+ * @param id - The id to check
1868
+ * @returns True if a primary canvas with this id is registered
1869
+ */
1870
+ declare function hasPrimary(id: string): boolean;
1871
+ /**
1872
+ * Unregister a primary canvas. Called on unmount.
1873
+ *
1874
+ * @param id - The id of the primary canvas to unregister
1875
+ */
1876
+ declare function unregisterPrimary(id: string): void;
1877
+ /**
1878
+ * Get all registered primary canvas ids. Useful for debugging.
1879
+ */
1880
+ declare function getPrimaryIds(): string[];
1881
+
1882
+ type EnvironmentLoaderProps = {
1883
+ files?: string | string[];
1884
+ path?: string;
1885
+ preset?: PresetsType;
1886
+ extensions?: (loader: Loader$1) => void;
1887
+ colorSpace?: ColorSpace;
1888
+ };
1889
+ /**
1890
+ * Loads environment textures for reflections and lighting.
1891
+ * Supports HDR files, presets, and cubemaps.
1892
+ *
1893
+ * @example Basic usage
1894
+ * ```jsx
1895
+ * const texture = useEnvironment({ preset: 'sunset' })
1896
+ * ```
1897
+ */
1898
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1899
+ declare namespace useEnvironment {
1900
+ var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1901
+ var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1902
+ }
1903
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1904
+ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1905
+
1906
+ /**
1907
+ * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1908
+ *
1909
+ * @property children - React children to render into custom environment portal
1910
+ * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1911
+ * @property near - Near clipping plane for cube camera (default: 0.1)
1912
+ * @property far - Far clipping plane for cube camera (default: 1000)
1913
+ * @property resolution - Resolution of the cube render target (default: 256)
1914
+ * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1915
+ *
1916
+ * @property blur - @deprecated Use backgroundBlurriness instead
1917
+ * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1918
+ * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1919
+ * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1920
+ * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1921
+ * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1922
+ *
1923
+ * @property map - Pre-existing texture to use as environment map
1924
+ * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1925
+ * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1926
+ * @property ground - Ground projection settings. Use true for defaults or object with:
1927
+ * - height: Height of camera used to create env map (default: 15)
1928
+ * - radius: Radius of the world (default: 60)
1929
+ * - scale: Scale of backside projected sphere (default: 1000)
1930
+ *
1931
+ * Additional loader props:
1932
+ * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1933
+ * @property path - Base path for file loading
1934
+ * @property extensions - Texture extensions override
1935
+ */
1936
+ type EnvironmentProps = {
1937
+ children?: React$1.ReactNode;
1938
+ frames?: number;
1939
+ near?: number;
1940
+ far?: number;
1941
+ resolution?: number;
1942
+ background?: boolean | 'only';
1943
+ /** deprecated, use backgroundBlurriness */
1944
+ blur?: number;
1945
+ backgroundBlurriness?: number;
1946
+ backgroundIntensity?: number;
1947
+ backgroundRotation?: Euler$3;
1948
+ environmentIntensity?: number;
1949
+ environmentRotation?: Euler$3;
1950
+ map?: Texture$1;
1951
+ preset?: PresetsType;
1952
+ scene?: Scene | React$1.RefObject<Scene>;
1953
+ ground?: boolean | {
1954
+ radius?: number;
1955
+ height?: number;
1956
+ scale?: number;
1957
+ };
1958
+ /** Solid color for background (alternative to files/preset) */
1959
+ color?: ColorRepresentation$1;
1960
+ /** Separate files for background (when different from environment files) */
1961
+ backgroundFiles?: string | string[];
1962
+ } & EnvironmentLoaderProps;
1963
+ /**
1964
+ * Internal component that applies a pre-existing texture as environment map.
1965
+ * Sets scene.environment and optionally scene.background.
1966
+ *
1967
+ * @example
1968
+ * ```jsx
1969
+ * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1970
+ * ```
1971
+ */
1972
+ declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1973
+ /**
1974
+ * Internal component that loads environment textures from files or presets.
1975
+ * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1976
+ * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1977
+ *
1978
+ * @example With preset
1979
+ * ```jsx
1980
+ * <EnvironmentCube preset="sunset" />
1981
+ * ```
1982
+ *
1983
+ * @example From HDR file
1984
+ * ```jsx
1985
+ * <EnvironmentCube files="environment.hdr" />
1986
+ * ```
1987
+ *
1988
+ * @example From gainmap (smallest footprint)
1989
+ * ```jsx
1990
+ * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1991
+ * ```
1992
+ *
1993
+ * @example From cube faces
1994
+ * ```jsx
1995
+ * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1996
+ * ```
1997
+ */
1998
+ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1999
+ /**
2000
+ * Internal component that renders custom environment using a portal and cube camera.
2001
+ * Renders children into an off-buffer and films with a cube camera to create environment map.
2002
+ * Can be static (frames=1) or animated (frames=Infinity).
2003
+ *
2004
+ * @example Custom environment with sphere
2005
+ * ```jsx
2006
+ * <EnvironmentPortal background near={1} far={1000} resolution={256}>
2007
+ * <mesh scale={100}>
2008
+ * <sphereGeometry args={[1, 64, 64]} />
2009
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
2010
+ * </mesh>
2011
+ * </EnvironmentPortal>
2012
+ * ```
2013
+ *
2014
+ * @example Animated environment
2015
+ * ```jsx
2016
+ * <EnvironmentPortal frames={Infinity} resolution={256}>
2017
+ * <Float>
2018
+ * <mesh />
2019
+ * </Float>
2020
+ * </EnvironmentPortal>
2021
+ * ```
2022
+ *
2023
+ * @example Mixed with preset
2024
+ * ```jsx
2025
+ * <EnvironmentPortal preset="warehouse">
2026
+ * <mesh />
2027
+ * </EnvironmentPortal>
2028
+ * ```
2029
+ */
2030
+ 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;
2031
+ declare module '@react-three/fiber' {
2032
+ interface ThreeElements {
2033
+ groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
2034
+ }
2035
+ }
2036
+ /**
2037
+ * Sets up a global environment map for PBR materials and backgrounds.
2038
+ * Affects scene.environment and optionally scene.background unless a custom scene is passed.
2039
+ *
2040
+ * Supports multiple input methods:
2041
+ * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
2042
+ * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
2043
+ * - **Texture**: Pre-existing cube texture via `map` prop
2044
+ * - **Custom Scene**: Render children into environment using portal and cube camera
2045
+ * - **Ground Projection**: Project environment onto ground plane
2046
+ *
2047
+ * @remarks
2048
+ * - Preset property is NOT meant for production and may fail (relies on CDNs)
2049
+ * - Gainmap format has the smallest file footprint
2050
+ * - Use `frames={Infinity}` for animated environments with low resolution for performance
2051
+ * - Ground projection places models on the "ground" within the environment map
2052
+ * - Supports self-hosting with @pmndrs/assets using dynamic imports
2053
+ *
2054
+ * @example Basic preset usage
2055
+ * ```jsx
2056
+ * <Environment preset="sunset" />
2057
+ * ```
2058
+ *
2059
+ * @example From HDR file
2060
+ * ```jsx
2061
+ * <Environment files="/hdr/environment.hdr" />
2062
+ * ```
2063
+ *
2064
+ * @example From gainmap (smallest footprint)
2065
+ * ```jsx
2066
+ * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
2067
+ * ```
2068
+ *
2069
+ * @example With self-hosted assets
2070
+ * ```jsx
2071
+ * import { suspend } from 'suspend-react'
2072
+ * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
2073
+ *
2074
+ * <Environment files={suspend(city)} />
2075
+ * ```
2076
+ *
2077
+ * @example From existing texture
2078
+ * ```jsx
2079
+ * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
2080
+ * ```
2081
+ *
2082
+ * @example Custom environment scene
2083
+ * ```jsx
2084
+ * <Environment background near={1} far={1000} resolution={256}>
2085
+ * <mesh scale={100}>
2086
+ * <sphereGeometry args={[1, 64, 64]} />
2087
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
2088
+ * </mesh>
2089
+ * </Environment>
2090
+ * ```
2091
+ *
2092
+ * @example Animated environment
2093
+ * ```jsx
2094
+ * <Environment frames={Infinity} resolution={256}>
2095
+ * <Float>
2096
+ * <mesh />
2097
+ * </Float>
2098
+ * </Environment>
2099
+ * ```
2100
+ *
2101
+ * @example Mixed custom scene with preset
2102
+ * ```jsx
2103
+ * <Environment background preset="warehouse">
2104
+ * <mesh />
2105
+ * </Environment>
2106
+ * ```
2107
+ *
2108
+ * @example With ground projection
2109
+ * ```jsx
2110
+ * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
2111
+ * ```
2112
+ *
2113
+ * @example As background only
2114
+ * ```jsx
2115
+ * <Environment background="only" preset="sunset" />
2116
+ * ```
2117
+ *
2118
+ * @example With rotation and intensity
2119
+ * ```jsx
2120
+ * <Environment
2121
+ * background
2122
+ * backgroundBlurriness={0.5}
2123
+ * backgroundIntensity={0.8}
2124
+ * backgroundRotation={[0, Math.PI / 2, 0]}
2125
+ * environmentIntensity={1.2}
2126
+ * environmentRotation={[0, Math.PI / 4, 0]}
2127
+ * preset="studio"
2128
+ * />
2129
+ * ```
2130
+ */
2131
+ declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
2132
+
2133
+ declare function removeInteractivity(store: RootStore, object: Object3D): void;
2134
+ declare function createEvents(store: RootStore): {
2135
+ handlePointer: (name: string) => (event: DomEvent) => void;
2136
+ flushDeferredPointers: () => void;
2137
+ processDeferredPointer: (event: DomEvent, pointerId: number) => void;
2138
+ };
2139
+ /** Default R3F event manager for web */
2140
+ declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
2141
+
2142
+ /**
2143
+ * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
2144
+ * This allows external code to access loader methods like abort().
2145
+ */
2146
+ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
2147
+ /**
2148
+ * Synchronously loads and caches assets with a three loader.
2149
+ *
2150
+ * Note: this hook's caller must be wrapped with `React.Suspense`
2151
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
2152
+ */
2153
+ declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
2154
+ declare namespace useLoader {
2155
+ var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
2156
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
2157
+ var loader: typeof getLoader;
2158
+ }
2159
+
2160
+ /**
2161
+ * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
2162
+ *
2163
+ * Features:
2164
+ * - Single RAF loop for entire application
2165
+ * - Root registration (multiple Canvas support)
2166
+ * - Global phases for addEffect/addAfterEffect (deprecated)
2167
+ * - Per-root job management with phases, priorities, FPS throttling
2168
+ * - onIdle callbacks for addTail (deprecated)
2169
+ * - Demand mode support via invalidate()
2170
+ */
2171
+ declare class Scheduler {
2172
+ private static readonly INSTANCE_KEY;
2173
+ private static get instance();
2174
+ private static set instance(value);
2175
+ /**
2176
+ * Get the global scheduler instance (creates if doesn't exist).
2177
+ * Uses HMR data to preserve instance across hot reloads.
2178
+ * @returns {Scheduler} The singleton scheduler instance
2179
+ */
2180
+ static get(): Scheduler;
2181
+ /**
2182
+ * Reset the singleton instance. Stops the loop and clears all state.
2183
+ * Primarily used for testing to ensure clean state between tests.
2184
+ * @returns {void}
2185
+ */
2186
+ static reset(): void;
2187
+ private roots;
2188
+ private phaseGraph;
2189
+ private loopState;
2190
+ private stoppedTime;
2191
+ private nextRootIndex;
2192
+ private globalBeforeJobs;
2193
+ private globalAfterJobs;
2194
+ private nextGlobalIndex;
2195
+ private idleCallbacks;
2196
+ private nextJobIndex;
2197
+ private jobStateListeners;
2198
+ private pendingFrames;
2199
+ private _frameloop;
2200
+ private _independent;
2201
+ private errorHandler;
2202
+ private rootReadyCallbacks;
2203
+ get phases(): string[];
2204
+ get frameloop(): Frameloop;
2205
+ set frameloop(mode: Frameloop);
2206
+ get isRunning(): boolean;
2207
+ get isReady(): boolean;
2208
+ get independent(): boolean;
2209
+ set independent(value: boolean);
2210
+ constructor();
2211
+ /**
2212
+ * Register a root (Canvas) with the scheduler.
2213
+ * The first root to register starts the RAF loop (if frameloop='always').
2214
+ * @param {string} id - Unique identifier for this root
2215
+ * @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
2216
+ * @returns {() => void} Unsubscribe function to remove this root
2217
+ */
2218
+ registerRoot(id: string, options?: RootOptions): () => void;
2219
+ /**
2220
+ * Unregister a root from the scheduler.
2221
+ * Cleans up all job state listeners for this root's jobs.
2222
+ * The last root to unregister stops the RAF loop.
2223
+ * @param {string} id - The root ID to unregister
2224
+ * @returns {void}
2225
+ */
2226
+ unregisterRoot(id: string): void;
2227
+ /**
2228
+ * Subscribe to be notified when a root becomes available.
2229
+ * Fires immediately if a root already exists.
2230
+ * @param {() => void} callback - Function called when first root registers
2231
+ * @returns {() => void} Unsubscribe function
2232
+ */
2233
+ onRootReady(callback: () => void): () => void;
2234
+ /**
2235
+ * Notify all registered root-ready callbacks.
2236
+ * Called when the first root registers.
2237
+ * @returns {void}
2238
+ * @private
2239
+ */
2240
+ private notifyRootReady;
2241
+ /**
2242
+ * Ensure a default root exists for independent mode.
2243
+ * Creates a minimal root with no state provider.
2244
+ * @returns {void}
2245
+ * @private
2246
+ */
2247
+ private ensureDefaultRoot;
2248
+ /**
2249
+ * Trigger error handling for job errors.
2250
+ * Uses the bound error handler if available, otherwise logs to console.
2251
+ * @param {Error} error - The error to handle
2252
+ * @returns {void}
2253
+ */
2254
+ triggerError(error: Error): void;
2255
+ /**
2256
+ * Add a named phase to the scheduler's execution order.
2257
+ * Marks all roots for rebuild to incorporate the new phase.
2258
+ * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
2259
+ * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
2260
+ * @returns {void}
2261
+ * @example
2262
+ * scheduler.addPhase('physics', { before: 'update' });
2263
+ * scheduler.addPhase('postprocess', { after: 'render' });
2264
+ */
2265
+ addPhase(name: string, options?: AddPhaseOptions): void;
2266
+ /**
2267
+ * Check if a phase exists in the scheduler.
2268
+ * @param {string} name - The phase name to check
2269
+ * @returns {boolean} True if the phase exists
2270
+ */
2271
+ hasPhase(name: string): boolean;
2272
+ /**
2273
+ * Register a global job that runs once per frame (not per-root).
2274
+ * Used internally by deprecated addEffect/addAfterEffect APIs.
2275
+ * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
2276
+ * @param {string} id - Unique identifier for this global job
2277
+ * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
2278
+ * @returns {() => void} Unsubscribe function to remove this global job
2279
+ * @deprecated Use useFrame with phases instead
2280
+ */
2281
+ registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
2282
+ /**
2283
+ * Register an idle callback that fires when the loop stops.
2284
+ * Used internally by deprecated addTail API.
2285
+ * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
2286
+ * @returns {() => void} Unsubscribe function to remove this idle callback
2287
+ * @deprecated Use demand mode with invalidate() instead
2288
+ */
2289
+ onIdle(callback: (timestamp: number) => void): () => void;
2290
+ /**
2291
+ * Notify all registered idle callbacks.
2292
+ * Called when the loop stops in demand mode.
2293
+ * @param {number} timestamp - The RAF timestamp when idle occurred
2294
+ * @returns {void}
2295
+ * @private
2296
+ */
2297
+ private notifyIdle;
2298
+ /**
2299
+ * Register a job (frame callback) with a specific root.
2300
+ * This is the core registration method used by useFrame internally.
2301
+ * @param {FrameNextCallback} callback - The function to call each frame
2302
+ * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
2303
+ * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
2304
+ * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
2305
+ * @param {string} [options.phase] - Execution phase (defaults to 'update')
2306
+ * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
2307
+ * @param {number} [options.fps] - FPS throttle limit
2308
+ * @param {boolean} [options.drop] - Drop frames when behind (default true)
2309
+ * @param {boolean} [options.enabled] - Whether job is active (default true)
2310
+ * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
2311
+ * @returns {() => void} Unsubscribe function to remove this job
2312
+ */
2313
+ register(callback: FrameNextCallback, options?: JobOptions & {
2314
+ rootId?: string;
2315
+ system?: boolean;
2316
+ }): () => void;
2317
+ /**
2318
+ * Unregister a job by its ID.
2319
+ * Searches all roots if rootId is not provided.
2320
+ * @param {string} id - The job ID to unregister
2321
+ * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
2322
+ * @returns {void}
2323
+ */
2324
+ unregister(id: string, rootId?: string): void;
2325
+ /**
2326
+ * Update a job's options dynamically.
2327
+ * Searches all roots to find the job by ID.
2328
+ * Phase/constraint changes trigger a rebuild of the sorted job list.
2329
+ * @param {string} id - The job ID to update
2330
+ * @param {Partial<JobOptions>} options - The options to update
2331
+ * @returns {void}
2332
+ */
2333
+ updateJob(id: string, options: Partial<JobOptions>): void;
2334
+ /**
2335
+ * Check if a job is currently paused (disabled).
2336
+ * @param {string} id - The job ID to check
2337
+ * @returns {boolean} True if the job exists and is paused
2338
+ */
2339
+ isJobPaused(id: string): boolean;
2340
+ /**
2341
+ * Subscribe to state changes for a specific job.
2342
+ * Listener is called when job is paused or resumed.
2343
+ * @param {string} id - The job ID to subscribe to
2344
+ * @param {() => void} listener - Callback invoked on state changes
2345
+ * @returns {() => void} Unsubscribe function
2346
+ */
2347
+ subscribeJobState(id: string, listener: () => void): () => void;
2348
+ /**
2349
+ * Notify all listeners that a job's state has changed.
2350
+ * @param {string} id - The job ID that changed
2351
+ * @returns {void}
2352
+ * @private
2353
+ */
2354
+ private notifyJobStateChange;
2355
+ /**
2356
+ * Pause a job by ID (sets enabled=false).
2357
+ * Notifies any subscribed state listeners.
2358
+ * @param {string} id - The job ID to pause
2359
+ * @returns {void}
2360
+ */
2361
+ pauseJob(id: string): void;
2362
+ /**
2363
+ * Resume a paused job by ID (sets enabled=true).
2364
+ * Resets job timing to prevent frame accumulation.
2365
+ * Notifies any subscribed state listeners.
2366
+ * @param {string} id - The job ID to resume
2367
+ * @returns {void}
2368
+ */
2369
+ resumeJob(id: string): void;
2370
+ /**
2371
+ * Start the requestAnimationFrame loop.
2372
+ * Resets timing state (elapsedTime, frameCount) on start.
2373
+ * No-op if already running.
2374
+ * @returns {void}
2375
+ */
2376
+ start(): void;
2377
+ /**
2378
+ * Stop the requestAnimationFrame loop.
2379
+ * Cancels any pending RAF callback.
2380
+ * No-op if not running.
2381
+ * @returns {void}
2382
+ */
2383
+ stop(): void;
2384
+ /**
2385
+ * Request frames to be rendered in demand mode.
2386
+ * Accumulates pending frames (capped at 60) and starts the loop if not running.
2387
+ * No-op if frameloop is not 'demand'.
2388
+ * @param {number} [frames=1] - Number of frames to request
2389
+ * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
2390
+ * - `false` (default): Sets pending frames to the specified value (replaces existing count)
2391
+ * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
2392
+ * @returns {void}
2393
+ * @example
2394
+ * // Request a single frame render
2395
+ * scheduler.invalidate();
2396
+ *
2397
+ * @example
2398
+ * // Request 5 frames (e.g., for animations)
2399
+ * scheduler.invalidate(5);
2400
+ *
2401
+ * @example
2402
+ * // Set pending frames to exactly 3 (don't stack with existing)
2403
+ * scheduler.invalidate(3, false);
2404
+ *
2405
+ * @example
2406
+ * // Add 2 more frames to existing pending count
2407
+ * scheduler.invalidate(2, true);
2408
+ */
2409
+ invalidate(frames?: number, stackFrames?: boolean): void;
2410
+ /**
2411
+ * Reset timing state for deterministic testing.
2412
+ * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
2413
+ * @returns {void}
2414
+ */
2415
+ resetTiming(): void;
2416
+ /**
2417
+ * Manually execute a single frame for all roots.
2418
+ * Useful for frameloop='never' mode or testing scenarios.
2419
+ * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2420
+ * @returns {void}
2421
+ * @example
2422
+ * // Manual control mode
2423
+ * scheduler.frameloop = 'never';
2424
+ * scheduler.step(); // Execute one frame
2425
+ */
2426
+ step(timestamp?: number): void;
2427
+ /**
2428
+ * Manually execute a single job by its ID.
2429
+ * Useful for testing individual job callbacks in isolation.
2430
+ * @param {string} id - The job ID to step
2431
+ * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2432
+ * @returns {void}
2433
+ */
2434
+ stepJob(id: string, timestamp?: number): void;
2435
+ /**
2436
+ * Main RAF loop callback.
2437
+ * Executes frame, handles demand mode, and schedules next frame.
2438
+ * @param {number} timestamp - RAF timestamp in milliseconds
2439
+ * @returns {void}
2440
+ * @private
2441
+ */
2442
+ private loop;
2443
+ /**
2444
+ * Execute a single frame across all roots.
2445
+ * Order: globalBefore → each root's jobs → globalAfter
2446
+ * @param {number} timestamp - RAF timestamp in milliseconds
2447
+ * @returns {void}
2448
+ * @private
2449
+ */
2450
+ private executeFrame;
2451
+ /**
2452
+ * Run all global jobs from a job map.
2453
+ * Catches and logs errors without stopping execution.
2454
+ * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
2455
+ * @param {number} timestamp - RAF timestamp in milliseconds
2456
+ * @returns {void}
2457
+ * @private
2458
+ */
2459
+ private runGlobalJobs;
2460
+ /**
2461
+ * Execute all jobs for a single root in sorted order.
2462
+ * Rebuilds sorted job list if needed, then dispatches each job.
2463
+ * Errors are caught and propagated via triggerError.
2464
+ * @param {RootEntry} root - The root entry to tick
2465
+ * @param {number} timestamp - RAF timestamp in milliseconds
2466
+ * @param {number} delta - Time since last frame in seconds
2467
+ * @returns {void}
2468
+ * @private
2469
+ */
2470
+ private tickRoot;
2471
+ /**
2472
+ * Get the total number of registered jobs across all roots.
2473
+ * Includes both per-root jobs and global before/after jobs.
2474
+ * @returns {number} Total job count
2475
+ */
2476
+ getJobCount(): number;
2477
+ /**
2478
+ * Get all registered job IDs across all roots.
2479
+ * Includes both per-root jobs and global before/after jobs.
2480
+ * @returns {string[]} Array of all job IDs
2481
+ */
2482
+ getJobIds(): string[];
2483
+ /**
2484
+ * Get the number of registered roots (Canvas instances).
2485
+ * @returns {number} Number of registered roots
2486
+ */
2487
+ getRootCount(): number;
2488
+ /**
2489
+ * Check if any user (non-system) jobs are registered in a specific phase.
2490
+ * Used by the default render job to know if a user has taken over rendering.
2491
+ *
2492
+ * @param phase The phase to check
2493
+ * @param rootId Optional root ID to check (checks all roots if not provided)
2494
+ * @returns true if any user jobs exist in the phase
2495
+ */
2496
+ hasUserJobsInPhase(phase: string, rootId?: string): boolean;
2497
+ /**
2498
+ * Generate a unique root ID for automatic root registration.
2499
+ * @returns {string} A unique root ID in the format 'root_N'
2500
+ */
2501
+ generateRootId(): string;
2502
+ /**
2503
+ * Generate a unique job ID.
2504
+ * @returns {string} A unique job ID in the format 'job_N'
2505
+ * @private
2506
+ */
2507
+ private generateJobId;
2508
+ /**
2509
+ * Normalize before/after constraints to a Set.
2510
+ * Handles undefined, single string, or array inputs.
2511
+ * @param {string | string[] | undefined} value - The constraint value(s)
2512
+ * @returns {Set<string>} Normalized Set of constraint strings
2513
+ * @private
2514
+ */
2515
+ private normalizeConstraints;
2516
+ }
2517
+ /**
2518
+ * Get the global scheduler instance.
2519
+ * Creates one if it doesn't exist.
2520
+ */
2521
+ declare const getScheduler: () => Scheduler;
2522
+
2523
+ /**
2524
+ * Frame hook with phase-based ordering, priority, and FPS throttling.
2525
+ *
2526
+ * Works both inside and outside Canvas context:
2527
+ * - Inside Canvas: Full RootState (gl, scene, camera, etc.)
2528
+ * - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
2529
+ * - Outside Canvas (independent mode): Fires immediately with timing-only state
2530
+ *
2531
+ * Returns a controls object for manual stepping, pausing, and resuming.
2532
+ *
2533
+ * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
2534
+ * @param priorityOrOptions - Either a priority number (backwards compat) or options object
2535
+ * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
2536
+ *
2537
+ * @example
2538
+ * // Simple priority (backwards compat)
2539
+ * useFrame((state, delta) => { ... }, 5)
2540
+ *
2541
+ * @example
2542
+ * // With phase-based ordering
2543
+ * useFrame((state, delta) => { ... }, { phase: 'physics' })
2544
+ *
2545
+ * @example
2546
+ * // Outside Canvas - waits for Canvas to mount
2547
+ * function UI() {
2548
+ * useFrame((state, delta) => { syncUI(state.camera) });
2549
+ * return <button>...</button>;
2550
+ * }
2551
+ *
2552
+ * @example
2553
+ * // Independent mode - no Canvas needed
2554
+ * getScheduler().independent = true;
2555
+ * useFrame((state, delta) => { updateGame(delta) });
2556
+ *
2557
+ * @example
2558
+ * // Scheduler-only access (no callback)
2559
+ * const { scheduler } = useFrame()
2560
+ * scheduler.pauseJob('some-job-id')
2561
+ *
2562
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
2563
+ */
2564
+ declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
2565
+
2566
+ declare const IsObject: (url: unknown) => url is Record<string, string>;
2567
+ type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2568
+ type TextureRecord<T> = T extends Record<string, string> ? {
2569
+ [key in keyof T]: Texture$1;
2570
+ } : never;
2571
+ type SingleTexture<T> = T extends string ? Texture$1 : never;
2572
+ type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
2573
+ /** Options for useTexture hook */
2574
+ type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
2575
+ /** Callback when texture(s) finish loading */
2576
+ onLoad?: (texture: MappedTextureType<Url>) => void;
2577
+ /**
2578
+ * Cache the texture in R3F's global state for access via useTextures().
2579
+ * When true:
2580
+ * - Textures persist until explicitly disposed
2581
+ * - Returns existing cached textures if available (preserving modifications like colorSpace)
2582
+ * @default false
2583
+ */
2584
+ cache?: boolean;
2585
+ };
2586
+ /**
2587
+ * Load texture(s) using Three's TextureLoader with Suspense support.
2588
+ *
2589
+ * @param input - URL string, array of URLs, or object mapping keys to URLs
2590
+ * @param optionsOrOnLoad - Options object or legacy onLoad callback
2591
+ *
2592
+ * @example
2593
+ * ```tsx
2594
+ * // Single texture
2595
+ * const diffuse = useTexture('/textures/diffuse.png')
2596
+ *
2597
+ * // Multiple textures (array)
2598
+ * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
2599
+ *
2600
+ * // Named textures (object)
2601
+ * const { diffuse, normal } = useTexture({
2602
+ * diffuse: '/diffuse.png',
2603
+ * normal: '/normal.png'
2604
+ * })
2605
+ *
2606
+ * // With caching - returns same texture object across components
2607
+ * // Modifications (colorSpace, wrapS, etc.) are preserved
2608
+ * const diffuse = useTexture('/diffuse.png', { cache: true })
2609
+ * diffuse.colorSpace = THREE.SRGBColorSpace
2610
+ *
2611
+ * // Another component gets the SAME texture with colorSpace already set
2612
+ * const sameDiffuse = useTexture('/diffuse.png', { cache: true })
2613
+ *
2614
+ * // Access cache directly
2615
+ * const { get } = useTextures()
2616
+ * const cached = get('/diffuse.png')
2617
+ * ```
2618
+ */
2619
+ declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
2620
+ declare namespace useTexture {
2621
+ var preload: (url: string | string[]) => void;
2622
+ var clear: (input: string | string[]) => void;
2623
+ }
2624
+ declare const Texture: ({ children, input, onLoad, cache, }: {
2625
+ children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
2626
+ input: Parameters<typeof useTexture>[0];
2627
+ onLoad?: Parameters<typeof useTexture>[1];
2628
+ cache?: boolean;
2629
+ }) => react_jsx_runtime.JSX.Element;
2630
+
2631
+ type TextureEntry = Texture$1 | {
2632
+ value: Texture$1;
2633
+ [key: string]: any;
2634
+ };
2635
+ interface UseTexturesReturn {
2636
+ /** Map of all textures currently in cache */
2637
+ textures: Map<string, TextureEntry>;
2638
+ /** Get a specific texture by key (usually URL) */
2639
+ get: (key: string) => TextureEntry | undefined;
2640
+ /** Check if a texture exists in cache */
2641
+ has: (key: string) => boolean;
2642
+ /** Add a texture to the cache */
2643
+ add: (key: string, value: TextureEntry) => void;
2644
+ /** Add multiple textures to the cache */
2645
+ addMultiple: (items: Map<string, TextureEntry> | Record<string, TextureEntry>) => void;
2646
+ /** Remove a texture from cache (does NOT dispose GPU resources) */
2647
+ remove: (key: string) => void;
2648
+ /** Remove multiple textures from cache */
2649
+ removeMultiple: (keys: string[]) => void;
2650
+ /** Dispose a texture's GPU resources and remove from cache */
2651
+ dispose: (key: string) => void;
2652
+ /** Dispose multiple textures */
2653
+ disposeMultiple: (keys: string[]) => void;
2654
+ /** Dispose ALL cached textures - use with caution */
2655
+ disposeAll: () => void;
2656
+ }
2657
+ /**
2658
+ * Hook for managing the global texture cache in R3F state.
2659
+ *
2660
+ * Textures are stored in a Map with URL/path keys for efficient lookup.
2661
+ * Useful for sharing texture references across materials and components.
2662
+ *
2663
+ * @example
2664
+ * ```tsx
2665
+ * const { textures, add, get, remove, has, dispose } = useTextures()
2666
+ *
2667
+ * // Check if texture is already cached
2668
+ * if (!has('/textures/diffuse.png')) {
2669
+ * // Load with useTexture and cache: true, or manually add
2670
+ * const tex = useTexture('/textures/diffuse.png', { cache: true })
2671
+ * }
2672
+ *
2673
+ * // Access cached texture from anywhere
2674
+ * const diffuse = get('/textures/diffuse.png')
2675
+ * if (diffuse) material.map = diffuse
2676
+ *
2677
+ * // Remove from cache only (texture still in GPU memory)
2678
+ * remove('/textures/old.png')
2679
+ *
2680
+ * // Fully dispose (frees GPU memory + removes from cache)
2681
+ * dispose('/textures/unused.png')
2682
+ *
2683
+ * // Nuclear option - dispose everything
2684
+ * disposeAll()
2685
+ * ```
2686
+ */
2687
+ declare function useTextures(): UseTexturesReturn;
2688
+
2689
+ /**
2690
+ * Creates a render target compatible with the current renderer.
2691
+ *
2692
+ * - Legacy build: Returns WebGLRenderTarget
2693
+ * - WebGPU build: Returns RenderTarget
2694
+ * - Default build: Returns whichever matches the active renderer
2695
+ *
2696
+ * @example
2697
+ * ```tsx
2698
+ * // Use canvas size
2699
+ * const fbo = useRenderTarget()
2700
+ *
2701
+ * // Use canvas size with options
2702
+ * const fbo = useRenderTarget({ samples: 4 })
2703
+ *
2704
+ * // Square render target
2705
+ * const fbo = useRenderTarget(512)
2706
+ *
2707
+ * // Square render target with options
2708
+ * const fbo = useRenderTarget(512, { depthBuffer: true })
2709
+ *
2710
+ * // Explicit dimensions
2711
+ * const fbo = useRenderTarget(512, 256)
2712
+ *
2713
+ * // Explicit dimensions with options
2714
+ * const fbo = useRenderTarget(512, 256, { samples: 4 })
2715
+ * ```
2716
+ */
2717
+ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
2718
+ declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
2719
+ declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
2720
+
2721
+ /**
2722
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2723
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2724
+ */
2725
+ declare function useStore(): RootStore;
2726
+ /**
2727
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2728
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2729
+ */
2730
+ declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2731
+ /**
2732
+ * Exposes an object's {@link Instance}.
2733
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
2734
+ *
2735
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
2736
+ */
2737
+ declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
2738
+ /**
2739
+ * Returns a node graph of an object with named nodes & materials.
2740
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
2741
+ */
2742
+ declare function useGraph(object: Object3D): ObjectMap;
2743
+
2744
+ /**
2745
+ * Adds a global render callback which is called each frame BEFORE rendering.
2746
+ *
2747
+ * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
2748
+ * This function will be removed in a future version.
2749
+ *
2750
+ * @param callback - Function called each frame with timestamp
2751
+ * @returns Unsubscribe function
2752
+ *
2753
+ * @example
2754
+ * // OLD (deprecated)
2755
+ * const unsub = addEffect((timestamp) => { ... })
2756
+ *
2757
+ * // NEW
2758
+ * useFrame((state, delta) => { ... }, { phase: 'start' })
2759
+ *
2760
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
2761
+ */
2762
+ declare function addEffect(callback: GlobalRenderCallback): () => void;
2763
+ /**
2764
+ * Adds a global after-render callback which is called each frame AFTER rendering.
2765
+ *
2766
+ * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
2767
+ * This function will be removed in a future version.
2768
+ *
2769
+ * @param callback - Function called each frame with timestamp
2770
+ * @returns Unsubscribe function
2771
+ *
2772
+ * @example
2773
+ * // OLD (deprecated)
2774
+ * const unsub = addAfterEffect((timestamp) => { ... })
2775
+ *
2776
+ * // NEW
2777
+ * useFrame((state, delta) => { ... }, { phase: 'finish' })
2778
+ *
2779
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
2780
+ */
2781
+ declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
2782
+ /**
2783
+ * Adds a global callback which is called when rendering stops.
2784
+ *
2785
+ * @deprecated Use `scheduler.onIdle(callback)` instead.
2786
+ * This function will be removed in a future version.
2787
+ *
2788
+ * @param callback - Function called when rendering stops
2789
+ * @returns Unsubscribe function
2790
+ *
2791
+ * @example
2792
+ * // OLD (deprecated)
2793
+ * const unsub = addTail((timestamp) => { ... })
2794
+ *
2795
+ * // NEW
2796
+ * const { scheduler } = useFrame()
2797
+ * const unsub = scheduler.onIdle((timestamp) => { ... })
2798
+ *
2799
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
2800
+ */
2801
+ declare function addTail(callback: GlobalRenderCallback): () => void;
2802
+ /**
2803
+ * Invalidates the view, requesting a frame to be rendered.
2804
+ * In demand mode, this triggers the scheduler to run frames.
2805
+ *
2806
+ * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2807
+ * @param frames - Number of frames to request (default: 1)
2808
+ * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2809
+ *
2810
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
2811
+ */
2812
+ declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
2813
+ /**
2814
+ * Advances the frameloop and runs render effects.
2815
+ * Useful for when manually rendering via `frameloop="never"`.
2816
+ *
2817
+ * @param timestamp - The timestamp to use for this frame
2818
+ * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2819
+ * @param state - Ignored (kept for backwards compat)
2820
+ * @param frame - Ignored (kept for backwards compat)
2821
+ *
2822
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2823
+ */
2824
+ declare function advance(timestamp: number): void;
2825
+
2826
+ /* eslint-disable @definitelytyped/no-unnecessary-generics */
2827
+ declare function ReactReconciler<
2828
+ Type,
2829
+ Props,
2830
+ Container,
2831
+ Instance,
2832
+ TextInstance,
2833
+ SuspenseInstance,
2834
+ HydratableInstance,
2835
+ FormInstance,
2836
+ PublicInstance,
2837
+ HostContext,
2838
+ ChildSet,
2839
+ TimeoutHandle,
2840
+ NoTimeout,
2841
+ TransitionStatus,
2842
+ >(
2843
+ /* eslint-enable @definitelytyped/no-unnecessary-generics */
2844
+ config: ReactReconciler.HostConfig<
2845
+ Type,
2846
+ Props,
2847
+ Container,
2848
+ Instance,
2849
+ TextInstance,
2850
+ SuspenseInstance,
2851
+ HydratableInstance,
2852
+ FormInstance,
2853
+ PublicInstance,
2854
+ HostContext,
2855
+ ChildSet,
2856
+ TimeoutHandle,
2857
+ NoTimeout,
2858
+ TransitionStatus
2859
+ >,
2860
+ ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
2861
+
2862
+ declare namespace ReactReconciler {
2863
+ interface HostConfig<
2864
+ Type,
2865
+ Props,
2866
+ Container,
2867
+ Instance,
2868
+ TextInstance,
2869
+ SuspenseInstance,
2870
+ HydratableInstance,
2871
+ FormInstance,
2872
+ PublicInstance,
2873
+ HostContext,
2874
+ ChildSet,
2875
+ TimeoutHandle,
2876
+ NoTimeout,
2877
+ TransitionStatus,
2878
+ > {
2879
+ // -------------------
2880
+ // Modes
2881
+ // -------------------
2882
+ /**
2883
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2884
+ *
2885
+ * 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.
2886
+ *
2887
+ * ```js
2888
+ * const HostConfig = {
2889
+ * // ...
2890
+ * supportsMutation: true,
2891
+ * // ...
2892
+ * }
2893
+ * ```
2894
+ *
2895
+ * Depending on the mode, the reconciler will call different methods on your host config.
2896
+ *
2897
+ * If you're not sure which one you want, you likely need the mutation mode.
2898
+ */
2899
+ supportsMutation: boolean;
2900
+
2901
+ /**
2902
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2903
+ *
2904
+ * 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".
2905
+ *
2906
+ * ```js
2907
+ * const HostConfig = {
2908
+ * // ...
2909
+ * supportsPersistence: true,
2910
+ * // ...
2911
+ * }
2912
+ * ```
2913
+ *
2914
+ * Depending on the mode, the reconciler will call different methods on your host config.
2915
+ *
2916
+ * If you're not sure which one you want, you likely need the mutation mode.
2917
+ */
2918
+ supportsPersistence: boolean;
2919
+
2920
+ // -------------------
2921
+ // Core Methods
2922
+ // -------------------
2923
+
2924
+ /**
2925
+ * 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`.
2926
+ *
2927
+ * 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.
2928
+ *
2929
+ * 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.
2930
+ *
2931
+ * 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.
2932
+ *
2933
+ * 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.
2934
+ */
2935
+ createInstance(
2936
+ type: Type,
2937
+ props: Props,
2938
+ rootContainer: Container,
2939
+ hostContext: HostContext,
2940
+ internalHandle: OpaqueHandle,
2941
+ ): Instance;
2942
+
2943
+ /**
2944
+ * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
2945
+ */
2946
+ createTextInstance(
2947
+ text: string,
2948
+ rootContainer: Container,
2949
+ hostContext: HostContext,
2950
+ internalHandle: OpaqueHandle,
2951
+ ): TextInstance;
2952
+
2953
+ /**
2954
+ * 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.
2955
+ *
2956
+ * 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.
2957
+ */
2958
+ appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
2959
+
2960
+ /**
2961
+ * 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.
2962
+ *
2963
+ * 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.
2964
+ *
2965
+ * 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.
2966
+ *
2967
+ * If you don't want to do anything here, you should return `false`.
2968
+ */
2969
+ finalizeInitialChildren(
2970
+ instance: Instance,
2971
+ type: Type,
2972
+ props: Props,
2973
+ rootContainer: Container,
2974
+ hostContext: HostContext,
2975
+ ): boolean;
2976
+
2977
+ /**
2978
+ * 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.
2979
+ *
2980
+ * 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.
2981
+ *
2982
+ * If you don't want to do anything here, you should return `false`.
2983
+ *
2984
+ * This method happens **in the render phase**. Do not mutate the tree from it.
2985
+ */
2986
+ shouldSetTextContent(type: Type, props: Props): boolean;
2987
+
2988
+ /**
2989
+ * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
2990
+ *
2991
+ * If you don't intend to use host context, you can return `null`.
2992
+ *
2993
+ * This method happens **in the render phase**. Do not mutate the tree from it.
2994
+ */
2995
+ getRootHostContext(rootContainer: Container): HostContext | null;
2996
+
2997
+ /**
2998
+ * 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.
2999
+ *
3000
+ * 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.
3001
+ *
3002
+ * If you don't want to do anything here, return `parentHostContext`.
3003
+ *
3004
+ * This method happens **in the render phase**. Do not mutate the tree from it.
3005
+ */
3006
+ getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
3007
+
3008
+ /**
3009
+ * 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.
3010
+ *
3011
+ * If you don't want to do anything here, return `instance`.
3012
+ */
3013
+ getPublicInstance(instance: Instance | TextInstance): PublicInstance;
3014
+
3015
+ /**
3016
+ * 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`.
3017
+ *
3018
+ * Even if you don't want to do anything here, you need to return `null` from it.
3019
+ */
3020
+ prepareForCommit(containerInfo: Container): Record<string, any> | null;
3021
+
3022
+ /**
3023
+ * 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.
3024
+ *
3025
+ * You can leave it empty.
3026
+ */
3027
+ resetAfterCommit(containerInfo: Container): void;
3028
+
3029
+ /**
3030
+ * This method is called for a container that's used as a portal target. Usually you can leave it empty.
3031
+ */
3032
+ preparePortalMount(containerInfo: Container): void;
3033
+
3034
+ /**
3035
+ * You can proxy this to `setTimeout` or its equivalent in your environment.
3036
+ */
3037
+ scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
3038
+
3039
+ /**
3040
+ * You can proxy this to `clearTimeout` or its equivalent in your environment.
3041
+ */
3042
+ cancelTimeout(id: TimeoutHandle): void;
3043
+
3044
+ /**
3045
+ * 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`.
3046
+ */
3047
+ noTimeout: NoTimeout;
3048
+
3049
+ /**
3050
+ * 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.
3051
+ */
3052
+ supportsMicrotasks?: boolean;
3053
+
3054
+ /**
3055
+ * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
3056
+ */
3057
+ scheduleMicrotask?(fn: () => unknown): void;
3058
+
3059
+ /**
3060
+ * 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`.
3061
+ */
3062
+ isPrimaryRenderer: boolean;
3063
+
3064
+ /**
3065
+ * Whether the renderer shouldn't trigger missing `act()` warnings
3066
+ */
3067
+ warnsIfNotActing?: boolean;
3068
+
3069
+ getInstanceFromNode(node: any): Fiber | null | undefined;
3070
+
3071
+ beforeActiveInstanceBlur(): void;
3072
+
3073
+ afterActiveInstanceBlur(): void;
3074
+
3075
+ prepareScopeUpdate(scopeInstance: any, instance: any): void;
3076
+
3077
+ getInstanceFromScope(scopeInstance: any): null | Instance;
3078
+
3079
+ detachDeletedInstance(node: Instance): void;
3080
+
3081
+ // -------------------
3082
+ // Mutation Methods
3083
+ // (optional)
3084
+ // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
3085
+ // -------------------
3086
+
3087
+ /**
3088
+ * 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.
3089
+ *
3090
+ * 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`.
3091
+ */
3092
+ appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
3093
+
3094
+ /**
3095
+ * 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.
3096
+ */
3097
+ appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
3098
+
3099
+ /**
3100
+ * 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.
3101
+ *
3102
+ * 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.
3103
+ */
3104
+ insertBefore?(
3105
+ parentInstance: Instance,
3106
+ child: Instance | TextInstance,
3107
+ beforeChild: Instance | TextInstance | SuspenseInstance,
3108
+ ): void;
3109
+
3110
+ /**
3111
+ * 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.
3112
+ */
3113
+ insertInContainerBefore?(
3114
+ container: Container,
3115
+ child: Instance | TextInstance,
3116
+ beforeChild: Instance | TextInstance | SuspenseInstance,
3117
+ ): void;
3118
+
3119
+ /**
3120
+ * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
3121
+ *
3122
+ * 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.
3123
+ */
3124
+ removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
3125
+
3126
+ /**
3127
+ * 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.
3128
+ */
3129
+ removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
3130
+
3131
+ /**
3132
+ * 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 = ''`.
3133
+ *
3134
+ * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
3135
+ */
3136
+ resetTextContent?(instance: Instance): void;
3137
+
3138
+ /**
3139
+ * This method should mutate the `textInstance` and update its text content to `nextText`.
3140
+ *
3141
+ * Here, `textInstance` is a node created by `createTextInstance`.
3142
+ */
3143
+ commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
3144
+
3145
+ /**
3146
+ * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
3147
+ *
3148
+ * 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.
3149
+ *
3150
+ * 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.
3151
+ *
3152
+ * 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.
3153
+ *
3154
+ * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
3155
+ */
3156
+ commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
3157
+
3158
+ /**
3159
+ * This method should mutate the instance to match nextProps.
3160
+ *
3161
+ * 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.
3162
+ */
3163
+ commitUpdate?(
3164
+ instance: Instance,
3165
+ type: Type,
3166
+ prevProps: Props,
3167
+ nextProps: Props,
3168
+ internalHandle: OpaqueHandle,
3169
+ ): void;
3170
+
3171
+ /**
3172
+ * 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.
3173
+ */
3174
+ hideInstance?(instance: Instance): void;
3175
+
3176
+ /**
3177
+ * Same as `hideInstance`, but for nodes created by `createTextInstance`.
3178
+ */
3179
+ hideTextInstance?(textInstance: TextInstance): void;
3180
+
3181
+ /**
3182
+ * This method should make the `instance` visible, undoing what `hideInstance` did.
3183
+ */
3184
+ unhideInstance?(instance: Instance, props: Props): void;
3185
+
3186
+ /**
3187
+ * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
3188
+ */
3189
+ unhideTextInstance?(textInstance: TextInstance, text: string): void;
3190
+
3191
+ /**
3192
+ * This method should mutate the `container` root node and remove all children from it.
3193
+ */
3194
+ clearContainer?(container: Container): void;
3195
+
3196
+ // -------------------
3197
+ // Persistence Methods
3198
+ // (optional)
3199
+ // 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.
3200
+ // -------------------
3201
+ cloneInstance?(
3202
+ instance: Instance,
3203
+ type: Type,
3204
+ oldProps: Props,
3205
+ newProps: Props,
3206
+ keepChildren: boolean,
3207
+ recyclableInstance: null | Instance,
3208
+ ): Instance;
3209
+ createContainerChildSet?(container: Container): ChildSet;
3210
+ appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
3211
+ finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
3212
+ replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
3213
+ cloneHiddenInstance?(
3214
+ instance: Instance,
3215
+ type: Type,
3216
+ props: Props,
3217
+ internalInstanceHandle: OpaqueHandle,
3218
+ ): Instance;
3219
+ cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
3220
+
3221
+ // -------------------
3222
+ // Hydration Methods
3223
+ // (optional)
3224
+ // 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.
3225
+ //
3226
+ // 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.
3227
+ // -------------------
3228
+ supportsHydration: boolean;
3229
+
3230
+ canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
3231
+
3232
+ canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
3233
+
3234
+ canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
3235
+
3236
+ isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
3237
+
3238
+ isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
3239
+
3240
+ registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
3241
+
3242
+ getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
3243
+
3244
+ getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
3245
+
3246
+ hydrateInstance?(
3247
+ instance: Instance,
3248
+ type: Type,
3249
+ props: Props,
3250
+ rootContainerInstance: Container,
3251
+ hostContext: HostContext,
3252
+ internalInstanceHandle: any,
3253
+ ): null | any[];
3254
+
3255
+ hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
3256
+
3257
+ hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
3258
+
3259
+ getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
3260
+
3261
+ // Returns the SuspenseInstance if this node is a direct child of a
3262
+ // SuspenseInstance. I.e. if its previous sibling is a Comment with
3263
+ // SUSPENSE_x_START_DATA. Otherwise, null.
3264
+ getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
3265
+
3266
+ commitHydratedContainer?(container: Container): void;
3267
+
3268
+ commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
3269
+
3270
+ didNotMatchHydratedContainerTextInstance?(
3271
+ parentContainer: Container,
3272
+ textInstance: TextInstance,
3273
+ text: string,
3274
+ ): void;
3275
+
3276
+ didNotMatchHydratedTextInstance?(
3277
+ parentType: Type,
3278
+ parentProps: Props,
3279
+ parentInstance: Instance,
3280
+ textInstance: TextInstance,
3281
+ text: string,
3282
+ ): void;
3283
+
3284
+ didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
3285
+
3286
+ didNotHydrateInstance?(
3287
+ parentType: Type,
3288
+ parentProps: Props,
3289
+ parentInstance: Instance,
3290
+ instance: HydratableInstance,
3291
+ ): void;
3292
+
3293
+ didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
3294
+
3295
+ didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
3296
+
3297
+ didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
3298
+
3299
+ didNotFindHydratableInstance?(
3300
+ parentType: Type,
3301
+ parentProps: Props,
3302
+ parentInstance: Instance,
3303
+ type: Type,
3304
+ props: Props,
3305
+ ): void;
3306
+
3307
+ didNotFindHydratableTextInstance?(
3308
+ parentType: Type,
3309
+ parentProps: Props,
3310
+ parentInstance: Instance,
3311
+ text: string,
3312
+ ): void;
3313
+
3314
+ didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
3315
+
3316
+ errorHydratingContainer?(parentContainer: Container): void;
3317
+
3318
+ // Undocumented
3319
+ // https://github.com/facebook/react/pull/26722
3320
+ NotPendingTransition: TransitionStatus | null;
3321
+ HostTransitionContext: ReactContext<TransitionStatus>;
3322
+
3323
+ // https://github.com/facebook/react/pull/28751
3324
+ setCurrentUpdatePriority(newPriority: EventPriority): void;
3325
+ getCurrentUpdatePriority(): EventPriority;
3326
+ resolveUpdatePriority(): EventPriority;
3327
+
3328
+ // https://github.com/facebook/react/pull/28804
3329
+ resetFormInstance(form: FormInstance): void;
3330
+
3331
+ // https://github.com/facebook/react/pull/25105
3332
+ requestPostPaintCallback(callback: (time: number) => void): void;
3333
+
3334
+ // https://github.com/facebook/react/pull/26025
3335
+ shouldAttemptEagerTransition(): boolean;
3336
+
3337
+ // https://github.com/facebook/react/pull/31528
3338
+ trackSchedulerEvent(): void;
3339
+
3340
+ // https://github.com/facebook/react/pull/31008
3341
+ resolveEventType(): null | string;
3342
+ resolveEventTimeStamp(): number;
3343
+
3344
+ /**
3345
+ * 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.
3346
+ */
3347
+ maySuspendCommit(type: Type, props: Props): boolean;
3348
+
3349
+ /**
3350
+ * 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.
3351
+ */
3352
+ preloadInstance(type: Type, props: Props): boolean;
3353
+
3354
+ /**
3355
+ * 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.
3356
+ */
3357
+ startSuspendingCommit(): void;
3358
+
3359
+ /**
3360
+ * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
3361
+ */
3362
+ suspendInstance(type: Type, props: Props): void;
3363
+
3364
+ /**
3365
+ * This method is called after all `suspendInstance` calls are complete.
3366
+ *
3367
+ * Return `null` if the commit can happen immediately.
3368
+ *
3369
+ * 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.
3370
+ */
3371
+ waitForCommitToBeReady():
3372
+ | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
3373
+ | null;
3374
+ }
3375
+
3376
+ interface Thenable<T> {
3377
+ then(resolve: () => T, reject?: () => T): T;
3378
+ }
3379
+
3380
+ type RootTag = 0 | 1 | 2;
3381
+
3382
+ type WorkTag =
3383
+ | 0
3384
+ | 1
3385
+ | 2
3386
+ | 3
3387
+ | 4
3388
+ | 5
3389
+ | 6
3390
+ | 7
3391
+ | 8
3392
+ | 9
3393
+ | 10
3394
+ | 11
3395
+ | 12
3396
+ | 13
3397
+ | 14
3398
+ | 15
3399
+ | 16
3400
+ | 17
3401
+ | 18
3402
+ | 19
3403
+ | 20
3404
+ | 21
3405
+ | 22
3406
+ | 23
3407
+ | 24;
3408
+
3409
+ type HookType =
3410
+ | "useState"
3411
+ | "useReducer"
3412
+ | "useContext"
3413
+ | "useRef"
3414
+ | "useEffect"
3415
+ | "useLayoutEffect"
3416
+ | "useCallback"
3417
+ | "useMemo"
3418
+ | "useImperativeHandle"
3419
+ | "useDebugValue"
3420
+ | "useDeferredValue"
3421
+ | "useTransition"
3422
+ | "useMutableSource"
3423
+ | "useOpaqueIdentifier"
3424
+ | "useCacheRefresh";
3425
+
3426
+ interface Source {
3427
+ fileName: string;
3428
+ lineNumber: number;
3429
+ }
3430
+
3431
+ // TODO: Ideally these types would be opaque but that doesn't work well with
3432
+ // our reconciler fork infra, since these leak into non-reconciler packages.
3433
+ type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
3434
+
3435
+ type Lanes = number;
3436
+ type Lane = number;
3437
+
3438
+ type Flags = number;
3439
+
3440
+ type TypeOfMode = number;
3441
+
3442
+ type EventPriority = number;
3443
+
3444
+ interface ReactProvider<T> {
3445
+ $$typeof: symbol | number;
3446
+ type: ReactProviderType<T>;
3447
+ key: null | string;
3448
+ ref: null;
3449
+ props: {
3450
+ value: T;
3451
+ children?: ReactNode;
3452
+ };
3453
+ }
3454
+
3455
+ interface ReactProviderType<T> {
3456
+ $$typeof: symbol | number;
3457
+ _context: ReactContext<T>;
3458
+ }
3459
+
3460
+ interface ReactConsumer<T> {
3461
+ $$typeof: symbol | number;
3462
+ type: ReactContext<T>;
3463
+ key: null | string;
3464
+ ref: null;
3465
+ props: {
3466
+ children: (value: T) => ReactNode;
3467
+ unstable_observedBits?: number;
3468
+ };
3469
+ }
3470
+
3471
+ interface ReactContext<T> {
3472
+ $$typeof: symbol | number;
3473
+ Consumer: ReactContext<T>;
3474
+ Provider: ReactProviderType<T>;
3475
+ _currentValue: T;
3476
+ _currentValue2: T;
3477
+ _threadCount: number;
3478
+ // DEV only
3479
+ _currentRenderer?: {
3480
+ [key: string]: any;
3481
+ } | null;
3482
+ _currentRenderer2?: {
3483
+ [key: string]: any;
3484
+ } | null;
3485
+ // This value may be added by application code
3486
+ // to improve DEV tooling display names
3487
+ displayName?: string;
3488
+ }
3489
+
3490
+ interface ReactPortal {
3491
+ $$typeof: symbol | number;
3492
+ key: null | string;
3493
+ containerInfo: any;
3494
+ children: ReactNode;
3495
+ // TODO: figure out the API for cross-renderer implementation.
3496
+ implementation: any;
3497
+ }
3498
+
3499
+ interface RefObject {
3500
+ current: any;
3501
+ }
3502
+
3503
+ interface ContextDependency<T> {
3504
+ context: ReactContext<T>;
3505
+ observedBits: number;
3506
+ next: ContextDependency<unknown> | null;
3507
+ }
3508
+
3509
+ interface Dependencies {
3510
+ lanes: Lanes;
3511
+ firstContext: ContextDependency<unknown> | null;
3512
+ }
3513
+
3514
+ interface Fiber {
3515
+ // These first fields are conceptually members of an Instance. This used to
3516
+ // be split into a separate type and intersected with the other Fiber fields,
3517
+ // but until Flow fixes its intersection bugs, we've merged them into a
3518
+ // single type.
3519
+
3520
+ // An Instance is shared between all versions of a component. We can easily
3521
+ // break this out into a separate object to avoid copying so much to the
3522
+ // alternate versions of the tree. We put this on a single object for now to
3523
+ // minimize the number of objects created during the initial render.
3524
+
3525
+ // Tag identifying the type of fiber.
3526
+ tag: WorkTag;
3527
+
3528
+ // Unique identifier of this child.
3529
+ key: null | string;
3530
+
3531
+ // The value of element.type which is used to preserve the identity during
3532
+ // reconciliation of this child.
3533
+ elementType: any;
3534
+
3535
+ // The resolved function/class/ associated with this fiber.
3536
+ type: any;
3537
+
3538
+ // The local state associated with this fiber.
3539
+ stateNode: any;
3540
+
3541
+ // Conceptual aliases
3542
+ // parent : Instance -> return The parent happens to be the same as the
3543
+ // return fiber since we've merged the fiber and instance.
3544
+
3545
+ // Remaining fields belong to Fiber
3546
+
3547
+ // The Fiber to return to after finishing processing this one.
3548
+ // This is effectively the parent, but there can be multiple parents (two)
3549
+ // so this is only the parent of the thing we're currently processing.
3550
+ // It is conceptually the same as the return address of a stack frame.
3551
+ return: Fiber | null;
3552
+
3553
+ // Singly Linked List Tree Structure.
3554
+ child: Fiber | null;
3555
+ sibling: Fiber | null;
3556
+ index: number;
3557
+
3558
+ // The ref last used to attach this node.
3559
+ // I'll avoid adding an owner field for prod and model that as functions.
3560
+ ref:
3561
+ | null
3562
+ | (((handle: unknown) => void) & {
3563
+ _stringRef?: string | null;
3564
+ })
3565
+ | RefObject;
3566
+
3567
+ // Input is the data coming into process this fiber. Arguments. Props.
3568
+ pendingProps: any; // This type will be more specific once we overload the tag.
3569
+ memoizedProps: any; // The props used to create the output.
3570
+
3571
+ // A queue of state updates and callbacks.
3572
+ updateQueue: unknown;
3573
+
3574
+ // The state used to create the output
3575
+ memoizedState: any;
3576
+
3577
+ // Dependencies (contexts, events) for this fiber, if it has any
3578
+ dependencies: Dependencies | null;
3579
+
3580
+ // Bitfield that describes properties about the fiber and its subtree. E.g.
3581
+ // the ConcurrentMode flag indicates whether the subtree should be async-by-
3582
+ // default. When a fiber is created, it inherits the mode of its
3583
+ // parent. Additional flags can be set at creation time, but after that the
3584
+ // value should remain unchanged throughout the fiber's lifetime, particularly
3585
+ // before its child fibers are created.
3586
+ mode: TypeOfMode;
3587
+
3588
+ // Effect
3589
+ flags: Flags;
3590
+ subtreeFlags: Flags;
3591
+ deletions: Fiber[] | null;
3592
+
3593
+ // Singly linked list fast path to the next fiber with side-effects.
3594
+ nextEffect: Fiber | null;
3595
+
3596
+ // The first and last fiber with side-effect within this subtree. This allows
3597
+ // us to reuse a slice of the linked list when we reuse the work done within
3598
+ // this fiber.
3599
+ firstEffect: Fiber | null;
3600
+ lastEffect: Fiber | null;
3601
+
3602
+ lanes: Lanes;
3603
+ childLanes: Lanes;
3604
+
3605
+ // This is a pooled version of a Fiber. Every fiber that gets updated will
3606
+ // eventually have a pair. There are cases when we can clean up pairs to save
3607
+ // memory if we need to.
3608
+ alternate: Fiber | null;
3609
+
3610
+ // Time spent rendering this Fiber and its descendants for the current update.
3611
+ // This tells us how well the tree makes use of sCU for memoization.
3612
+ // It is reset to 0 each time we render and only updated when we don't bailout.
3613
+ // This field is only set when the enableProfilerTimer flag is enabled.
3614
+ actualDuration?: number;
3615
+
3616
+ // If the Fiber is currently active in the "render" phase,
3617
+ // This marks the time at which the work began.
3618
+ // This field is only set when the enableProfilerTimer flag is enabled.
3619
+ actualStartTime?: number;
3620
+
3621
+ // Duration of the most recent render time for this Fiber.
3622
+ // This value is not updated when we bailout for memoization purposes.
3623
+ // This field is only set when the enableProfilerTimer flag is enabled.
3624
+ selfBaseDuration?: number;
3625
+
3626
+ // Sum of base times for all descendants of this Fiber.
3627
+ // This value bubbles up during the "complete" phase.
3628
+ // This field is only set when the enableProfilerTimer flag is enabled.
3629
+ treeBaseDuration?: number;
3630
+
3631
+ // Conceptual aliases
3632
+ // workInProgress : Fiber -> alternate The alternate used for reuse happens
3633
+ // to be the same as work in progress.
3634
+ // __DEV__ only
3635
+ _debugID?: number;
3636
+ _debugSource?: Source | null;
3637
+ _debugOwner?: Fiber | null;
3638
+ _debugIsCurrentlyTiming?: boolean;
3639
+ _debugNeedsRemount?: boolean;
3640
+
3641
+ // Used to verify that the order of hooks does not change between renders.
3642
+ _debugHookTypes?: HookType[] | null;
3643
+ }
3644
+
3645
+ type FiberRoot = any;
3646
+
3647
+ // Concurrent related struct
3648
+ type MutableSource = any;
3649
+
3650
+ type OpaqueHandle = any;
3651
+ type OpaqueRoot = any;
3652
+
3653
+ // 0 is PROD, 1 is DEV.
3654
+ // Might add PROFILE later.
3655
+ type BundleType = 0 | 1;
3656
+
3657
+ interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
3658
+ bundleType: BundleType;
3659
+ version: string;
3660
+ rendererPackageName: string;
3661
+ // Note: this actually *does* depend on Fiber internal fields.
3662
+ // Used by "inspect clicked DOM element" in React DevTools.
3663
+ findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
3664
+ rendererConfig?: RendererInspectionConfig;
3665
+ }
3666
+
3667
+ interface SuspenseHydrationCallbacks<SuspenseInstance> {
3668
+ onHydrated?: (suspenseInstance: SuspenseInstance) => void;
3669
+ onDeleted?: (suspenseInstance: SuspenseInstance) => void;
3670
+ }
3671
+
3672
+ interface TransitionTracingCallbacks {
3673
+ onTransitionStart?: (transitionName: string, startTime: number) => void;
3674
+ onTransitionProgress?: (
3675
+ transitionName: string,
3676
+ startTime: number,
3677
+ currentTime: number,
3678
+ pending: Array<{ name: null | string }>,
3679
+ ) => void;
3680
+ onTransitionIncomplete?: (
3681
+ transitionName: string,
3682
+ startTime: number,
3683
+ deletions: Array<{
3684
+ type: string;
3685
+ name?: string;
3686
+ newName?: string;
3687
+ endTime: number;
3688
+ }>,
3689
+ ) => void;
3690
+ onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
3691
+ onMarkerProgress?: (
3692
+ transitionName: string,
3693
+ marker: string,
3694
+ startTime: number,
3695
+ currentTime: number,
3696
+ pending: Array<{ name: null | string }>,
3697
+ ) => void;
3698
+ onMarkerIncomplete?: (
3699
+ transitionName: string,
3700
+ marker: string,
3701
+ startTime: number,
3702
+ deletions: Array<{
3703
+ type: string;
3704
+ name?: string;
3705
+ newName?: string;
3706
+ endTime: number;
3707
+ }>,
3708
+ ) => void;
3709
+ onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
3710
+ }
3711
+
3712
+ interface ComponentSelector {
3713
+ $$typeof: symbol | number;
3714
+ value: React$AbstractComponent<never, unknown>;
3715
+ }
3716
+
3717
+ interface HasPseudoClassSelector {
3718
+ $$typeof: symbol | number;
3719
+ value: Selector[];
3720
+ }
3721
+
3722
+ interface RoleSelector {
3723
+ $$typeof: symbol | number;
3724
+ value: string;
3725
+ }
3726
+
3727
+ interface TextSelector {
3728
+ $$typeof: symbol | number;
3729
+ value: string;
3730
+ }
3731
+
3732
+ interface TestNameSelector {
3733
+ $$typeof: symbol | number;
3734
+ value: string;
3735
+ }
3736
+
3737
+ type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
3738
+
3739
+ // TODO can not find React$AbstractComponent def
3740
+ type React$AbstractComponent<Config, Instance = any> = any;
3741
+
3742
+ interface BoundingRect {
3743
+ x: number;
3744
+ y: number;
3745
+ width: number;
3746
+ height: number;
3747
+ }
3748
+
3749
+ type IntersectionObserverOptions = any;
3750
+
3751
+ interface BaseErrorInfo {
3752
+ componentStack?: string;
3753
+ }
3754
+
3755
+ interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
3756
+ createContainer(
3757
+ containerInfo: Container,
3758
+ tag: RootTag,
3759
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3760
+ isStrictMode: boolean,
3761
+ concurrentUpdatesByDefaultOverride: null | boolean,
3762
+ identifierPrefix: string,
3763
+ onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
3764
+ onCaughtError: (error: Error, info: BaseErrorInfo) => void,
3765
+ onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
3766
+ onDefaultTransitionIndicator: () => void,
3767
+ transitionCallbacks: null | TransitionTracingCallbacks,
3768
+ ): OpaqueRoot;
3769
+
3770
+ createPortal(
3771
+ children: ReactNode,
3772
+ containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
3773
+ implementation: any,
3774
+ key?: string | null,
3775
+ ): ReactPortal;
3776
+
3777
+ registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
3778
+
3779
+ createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
3780
+
3781
+ createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
3782
+
3783
+ createRoleSelector(role: string): RoleSelector;
3784
+
3785
+ createTextSelector(text: string): TextSelector;
3786
+
3787
+ createTestNameSelector(id: string): TestNameSelector;
3788
+
3789
+ getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
3790
+
3791
+ findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
3792
+
3793
+ findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
3794
+
3795
+ focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
3796
+
3797
+ observeVisibleRects(
3798
+ hostRoot: Instance,
3799
+ selectors: Selector[],
3800
+ callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
3801
+ options?: IntersectionObserverOptions,
3802
+ ): { disconnect: () => void };
3803
+
3804
+ createHydrationContainer(
3805
+ initialChildren: ReactNode,
3806
+ callback: (() => void) | null | undefined,
3807
+ containerInfo: Container,
3808
+ tag: RootTag,
3809
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3810
+ isStrictMode: boolean,
3811
+ concurrentUpdatesByDefaultOverride: null | boolean,
3812
+ identifierPrefix: string,
3813
+ onRecoverableError: (error: Error) => void,
3814
+ transitionCallbacks: null | TransitionTracingCallbacks,
3815
+ ): OpaqueRoot;
3816
+
3817
+ updateContainer(
3818
+ element: ReactNode,
3819
+ container: OpaqueRoot,
3820
+ parentComponent?: Component<any, any> | null,
3821
+ callback?: (() => void) | null,
3822
+ ): Lane;
3823
+
3824
+ batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
3825
+
3826
+ deferredUpdates<A>(fn: () => A): A;
3827
+
3828
+ 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;
3829
+
3830
+ flushControlled(fn: () => any): void;
3831
+
3832
+ flushSync(): void;
3833
+ flushSync<R>(fn: () => R): R;
3834
+
3835
+ isAlreadyRendering(): boolean;
3836
+
3837
+ flushPassiveEffects(): boolean;
3838
+
3839
+ getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
3840
+
3841
+ attemptSynchronousHydration(fiber: Fiber): void;
3842
+
3843
+ attemptDiscreteHydration(fiber: Fiber): void;
3844
+
3845
+ attemptContinuousHydration(fiber: Fiber): void;
3846
+
3847
+ attemptHydrationAtCurrentPriority(fiber: Fiber): void;
3848
+
3849
+ getCurrentUpdatePriority(): LanePriority;
3850
+
3851
+ runWithPriority<T>(priority: LanePriority, fn: () => T): T;
3852
+
3853
+ findHostInstance(component: any): PublicInstance | null;
3854
+
3855
+ findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
3856
+
3857
+ findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
3858
+
3859
+ shouldError(fiber: Fiber): boolean | undefined;
3860
+
3861
+ shouldSuspend(fiber: Fiber): boolean;
3862
+
3863
+ injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
3864
+ }
3865
+ }
3866
+
3867
+ declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3868
+ declare function extend<T extends Catalogue>(objects: T): void;
3869
+ declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3870
+
3871
+ declare const isRenderer: (def: any) => boolean;
3872
+ interface OffscreenCanvas extends EventTarget {
3873
+ }
3874
+ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3875
+ declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3876
+ declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3877
+ declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3878
+ interface PortalProps {
3879
+ children: ReactNode;
3880
+ state?: InjectState;
3881
+ container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3882
+ }
3883
+ declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3884
+ /**
3885
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
3886
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
3887
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
3888
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
3889
+ */
3890
+ declare function flushSync<R>(fn: () => R): R;
3891
+
3892
+ declare const context: React$1.Context<RootStore>;
3893
+ declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3894
+
3895
+ /**
3896
+ * Safely flush async effects when testing, simulating a legacy root.
3897
+ * @deprecated Import from React instead. import { act } from 'react'
3898
+ */
3899
+ declare const act: typeof React$1.act;
3900
+ /**
3901
+ * An SSR-friendly useLayoutEffect.
3902
+ *
3903
+ * React currently throws a warning when using useLayoutEffect on the server.
3904
+ * To get around it, we can conditionally useEffect on the server (no-op) and
3905
+ * useLayoutEffect elsewhere.
3906
+ *
3907
+ * @see https://github.com/facebook/react/issues/14927
3908
+ */
3909
+ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
3910
+ /**
3911
+ * Creates a stable ref that always contains the latest callback.
3912
+ * Useful for avoiding dependency arrays while ensuring the latest closure is called.
3913
+ *
3914
+ * @param fn - The callback function to wrap
3915
+ * @returns A ref containing the current callback
3916
+ */
3917
+ declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
3918
+ /**
3919
+ * Bridges renderer Context and StrictMode from a primary renderer.
3920
+ * Used to maintain React context when rendering into portals or secondary canvases.
3921
+ *
3922
+ * @returns A Bridge component that wraps children with the parent renderer's context
3923
+ */
3924
+ declare function useBridge(): Bridge;
3925
+ /**
3926
+ * Internal component that blocks rendering until a promise resolves.
3927
+ * Used for suspense-like blocking behavior.
3928
+ *
3929
+ * @param set - Function to set the blocking promise
3930
+ */
3931
+ declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
3932
+ /**
3933
+ * Error boundary component for catching and handling errors in the React tree.
3934
+ * Forwards errors to a state setter for external handling.
3935
+ *
3936
+ * NOTE: static members get down-level transpiled to mutations which break tree-shaking
3937
+ */
3938
+ declare const ErrorBoundary: {
3939
+ new (props: {
3940
+ set: React$1.Dispatch<Error | undefined>;
3941
+ children: React$1.ReactNode;
3942
+ }): {
3943
+ state: {
3944
+ error: boolean;
3945
+ };
3946
+ componentDidCatch(err: Error): void;
3947
+ render(): React$1.ReactNode;
3948
+ context: unknown;
3949
+ setState<K extends "error">(state: {
3950
+ error: boolean;
3951
+ } | ((prevState: Readonly<{
3952
+ error: boolean;
3953
+ }>, props: Readonly<{
3954
+ set: React$1.Dispatch<Error | undefined>;
3955
+ children: React$1.ReactNode;
3956
+ }>) => {
3957
+ error: boolean;
3958
+ } | Pick<{
3959
+ error: boolean;
3960
+ }, K> | null) | Pick<{
3961
+ error: boolean;
3962
+ }, K> | null, callback?: (() => void) | undefined): void;
3963
+ forceUpdate(callback?: (() => void) | undefined): void;
3964
+ readonly props: Readonly<{
3965
+ set: React$1.Dispatch<Error | undefined>;
3966
+ children: React$1.ReactNode;
3967
+ }>;
3968
+ componentDidMount?(): void;
3969
+ shouldComponentUpdate?(nextProps: Readonly<{
3970
+ set: React$1.Dispatch<Error | undefined>;
3971
+ children: React$1.ReactNode;
3972
+ }>, nextState: Readonly<{
3973
+ error: boolean;
3974
+ }>, nextContext: any): boolean;
3975
+ componentWillUnmount?(): void;
3976
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
3977
+ set: React$1.Dispatch<Error | undefined>;
3978
+ children: React$1.ReactNode;
3979
+ }>, prevState: Readonly<{
3980
+ error: boolean;
3981
+ }>): any;
3982
+ componentDidUpdate?(prevProps: Readonly<{
3983
+ set: React$1.Dispatch<Error | undefined>;
3984
+ children: React$1.ReactNode;
3985
+ }>, prevState: Readonly<{
3986
+ error: boolean;
3987
+ }>, snapshot?: any): void;
3988
+ componentWillMount?(): void;
3989
+ UNSAFE_componentWillMount?(): void;
3990
+ componentWillReceiveProps?(nextProps: Readonly<{
3991
+ set: React$1.Dispatch<Error | undefined>;
3992
+ children: React$1.ReactNode;
3993
+ }>, nextContext: any): void;
3994
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3995
+ set: React$1.Dispatch<Error | undefined>;
3996
+ children: React$1.ReactNode;
3997
+ }>, nextContext: any): void;
3998
+ componentWillUpdate?(nextProps: Readonly<{
3999
+ set: React$1.Dispatch<Error | undefined>;
4000
+ children: React$1.ReactNode;
4001
+ }>, nextState: Readonly<{
4002
+ error: boolean;
4003
+ }>, nextContext: any): void;
4004
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
4005
+ set: React$1.Dispatch<Error | undefined>;
4006
+ children: React$1.ReactNode;
4007
+ }>, nextState: Readonly<{
4008
+ error: boolean;
4009
+ }>, nextContext: any): void;
4010
+ };
4011
+ new (props: {
4012
+ set: React$1.Dispatch<Error | undefined>;
4013
+ children: React$1.ReactNode;
4014
+ }, context: any): {
4015
+ state: {
4016
+ error: boolean;
4017
+ };
4018
+ componentDidCatch(err: Error): void;
4019
+ render(): React$1.ReactNode;
4020
+ context: unknown;
4021
+ setState<K extends "error">(state: {
4022
+ error: boolean;
4023
+ } | ((prevState: Readonly<{
4024
+ error: boolean;
4025
+ }>, props: Readonly<{
4026
+ set: React$1.Dispatch<Error | undefined>;
4027
+ children: React$1.ReactNode;
4028
+ }>) => {
4029
+ error: boolean;
4030
+ } | Pick<{
4031
+ error: boolean;
4032
+ }, K> | null) | Pick<{
4033
+ error: boolean;
4034
+ }, K> | null, callback?: (() => void) | undefined): void;
4035
+ forceUpdate(callback?: (() => void) | undefined): void;
4036
+ readonly props: Readonly<{
4037
+ set: React$1.Dispatch<Error | undefined>;
4038
+ children: React$1.ReactNode;
4039
+ }>;
4040
+ componentDidMount?(): void;
4041
+ shouldComponentUpdate?(nextProps: Readonly<{
4042
+ set: React$1.Dispatch<Error | undefined>;
4043
+ children: React$1.ReactNode;
4044
+ }>, nextState: Readonly<{
4045
+ error: boolean;
4046
+ }>, nextContext: any): boolean;
4047
+ componentWillUnmount?(): void;
4048
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
4049
+ set: React$1.Dispatch<Error | undefined>;
4050
+ children: React$1.ReactNode;
4051
+ }>, prevState: Readonly<{
4052
+ error: boolean;
4053
+ }>): any;
4054
+ componentDidUpdate?(prevProps: Readonly<{
4055
+ set: React$1.Dispatch<Error | undefined>;
4056
+ children: React$1.ReactNode;
4057
+ }>, prevState: Readonly<{
4058
+ error: boolean;
4059
+ }>, snapshot?: any): void;
4060
+ componentWillMount?(): void;
4061
+ UNSAFE_componentWillMount?(): void;
4062
+ componentWillReceiveProps?(nextProps: Readonly<{
4063
+ set: React$1.Dispatch<Error | undefined>;
4064
+ children: React$1.ReactNode;
4065
+ }>, nextContext: any): void;
4066
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
4067
+ set: React$1.Dispatch<Error | undefined>;
4068
+ children: React$1.ReactNode;
4069
+ }>, nextContext: any): void;
4070
+ componentWillUpdate?(nextProps: Readonly<{
4071
+ set: React$1.Dispatch<Error | undefined>;
4072
+ children: React$1.ReactNode;
4073
+ }>, nextState: Readonly<{
4074
+ error: boolean;
4075
+ }>, nextContext: any): void;
4076
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
4077
+ set: React$1.Dispatch<Error | undefined>;
4078
+ children: React$1.ReactNode;
4079
+ }>, nextState: Readonly<{
4080
+ error: boolean;
4081
+ }>, nextContext: any): void;
4082
+ };
4083
+ getDerivedStateFromError: () => {
4084
+ error: boolean;
4085
+ };
4086
+ contextType?: React$1.Context<any> | undefined;
4087
+ propTypes?: any;
4088
+ };
4089
+
4090
+ /**
4091
+ * React internal props that should not be passed to Three.js objects.
4092
+ */
4093
+ declare const REACT_INTERNAL_PROPS: string[];
4094
+ /**
4095
+ * Returns the instance's initial (outermost) root.
4096
+ * Traverses through previousRoot links to find the original root store.
4097
+ *
4098
+ * @param instance - R3F instance to find root for
4099
+ * @returns The outermost root store
4100
+ */
4101
+ declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
4102
+ /**
4103
+ * Returns instance root state.
4104
+ * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
4105
+ * traverses ancestors to find the nearest managed parent.
4106
+ *
4107
+ * @param obj - Three.js object to get root state for
4108
+ * @returns Root state if found, undefined otherwise
4109
+ */
4110
+ declare function getRootState<T extends Object3D = Object3D>(obj: T): RootState | undefined;
4111
+ /**
4112
+ * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
4113
+ * Handles duplicate material names by appending UUID prefixes.
4114
+ *
4115
+ * @param object - Root object to traverse
4116
+ * @returns ObjectMap containing named nodes, materials, and meshes
4117
+ *
4118
+ * @example
4119
+ * const { nodes, materials, meshes } = buildGraph(gltf.scene)
4120
+ * // Access by name: nodes.Head, materials.Metal, meshes.Body
4121
+ */
4122
+ declare function buildGraph(object: Object3D): ObjectMap;
4123
+ /**
4124
+ * Disposes an object and all its disposable properties.
4125
+ * Skips Scene objects as they should not be disposed automatically.
4126
+ *
4127
+ * @param obj - Object to dispose
4128
+ */
4129
+ declare function dispose<T extends Disposable>(obj: T): void;
4130
+ /**
4131
+ * Extracts instance props from React reconciler fiber props.
4132
+ * Filters out React-internal props (children, key, ref).
4133
+ *
4134
+ * @param queue - Pending props from reconciler fiber
4135
+ * @returns Props object without React-internal keys
4136
+ */
4137
+ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
4138
+ /**
4139
+ * Creates or retrieves an R3F instance descriptor for a Three.js object.
4140
+ * Each object in the scene carries a LocalState descriptor (__r3f).
4141
+ *
4142
+ * @param target - Target object to prepare
4143
+ * @param root - Root store for this instance
4144
+ * @param type - String identifier for the object type
4145
+ * @param props - Initial props for the instance
4146
+ * @returns Instance descriptor
4147
+ */
4148
+ declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
4149
+ /**
4150
+ * Triggers an update for an instance.
4151
+ * Calls onUpdate callback and invalidates the frame if necessary.
4152
+ *
4153
+ * @param instance - Instance to invalidate
4154
+ */
4155
+ declare function invalidateInstance(instance: Instance): void;
4156
+
4157
+ /**
4158
+ * Reserved prop names that should not be applied to Three.js objects.
4159
+ */
4160
+ declare const RESERVED_PROPS: string[];
4161
+ /**
4162
+ * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
4163
+ * First tries the entire key as a single property, then attempts piercing.
4164
+ *
4165
+ * @param root - Root object to resolve from
4166
+ * @param key - Property key (may contain dashes for piercing)
4167
+ * @returns Object containing root, key, and target value
4168
+ *
4169
+ * @example
4170
+ * resolve(mesh, 'material-color')
4171
+ * // => { root: mesh.material, key: 'color', target: mesh.material.color }
4172
+ */
4173
+ declare function resolve(root: any, key: string): {
4174
+ root: any;
4175
+ key: string;
4176
+ target: any;
4177
+ };
4178
+ /**
4179
+ * Attaches a child instance to a parent instance.
4180
+ * Handles both string-based attachment (e.g., 'geometry', 'material-map')
4181
+ * and function-based attachment for custom logic.
4182
+ *
4183
+ * @param parent - Parent instance
4184
+ * @param child - Child instance to attach
4185
+ *
4186
+ * @example
4187
+ * // String attachment
4188
+ * <bufferGeometry attach="geometry" />
4189
+ * // Array attachment
4190
+ * <light attach="lights-0" />
4191
+ * // Function attachment
4192
+ * <thing attach={(parent, self) => { parent.customProp = self }} />
4193
+ */
4194
+ declare function attach(parent: Instance, child: Instance): void;
4195
+ /**
4196
+ * Detaches a child instance from a parent instance.
4197
+ * Restores the previous value or deletes the property if it was never set.
4198
+ *
4199
+ * @param parent - Parent instance
4200
+ * @param child - Child instance to detach
4201
+ */
4202
+ declare function detach(parent: Instance, child: Instance): void;
4203
+ /**
4204
+ * Compares old and new props to determine which properties have changed.
4205
+ * Also handles resetting removed props for HMR/fast-refresh.
4206
+ *
4207
+ * @param instance - Instance to diff props for
4208
+ * @param newProps - New props to compare against
4209
+ * @returns Object containing only changed props
4210
+ *
4211
+ * @example
4212
+ * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
4213
+ * // => { position: [1, 2, 3] } (only if position changed)
4214
+ */
4215
+ declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
4216
+ /**
4217
+ * Applies a set of props to a Three.js object.
4218
+ * Handles special cases like colors, vectors, textures, events, and pierced props.
4219
+ *
4220
+ * @param object - Three.js object to apply props to
4221
+ * @param props - Props to apply
4222
+ * @returns The object with props applied
4223
+ *
4224
+ * @example
4225
+ * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
4226
+ */
4227
+ declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
4228
+
4229
+ /**
4230
+ * Calculates the device pixel ratio for rendering.
4231
+ * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
4232
+ *
4233
+ * @param dpr - Target DPR value or [min, max] range
4234
+ * @returns Calculated DPR value
4235
+ *
4236
+ * @example
4237
+ * calculateDpr(2) // => 2
4238
+ * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
4239
+ */
4240
+ declare function calculateDpr(dpr: Dpr): number;
4241
+ /**
4242
+ * Extracts the first segment of a UUID string (before the first hyphen).
4243
+ * Used for creating unique material names when duplicates exist.
4244
+ *
4245
+ * @param uuid - UUID string to extract prefix from
4246
+ * @returns First segment of the UUID
4247
+ *
4248
+ * @example
4249
+ * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
4250
+ */
4251
+ declare function getUuidPrefix(uuid: string): string;
4252
+ /**
4253
+ * Updates camera projection based on viewport size.
4254
+ * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
4255
+ * Respects camera.manual flag - manual cameras are not modified.
4256
+ *
4257
+ * @param camera - Camera to update
4258
+ * @param size - Current viewport size
4259
+ */
4260
+ declare function updateCamera(camera: ThreeCamera, size: Size): void;
4261
+ /**
4262
+ * Updates a frustum from a camera's projection and world matrices.
4263
+ * If no target frustum is provided, creates and returns a new one.
4264
+ *
4265
+ * @param camera - Camera to extract frustum from
4266
+ * @param frustum - Optional existing frustum to update (creates new if not provided)
4267
+ * @returns The updated or newly created frustum
4268
+ *
4269
+ * @example
4270
+ * // Create new frustum
4271
+ * const frustum = updateFrustum(camera)
4272
+ *
4273
+ * // Update existing frustum (no allocation)
4274
+ * updateFrustum(camera, existingFrustum)
4275
+ *
4276
+ * // Use for visibility checks
4277
+ * if (frustum.containsPoint(point)) { ... }
4278
+ * if (frustum.intersectsObject(mesh)) { ... }
4279
+ */
4280
+ declare function updateFrustum(camera: ThreeCamera, frustum?: Frustum): Frustum;
4281
+
4282
+ declare const is: {
4283
+ obj: (a: any) => boolean;
4284
+ fun: (a: any) => a is Function;
4285
+ str: (a: any) => a is string;
4286
+ num: (a: any) => a is number;
4287
+ boo: (a: any) => a is boolean;
4288
+ und: (a: any) => boolean;
4289
+ nul: (a: any) => boolean;
4290
+ arr: (a: any) => a is any[];
4291
+ equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
4292
+ };
4293
+ declare const isOrthographicCamera: (def: ThreeCamera) => def is OrthographicCamera;
4294
+ declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
4295
+ declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation$1;
4296
+ declare const isObject3D: (object: any) => object is Object3D;
4297
+ declare const isTexture: (value: unknown) => value is Texture$1;
4298
+ type VectorLike = {
4299
+ set: (...args: any[]) => void;
4300
+ constructor?: Function;
4301
+ };
4302
+ declare const isVectorLike: (object: unknown) => object is VectorLike;
4303
+ type Copyable = {
4304
+ copy: (...args: any[]) => void;
4305
+ constructor?: Function;
4306
+ };
4307
+ declare const isCopyable: (object: unknown) => object is Copyable;
4308
+ declare const hasConstructor: (object: unknown) => object is {
4309
+ constructor?: Function;
4310
+ };
4311
+
4312
+ /**
4313
+ * Symbol marker for deferred ref resolution.
4314
+ * Used to identify values that should be resolved from refs after mount.
4315
+ */
4316
+ declare const FROM_REF: unique symbol;
4317
+ /**
4318
+ * Defers prop application until the referenced object is available.
4319
+ * Useful for props like `target` that need sibling refs to be populated.
4320
+ *
4321
+ * @param ref - React ref object to resolve at mount time
4322
+ * @returns A marker value that applyProps will resolve after mount
4323
+ *
4324
+ * @example
4325
+ * const targetRef = useRef<THREE.Object3D>(null)
4326
+ *
4327
+ * <group ref={targetRef} position={[-3, -2, -15]} />
4328
+ * <spotLight target={fromRef(targetRef)} intensity={100} />
4329
+ */
4330
+ declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
4331
+ /**
4332
+ * Type guard to check if a value is a fromRef marker.
4333
+ *
4334
+ * @param value - Value to check
4335
+ * @returns True if value is a fromRef marker
4336
+ */
4337
+ declare function isFromRef(value: unknown): value is {
4338
+ [FROM_REF]: React$1.RefObject<any>;
4339
+ };
4340
+
4341
+ /**
4342
+ * Symbol marker for mount-only method calls.
4343
+ * Used to identify methods that should only be called once on initial mount.
4344
+ */
4345
+ declare const ONCE: unique symbol;
4346
+ /**
4347
+ * Marks a method call to be executed only on initial mount.
4348
+ * Useful for geometry transforms that should not be reapplied on every render.
4349
+ *
4350
+ * When `args` prop changes (triggering reconstruction), the method will be
4351
+ * called again on the new instance since appliedOnce is not carried over.
4352
+ *
4353
+ * @param args - Arguments to pass to the method
4354
+ * @returns A marker value that applyProps will execute once
4355
+ *
4356
+ * @example
4357
+ * // Rotate geometry on mount
4358
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
4359
+ *
4360
+ * // Multiple arguments
4361
+ * <bufferGeometry applyMatrix4={once(matrix)} />
4362
+ *
4363
+ * // No arguments
4364
+ * <geometry center={once()} />
4365
+ */
4366
+ declare function once<T>(...args: T[]): T;
4367
+ /**
4368
+ * Type guard to check if a value is a once marker.
4369
+ *
4370
+ * @param value - Value to check
4371
+ * @returns True if value is a once marker
4372
+ */
4373
+ declare function isOnce(value: unknown): value is {
4374
+ [ONCE]: any[] | true;
4375
+ };
4376
+
4377
+ /**
4378
+ * A DOM canvas which accepts threejs elements as children.
4379
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
4380
+ */
4381
+ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
4382
+
4383
+ /**
4384
+ * ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
4385
+ *
4386
+ * Provides TypeScript-friendly access to uniform/node stores where the runtime
4387
+ * structure is `Record<string, T | Record<string, T>>` (leaf nodes or nested scopes).
4388
+ *
4389
+ * The wrapper uses a Proxy to:
4390
+ * 1. Return `T` for property access (type assumption: assumes leaf node)
4391
+ * 2. Provide `.scope(key)` method for explicit nested access
4392
+ * 3. Support iteration methods: has(), keys(), Object.keys(), for...in
4393
+ *
4394
+ * @example
4395
+ * ```tsx
4396
+ * useLocalNodes(({ uniforms }) => ({
4397
+ * wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
4398
+ * playerHealth: uniforms.scope('player').uHealth // Explicit scope access
4399
+ * }))
4400
+ * ```
4401
+ */
4402
+
4403
+ /** Keys reserved for methods (excluded from index signature) */
4404
+ type MethodKeys = 'scope' | 'has' | 'keys';
4405
+ /**
4406
+ * Type-safe wrapper interface for accessing nested store data.
4407
+ * Property access returns `T` (assumes leaf node).
4408
+ * Use `.scope(key)` for nested object access.
4409
+ *
4410
+ * Uses mapped type with key filtering to exclude method names from index signature,
4411
+ * allowing methods to have their correct return types.
4412
+ */
4413
+ type ScopedStoreType<T> = {
4414
+ /** Direct property access returns the leaf type T (method keys excluded) */
4415
+ readonly [K in string as K extends MethodKeys ? never : K]: T;
4416
+ } & {
4417
+ /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
4418
+ scope(key: string): ScopedStoreType<T>;
4419
+ /** Check if a key exists in the store */
4420
+ has(key: string): boolean;
4421
+ /** Get all keys in the store */
4422
+ keys(): string[];
4423
+ };
4424
+ /**
4425
+ * Create a type-safe ScopedStore wrapper around store data.
4426
+ * @param data - The raw store data (uniforms or nodes from RootState)
4427
+ * @returns A ScopedStoreType wrapper with type-safe access
4428
+ */
4429
+ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
4430
+ /**
4431
+ * State type passed to creator functions with ScopedStore wrappers.
4432
+ * Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
4433
+ */
4434
+ type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
4435
+ /** Type-safe uniform access - property access returns UniformNode */
4436
+ uniforms: ScopedStoreType<UniformNode>;
4437
+ /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
4438
+ nodes: ScopedStoreType<TSLNodeType>;
4439
+ /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
4440
+ buffers: ScopedStoreType<BufferLike>;
4441
+ /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
4442
+ gpuStorage: ScopedStoreType<StorageLike>;
4443
+ };
4444
+
4445
+ /** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
4446
+ type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: CreatorState) => T;
4447
+ /** Function signature for removeUniforms util */
4448
+ type RemoveUniformsFn = (names: string | string[], scope?: string) => void;
4449
+ /** Function signature for clearUniforms util */
4450
+ type ClearUniformsFn = (scope?: string) => void;
4451
+ /** Function signature for rebuildUniforms util */
4452
+ type RebuildUniformsFn = (scope?: string) => void;
4453
+ /** Return type with utils included */
4454
+ type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
4455
+ removeUniforms: RemoveUniformsFn;
4456
+ clearUniforms: ClearUniformsFn;
4457
+ rebuildUniforms: RebuildUniformsFn;
4458
+ };
4459
+ declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
4460
+ declare function useUniforms(scope: string): UniformsWithUtils;
4461
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformRecord<UniformNode>>;
4462
+ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4463
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
4464
+ declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4465
+ /**
4466
+ * Global rebuildUniforms function for HMR integration.
4467
+ * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
4468
+ * Call this when HMR is detected to refresh all uniform creators.
4469
+ *
4470
+ * @param store - The R3F store (from useStore or context)
4471
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4472
+ */
4473
+ declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?: string): void;
4474
+ /**
4475
+ * Remove uniforms by name from root level or a scope
4476
+ * @deprecated Use `const { removeUniforms } = useUniforms()` instead
4477
+ */
4478
+ declare function removeUniforms(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
4479
+ /**
4480
+ * Clear all uniforms from a scope (removes the entire scope object)
4481
+ * @deprecated Use `const { clearUniforms } = useUniforms()` instead
4482
+ */
4483
+ declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
4484
+ /**
4485
+ * Clear all root-level uniforms (preserves scopes)
4486
+ * @deprecated Use `const { clearUniforms } = useUniforms()` with `clearUniforms('root')` instead
4487
+ */
4488
+ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
4489
+
4490
+ /**
4491
+ * Supported uniform value types:
4492
+ * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
4493
+ * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
4494
+ * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
4495
+ * - UniformNode: existing uniforms (reused as-is)
4496
+ */
4497
+ type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
4498
+ /**
4499
+ * Widen literal types to their base types:
4500
+ * - 0 → number
4501
+ * - true → boolean
4502
+ * - '#ff0000' → Color (string colors are converted to Color objects)
4503
+ * - Node → Node (TSL nodes passed through for uniform type casting)
4504
+ */
4505
+ type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
4506
+ declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
4507
+ declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
4508
+
4509
+ /**
4510
+ * Minimal interface for TSL nodes.
4511
+ * Used instead of Three.js's Node type because the @types/three definitions
4512
+ * have inconsistencies where OperatorNode, ConstNode, etc. don't properly
4513
+ * extend Node with all required properties.
4514
+ */
4515
+ interface TSLNodeLike {
4516
+ uuid?: string;
4517
+ nodeType?: string | null;
4518
+ /** label method for chaining - sets the node's label and returns self */
4519
+ label?: ((label: string) => TSLNodeLike) | string;
4520
+ setName?: (name: string) => this;
4521
+ }
4522
+ /** TSL node type - alias for compatibility */
4523
+ type TSLNode = TSLNodeLike;
4524
+ /**
4525
+ * A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
4526
+ * Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
4527
+ */
4528
+ type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
4529
+ /**
4530
+ * Creator function that returns a record of nodes.
4531
+ * Uses TSLNodeLike constraint to allow mixed node types
4532
+ * (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
4533
+ */
4534
+ type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
4535
+ /** Function signature for removeNodes util */
4536
+ type RemoveNodesFn = (names: string | string[], scope?: string) => void;
4537
+ /** Function signature for clearNodes util */
4538
+ type ClearNodesFn = (scope?: string) => void;
4539
+ /** Function signature for rebuildNodes util */
4540
+ type RebuildNodesFn = (scope?: string) => void;
4541
+ /** Return type with utils included */
4542
+ type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
4543
+ removeNodes: RemoveNodesFn;
4544
+ clearNodes: ClearNodesFn;
4545
+ rebuildNodes: RebuildNodesFn;
4546
+ };
4547
+ declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
4548
+ declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
4549
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
4550
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
4551
+ /**
4552
+ * Global rebuildNodes function for HMR integration.
4553
+ * Clears cached nodes and increments _hmrVersion to trigger re-creation.
4554
+ * Call this when HMR is detected to refresh all node creators.
4555
+ *
4556
+ * @param store - The R3F store (from useStore or context)
4557
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4558
+ */
4559
+ declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: string): void;
4560
+ /**
4561
+ * Remove nodes by name from root level or a scope
4562
+ * @deprecated Use `const { removeNodes } = useNodes()` instead
4563
+ */
4564
+ declare function removeNodes(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
4565
+ /**
4566
+ * Clear all nodes from a scope (removes the entire scope object)
4567
+ * @deprecated Use `const { clearNodes } = useNodes()` instead
4568
+ */
4569
+ declare function clearNodeScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
4570
+ /**
4571
+ * Clear all root-level nodes (preserves scopes)
4572
+ * @deprecated Use `const { clearNodes } = useNodes()` with `clearNodes('root')` instead
4573
+ */
4574
+ declare function clearRootNodes(set: ReturnType<typeof useStore>['setState']): void;
4575
+
4576
+ /** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
4577
+ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
4578
+ /**
4579
+ * Creates local values that rebuild when uniforms, nodes, or textures change.
4580
+ *
4581
+ * Unlike `useNodes`, this does NOT register to the global store.
4582
+ * Use for component-specific nodes/values that depend on shared resources.
4583
+ *
4584
+ * @example
4585
+ * ```tsx
4586
+ * // Destructure what you need from state
4587
+ * const { wobble, uTime } = useLocalNodes(({ uniforms, nodes }) => ({
4588
+ * wobble: sin(uniforms.uTime.mul(2)),
4589
+ * uTime: uniforms.uTime, // can return uniforms too
4590
+ * }))
4591
+ *
4592
+ * // Or access anything else from RootState
4593
+ * const { scaled } = useLocalNodes(({ camera, nodes }) => ({
4594
+ * scaled: nodes.basePos.mul(camera.zoom),
4595
+ * }))
4596
+ *
4597
+ * // Type-safe uniform access
4598
+ * const { colorNode } = useLocalNodes(({ uniforms }) => {
4599
+ * const uValue = uniforms.myUniform as UniformNode<number>
4600
+ * return { colorNode: mix(colorA, colorB, uValue) }
4601
+ * })
4602
+ * ```
4603
+ */
4604
+ declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
4605
+
4606
+ /**
4607
+ * Creator function that returns a record of buffers.
4608
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
4609
+ */
4610
+ type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
4611
+ /** Function signature for removeBuffers util */
4612
+ type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
4613
+ /** Function signature for clearBuffers util */
4614
+ type ClearBuffersFn = (scope?: string) => void;
4615
+ /** Function signature for rebuildBuffers util */
4616
+ type RebuildBuffersFn = (scope?: string) => void;
4617
+ /** Function signature for disposeBuffers util - releases GPU resources */
4618
+ type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
4619
+ /** Return type with utils included */
4620
+ type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
4621
+ removeBuffers: RemoveBuffersFn;
4622
+ clearBuffers: ClearBuffersFn;
4623
+ rebuildBuffers: RebuildBuffersFn;
4624
+ disposeBuffers: DisposeBuffersFn;
4625
+ };
4626
+ declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
4627
+ declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
4628
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
4629
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
4630
+ /**
4631
+ * Global rebuildBuffers function for HMR integration.
4632
+ * Clears cached buffers and increments _hmrVersion to trigger re-creation.
4633
+ * Call this when HMR is detected to refresh all buffer creators.
4634
+ *
4635
+ * @param store - The R3F store (from useStore or context)
4636
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4637
+ */
4638
+ declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
4639
+
4640
+ /**
4641
+ * Creator function that returns a record of GPU storage objects.
4642
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
4643
+ */
4644
+ type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
4645
+ /** Function signature for removeStorage util */
4646
+ type RemoveStorageFn = (names: string | string[], scope?: string) => void;
4647
+ /** Function signature for clearStorage util */
4648
+ type ClearStorageFn = (scope?: string) => void;
4649
+ /** Function signature for rebuildStorage util */
4650
+ type RebuildStorageFn = (scope?: string) => void;
4651
+ /** Function signature for disposeStorage util - releases GPU resources */
4652
+ type DisposeStorageFn = (names: string | string[], scope?: string) => void;
4653
+ /** Return type with utils included */
4654
+ type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
4655
+ removeStorage: RemoveStorageFn;
4656
+ clearStorage: ClearStorageFn;
4657
+ rebuildStorage: RebuildStorageFn;
4658
+ disposeStorage: DisposeStorageFn;
4659
+ };
4660
+ declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
4661
+ declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
4662
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
4663
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
4664
+ /**
4665
+ * Global rebuildStorage function for HMR integration.
4666
+ * Clears cached storage and increments _hmrVersion to trigger re-creation.
4667
+ * Call this when HMR is detected to refresh all storage creators.
4668
+ *
4669
+ * @param store - The R3F store (from useStore or context)
4670
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4671
+ */
4672
+ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
4673
+
4674
+ interface TextureOperations {
4675
+ add: (key: string, value: any) => void;
4676
+ addMultiple: (items: Map<string, any> | Record<string, any>) => void;
4677
+ remove: (key: string) => void;
4678
+ removeMultiple: (keys: string[]) => void;
4679
+ }
4680
+ declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
4681
+
4682
+ /**
4683
+ * Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
4684
+ *
4685
+ * Features:
4686
+ * - Creates RenderPipeline instance if not exists
4687
+ * - Creates default scenePass (no MRT) automatically
4688
+ * - Callbacks receive full RootState for flexibility
4689
+ * - No auto-cleanup on unmount - use reset() for explicit cleanup
4690
+ * - Scene/camera changes trigger scenePass recreation
4691
+ *
4692
+ * @param mainCB - Main callback to configure outputNode and create effect passes
4693
+ * @param setupCB - Optional setup callback to configure MRT on scenePass
4694
+ * @returns { passes, renderPipeline, clearPasses, reset, rebuild }
4695
+ *
4696
+ * @example
4697
+ * ```tsx
4698
+ * // Simple effect
4699
+ * useRenderPipeline(({ renderPipeline, passes }) => {
4700
+ * renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
4701
+ * })
4702
+ *
4703
+ * // With MRT setup
4704
+ * useRenderPipeline(
4705
+ * ({ renderPipeline, passes }) => {
4706
+ * const beauty = passes.scenePass.getTextureNode().toInspector('Color')
4707
+ * const vel = passes.scenePass.getTextureNode('velocity')
4708
+ * renderPipeline.outputNode = motionBlur(beauty, vel)
4709
+ * },
4710
+ * ({ passes }) => {
4711
+ * passes.scenePass.setMRT(mrt({ output, velocity }))
4712
+ * }
4713
+ * )
4714
+ *
4715
+ * // Read-only access
4716
+ * const { renderPipeline, passes } = useRenderPipeline()
4717
+ * ```
4718
+ */
4719
+ declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
4720
+
4721
+ //* Renderer Props ========================================
4722
+
4723
+ type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
4724
+
4725
+ type WebGPUProps =
4726
+ | RendererFactory<WebGPURenderer, WebGPUDefaultProps>
4727
+ | Partial<Properties<WebGPURenderer> | WebGPURendererParameters>
4728
+
4729
+ // WebGPU doesn't have shadow maps in the same way
4730
+ interface WebGPUShadowConfig {
4731
+ shadows?: boolean // Simplified for WebGPU
4732
+ }
4733
+
4734
+ //* WebGPU-specific Types ========================================
4735
+
4736
+ /** WebGPU renderer type - re-exported as R3FRenderer from @react-three/fiber/webgpu */
4737
+ type WebGPUR3FRenderer = WebGPURenderer
4738
+
4739
+ /** WebGPU internal state with narrowed renderer type */
4740
+ interface WebGPUInternalState extends Omit<InternalState, 'actualRenderer'> {
4741
+ actualRenderer: WebGPURenderer
4742
+ }
4743
+
4744
+ /**
4745
+ * WebGPU-specific RootState with narrowed renderer type.
4746
+ * Automatically used when importing from `@react-three/fiber/webgpu`.
4747
+ *
4748
+ * @example
4749
+ * ```tsx
4750
+ * import { useThree } from '@react-three/fiber/webgpu'
4751
+ *
4752
+ * function MyComponent() {
4753
+ * const { renderer } = useThree()
4754
+ * // renderer is typed as WebGPURenderer
4755
+ * renderer.compute(computePass)
4756
+ * }
4757
+ * ```
4758
+ */
4759
+ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'> {
4760
+ /** @deprecated Use `renderer` instead */
4761
+ gl: WebGPURenderer
4762
+ /** The WebGPU renderer instance */
4763
+ renderer: WebGPURenderer
4764
+ /** Internals with WebGPU renderer */
4765
+ internal: WebGPUInternalState
4766
+ }
4767
+
4768
+ export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
4769
+ export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureOperations, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };