@react-three/fiber 10.0.0-canary.ea31ccd → 10.0.0-canary.ee5a08a

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