@react-three/fiber 10.0.0-canary.de17310 → 10.0.0-canary.de8b03c

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