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

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