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