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