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