@react-three/fiber 10.0.0-canary.eb6c14f → 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 -15366
  11. package/dist/index.d.cts +123 -3875
  12. package/dist/index.d.mts +123 -3875
  13. package/dist/index.d.ts +122 -3846
  14. package/dist/index.mjs +10 -15267
  15. package/dist/legacy.cjs +97 -15321
  16. package/dist/legacy.d.cts +114 -3876
  17. package/dist/legacy.d.mts +114 -3876
  18. package/dist/legacy.d.ts +115 -3851
  19. package/dist/legacy.mjs +14 -15225
  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 -16206
  34. package/dist/webgpu/index.d.cts +112 -4192
  35. package/dist/webgpu/index.d.mts +112 -4192
  36. package/dist/webgpu/index.d.ts +112 -4164
  37. package/dist/webgpu/index.mjs +15 -16090
  38. package/package.json +11 -8
  39. package/readme.md +1 -1
package/dist/legacy.d.mts CHANGED
@@ -1,3891 +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
- onUpdate?: (self: T) => void
947
- }
948
-
949
- interface Instance<O = any> {
950
- root: RootStore
951
- type: string
952
- parent: Instance | null
953
- children: Instance[]
954
- props: InstanceProps<O> & Record<string, unknown>
955
- object: O & { __r3f?: Instance<O> }
956
- eventCount: number
957
- handlers: Partial<EventHandlers>
958
- attach?: AttachType<O>
959
- previousAttach?: any
960
- isHidden: boolean
961
- /** Set of props that have been applied via once() */
962
- appliedOnce?: Set<string>
963
- }
964
-
965
- interface HostConfig {
966
- type: string
967
- props: Instance['props']
968
- container: RootStore
969
- instance: Instance
970
- textInstance: void
971
- suspenseInstance: Instance
972
- hydratableInstance: never
973
- formInstance: never
974
- publicInstance: Instance['object']
975
- hostContext: {}
976
- childSet: never
977
- timeoutHandle: number | undefined
978
- noTimeout: -1
979
- TransitionStatus: null
980
- }
981
- declare global {
982
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
983
- }
984
-
985
- //* Loop Types ==============================
986
-
987
- type GlobalRenderCallback = (timestamp: number) => void
988
-
989
- type GlobalEffectType = 'before' | 'after' | 'tail'
990
-
991
- declare const presetsObj: {
992
- apartment: string;
993
- city: string;
994
- dawn: string;
995
- forest: string;
996
- lobby: string;
997
- night: string;
998
- park: string;
999
- studio: string;
1000
- sunset: string;
1001
- 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;
1002
103
  };
1003
- type PresetsType = keyof typeof presetsObj;
1004
-
1005
- //* Background Types ==============================
1006
-
1007
- /**
1008
- * Expanded object form for background configuration.
1009
- * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
1010
- */
1011
- interface BackgroundConfig {
1012
- /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
1013
- preset?: PresetsType
1014
- /** Files for cube texture (6 faces) or single HDR/EXR */
1015
- files?: string | string[]
1016
- /** Separate files for scene.background (visual backdrop) */
1017
- backgroundMap?: string | string[]
1018
- backgroundRotation?: Euler$1 | [number, number, number]
1019
- backgroundBlurriness?: number
1020
- backgroundIntensity?: number
1021
- /** Separate files for scene.environment (PBR lighting/reflections) */
1022
- envMap?: string | string[]
1023
- environmentRotation?: Euler$1 | [number, number, number]
1024
- environmentIntensity?: number
1025
- path?: string
1026
- extensions?: (loader: Loader) => void
1027
- }
1028
-
1029
- /**
1030
- * Background prop type for Canvas.
1031
- *
1032
- * String detection priority:
1033
- * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1034
- * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
1035
- * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
1036
- *
1037
- * @example Color
1038
- * ```tsx
1039
- * <Canvas background="red" />
1040
- * <Canvas background="#ff0000" />
1041
- * <Canvas background={0xff0000} />
1042
- * ```
1043
- *
1044
- * @example Preset
1045
- * ```tsx
1046
- * <Canvas background="city" />
1047
- * ```
1048
- *
1049
- * @example URL
1050
- * ```tsx
1051
- * <Canvas background="/path/to/env.hdr" />
1052
- * <Canvas background="./sky.jpg" />
1053
- * ```
1054
- *
1055
- * @example Object form
1056
- * ```tsx
1057
- * <Canvas background={{
1058
- * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1059
- * backgroundMap: 'path/to/sky.jpg',
1060
- * envMap: 'path/to/lighting.hdr',
1061
- * backgroundBlurriness: 0.5,
1062
- * }} />
1063
- * ```
1064
- */
1065
- type BackgroundProp =
1066
- | ColorRepresentation // "red", "#ff0000", 0xff0000
1067
- | string // URL or preset
1068
- | BackgroundConfig // Expanded object form
1069
-
1070
- //* Canvas Types ==============================
1071
-
1072
- interface CanvasProps
1073
- extends
1074
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1075
- React$1.HTMLAttributes<HTMLDivElement> {
1076
- children?: React$1.ReactNode
1077
- ref?: React$1.Ref<HTMLCanvasElement>
1078
- /** Canvas fallback content, similar to img's alt prop */
1079
- fallback?: React$1.ReactNode
1080
- /**
1081
- * Options to pass to useMeasure.
1082
- * @see https://github.com/pmndrs/react-use-measure#api
1083
- */
1084
- resize?: Options
1085
- /** The target where events are being subscribed to, default: the div that wraps canvas */
1086
- eventSource?: Element | React$1.RefObject<Element | null>
1087
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1088
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1089
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1090
- hmr?: boolean
1091
- /** Canvas resolution width in pixels. If omitted, uses container width. */
1092
- width?: number
1093
- /** Canvas resolution height in pixels. If omitted, uses container height. */
1094
- height?: number
1095
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1096
- forceEven?: boolean
1097
- /**
1098
- * Scene background configuration.
1099
- * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1100
- * @see BackgroundProp for full documentation and examples
1101
- */
1102
- background?: BackgroundProp
1103
- }
1104
104
 
1105
- //* Loader Types ==============================
1106
-
1107
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1108
-
1109
- // Define a loader-like interface that matches THREE.Loader's load signature
1110
- // This works for both generic and non-generic THREE.Loader instances
1111
- interface LoaderLike {
1112
- load(
1113
- url: InputLike,
1114
- onLoad?: (result: any) => void,
1115
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
1116
- onError?: (error: unknown) => void,
1117
- ): any
1118
- }
1119
-
1120
- type GLTFLike = { scene: THREE$1.Object3D }
1121
-
1122
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1123
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1124
-
1125
- // Infer result type from the load method's callback parameter
1126
- type InferLoadResult<T> = T extends {
1127
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1128
- }
1129
- ? R
1130
- : T extends ConstructorRepresentation<any>
1131
- ? InstanceType<T> extends {
1132
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1133
- }
1134
- ? R
1135
- : any
1136
- : any
1137
-
1138
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1139
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1140
-
1141
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1142
- loader: LoaderInstance<T>,
1143
- ) => void
1144
-
1145
- //* Renderer Props ========================================
1146
-
1147
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1148
-
1149
- type WebGLProps =
1150
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1151
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1152
-
1153
- interface WebGLShadowConfig {
1154
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1155
- }
1156
-
1157
- //* Legacy-specific Types ========================================
1158
-
1159
- /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1160
- type LegacyRenderer = THREE$1.WebGLRenderer
1161
-
1162
- /** Legacy internal state with narrowed renderer type */
1163
- interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1164
- actualRenderer: THREE$1.WebGLRenderer
1165
- }
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
+ };
1166
110
 
1167
111
  /**
1168
- * Legacy-specific RootState with narrowed renderer type.
1169
- * Automatically used when importing from `@react-three/fiber/legacy`.
1170
- *
1171
- * @example
1172
- * ```tsx
1173
- * import { useThree } from '@react-three/fiber/legacy'
1174
- *
1175
- * function MyComponent() {
1176
- * const { renderer } = useThree()
1177
- * // renderer is typed as THREE.WebGLRenderer
1178
- * renderer.shadowMap.enabled = true
1179
- * }
1180
- * ```
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
1181
115
  */
1182
- interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1183
- /** The WebGL renderer instance */
1184
- renderer: THREE$1.WebGLRenderer
1185
- /** Internals with WebGL renderer */
1186
- internal: LegacyInternalState
1187
- }
1188
-
1189
- //* RenderTarget Types ==============================
1190
-
1191
-
1192
- type RenderTargetOptions = RenderTargetOptions$1
1193
-
1194
- //* Global TSL Types ==============================
1195
-
1196
- declare global {
1197
- /**
1198
- * Broad callable-node fallback for dynamic store readers.
1199
- * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1200
- */
1201
- type CallableTSLNode = ((...params: never[]) => unknown) & {
1202
- readonly shaderNode: unknown
1203
- readonly id: number
1204
- }
1205
-
1206
- /** Legacy structural node accepted when at least one historical marker exists. */
1207
- type LegacyTSLNodeLike = {
1208
- label?: ((label: string) => unknown) | string
1209
- setName?: (name: string) => unknown
1210
- } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1211
-
1212
- /** Node type accepted by broad dynamic node-store readers. */
1213
- type TSLNodeType = three_webgpu.Node | CallableTSLNode
1214
-
1215
- /**
1216
- * Derive Three's shader node type from an existing node or a supported raw input.
1217
- * Existing InputNode generics take precedence over structural value normalization.
1218
- * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1219
- * InputNode base with its concrete InputNode specialization.
1220
- */
1221
- type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1222
- ? TNodeType
1223
- : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1224
- ? TNodeType
1225
- : T extends number
1226
- ? 'float'
1227
- : T extends boolean
1228
- ? 'bool'
1229
- : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1230
- ? 'color'
1231
- : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1232
- ? 'vec4'
1233
- : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1234
- ? 'vec3'
1235
- : T extends three_webgpu.Vector2 | { x: number; y: number }
1236
- ? 'vec2'
1237
- : T extends three_webgpu.Matrix4
1238
- ? 'mat4'
1239
- : T extends three_webgpu.Matrix3
1240
- ? 'mat3'
1241
- : T extends three_webgpu.Matrix2
1242
- ? 'mat2'
1243
- : unknown
1244
-
1245
- /** Derive the normalized JavaScript value stored by a uniform node. */
1246
- type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1247
- ? TValue
1248
- : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1249
- ? TValue
1250
- : T extends string | { r: number; g: number; b: number }
1251
- ? three_webgpu.Color
1252
- : T extends { x: number; y: number; z: number; w: number }
1253
- ? three_webgpu.Vector4
1254
- : T extends { x: number; y: number; z: number }
1255
- ? three_webgpu.Vector3
1256
- : T extends { x: number; y: number }
1257
- ? three_webgpu.Vector2
1258
- : T extends number
1259
- ? number
1260
- : T extends boolean
1261
- ? boolean
1262
- : T
1263
-
1264
- /** Three's exact UniformNode with shader and value generics derived from an input. */
1265
- type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1266
-
1267
- /** Preserve every input key while mapping values to exact Three uniform nodes. */
1268
- type UniformNodesFor<T extends UniformInputRecord> = {
1269
- [K in keyof T]: UniformNodeFor<T[K]>
1270
- }
1271
-
1272
- /** Backward-compatible single-parameter uniform alias. */
1273
- type UniformNode<T = unknown> = UniformNodeFor<T>
1274
-
1275
- /** Flat record of uniform nodes (no nested scopes) */
1276
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1277
-
1278
- /**
1279
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
1280
- * Used by state.uniforms which has structure like:
1281
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1282
- */
1283
- type UniformStore = Record<string, UniformNode | UniformRecord>
1284
-
1285
- /**
1286
- * Helper to safely access a uniform node from the store.
1287
- * Use this when accessing state.uniforms to get proper typing.
1288
- * @example
1289
- * const uTime = uniforms.uTime as UniformNode<number>
1290
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1291
- */
1292
- type GetUniform<T = unknown> = UniformNode<T>
1293
-
1294
- /**
1295
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1296
- * Supports:
1297
- * - Primitives: number, string (color), boolean
1298
- * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1299
- * - Plain objects: { x, y, z, w } converted to vectors
1300
- * - TSL nodes: color(), vec3(), float() for type casting
1301
- * - UniformNode: existing uniforms (reused as-is)
1302
- */
1303
- type UniformValue =
1304
- | number
1305
- | string
1306
- | boolean
1307
- | three_webgpu.Color
1308
- | three_webgpu.Vector2
1309
- | three_webgpu.Vector3
1310
- | three_webgpu.Vector4
1311
- | three_webgpu.Matrix2
1312
- | three_webgpu.Matrix3
1313
- | three_webgpu.Matrix4
1314
- | { x: number; y: number }
1315
- | { x: number; y: number; z: number }
1316
- | { x: number; y: number; z: number; w: number }
1317
- | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1318
- | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1319
- | UniformNode
1320
-
1321
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1322
- 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> {
1323
120
  }
1324
-
1325
- declare global {
1326
- /**
1327
- * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1328
- * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1329
- * is r185, so the new name is the only one.
1330
- */
1331
- type ThreeRenderPipeline = three_webgpu.RenderPipeline
1332
-
1333
- /**
1334
- * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1335
- * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1336
- * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1337
- */
1338
- type ScenePassNode = three_webgpu.PassNode
1339
-
1340
- /**
1341
- * Pass record - stores TSL pass nodes for render pipeline.
1342
- *
1343
- * `scenePass` is the only key the library owns. It is optional here because this is also the
1344
- * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1345
- * or `clearPasses()`. Inside the callbacks it is always present; see
1346
- * {@link RenderPipelineCallbackState}.
1347
- *
1348
- * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1349
- * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1350
- * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1351
- * site when you need a member, e.g. `passes.velocity as TextureNode`.
1352
- *
1353
- * The index signature admits `undefined` because a key may simply not be registered, and
1354
- * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1355
- * optional property whose type excludes `undefined` from the index signature is an error
1356
- * (TS2411) for every consumer compiling these declarations.
1357
- */
1358
- interface PassRecord {
1359
- scenePass?: ScenePassNode
1360
- [key: string]: three_webgpu.Node | undefined
1361
- }
1362
-
1363
- /**
1364
- * State passed to pipeline callbacks after the active pipeline has been created.
1365
- *
1366
- * `passes.scenePass` is required here: the hook installs the default scene pass before either
1367
- * callback runs, so callbacks can use it without a guard or a cast.
1368
- *
1369
- * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1370
- * the legacy renderer before either callback can run, so a callback never sees WebGL.
1371
- */
1372
- type RenderPipelineCallbackState = RootState & {
1373
- renderPipeline: ThreeRenderPipeline
1374
- passes: PassRecord & { scenePass: ScenePassNode }
1375
- renderer: three_webgpu.WebGPURenderer
1376
- isLegacy: false
1377
- }
1378
-
1379
- /**
1380
- * What a callback may return to register entries into `state.passes`.
1381
- *
1382
- * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1383
- * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1384
- * store entry would leave the store pointing at a node the hook never disposes, and the hook
1385
- * disposing a pass nothing references. So returning it is a type error.
1386
- */
1387
- type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1388
-
1389
- /** Setup callback - runs first to configure MRT, create additional passes */
1390
- type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1391
-
1392
- /** Main callback - runs second to configure outputNode, create effect passes */
1393
- type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1394
-
1395
- /** The imperative half of useRenderPipeline's return value, present in every state */
1396
- interface UseRenderPipelineActions {
1397
- /** Current passes from state */
1398
- passes: PassRecord
1399
- /** Clear all passes from state */
1400
- clearPasses: () => void
1401
- /** Reset RenderPipeline entirely (clears PP + passes) */
1402
- reset: () => void
1403
- /** Re-run setup/main callbacks with current closure values */
1404
- rebuild: () => void
1405
- }
1406
-
1407
- /**
1408
- * Return type for useRenderPipeline hook, discriminated on `isReady`.
1409
- *
1410
- * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1411
- * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1412
- * `clearPasses()` empties the record while leaving the pipeline in place.
1413
- */
1414
- type UseRenderPipelineReturn = UseRenderPipelineActions &
1415
- (
1416
- | {
1417
- /** True when RenderPipeline is configured and ready */
1418
- isReady: true
1419
- /** RenderPipeline instance */
1420
- renderPipeline: ThreeRenderPipeline
1421
- }
1422
- | {
1423
- /** False until the pipeline has been created */
1424
- isReady: false
1425
- /** Not initialized yet, or torn down by reset() */
1426
- renderPipeline: null
121
+ declare module 'react' {
122
+ namespace JSX {
123
+ interface IntrinsicElements extends ThreeElements {
1427
124
  }
1428
- )
1429
- }
1430
-
1431
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1432
-
1433
- interface MathRepresentation {
1434
- set(...args: number[]): any
1435
- }
1436
- interface VectorRepresentation extends MathRepresentation {
1437
- setScalar(value: number): any
1438
- }
1439
- type MathTypes = MathRepresentation | Euler$1 | Color$1
1440
-
1441
- type MathType<T extends MathTypes> = T extends Color$1
1442
- ? Args<typeof Color$1> | ColorRepresentation
1443
- : T extends VectorRepresentation | Layers$1 | Euler$1
1444
- ? T | MutableOrReadonlyParameters<T['set']> | number
1445
- : T | MutableOrReadonlyParameters<T['set']>
1446
-
1447
- type MathProps<P> = {
1448
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1449
- }
1450
-
1451
- type Vector2 = MathType<Vector2$1>
1452
- type Vector3 = MathType<Vector3$1>
1453
- type Vector4 = MathType<Vector4$1>
1454
- type Color = MathType<Color$1>
1455
- type Layers = MathType<Layers$1>
1456
- type Quaternion = MathType<Quaternion$1>
1457
- type Euler = MathType<Euler$1>
1458
- type Matrix3 = MathType<Matrix3$1>
1459
- type Matrix4 = MathType<Matrix4$1>
1460
-
1461
- interface RaycastableRepresentation {
1462
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
125
+ }
1463
126
  }
1464
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1465
-
1466
- /**
1467
- * Props for geometry transform methods that can be called with `once()`.
1468
- * These methods modify the geometry in-place and only make sense to call once on mount.
1469
- *
1470
- * @example
1471
- * import { once } from '@react-three/fiber'
1472
- *
1473
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1474
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1475
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1476
- */
1477
- interface GeometryTransformProps {
1478
- /** Rotate the geometry about the X axis (radians). Use with once(). */
1479
- rotateX?: number
1480
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
1481
- rotateY?: number
1482
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
1483
- rotateZ?: number
1484
- /** Translate the geometry (x, y, z). Use with once(). */
1485
- translate?: [x: number, y: number, z: number]
1486
- /** Scale the geometry (x, y, z). Use with once(). */
1487
- scale?: [x: number, y: number, z: number]
1488
- /** Center the geometry based on bounding box. Use with once(). */
1489
- center?: true
1490
- /** Apply a Matrix4 transformation. Use with once(). */
1491
- applyMatrix4?: Matrix4$1
1492
- /** Apply a Quaternion rotation. Use with once(). */
1493
- applyQuaternion?: Quaternion$1
1494
- }
1495
-
1496
- type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
1497
-
1498
- /**
1499
- * Workaround for @types/three TSL node type issues.
1500
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1501
- * This transforms `Node | null` properties to accept any object with node-like shape.
1502
- */
1503
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1504
-
1505
- /**
1506
- * For node material properties (colorNode, positionNode, etc.), accept broader types
1507
- * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1508
- * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1509
- */
1510
- type NodeProps<P> = {
1511
- [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1512
- }
1513
-
1514
- interface ReactProps<P> {
1515
- children?: React.ReactNode
1516
- ref?: React.Ref<P>
1517
- key?: React.Key
1518
- }
1519
-
1520
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1521
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1522
- >
1523
-
1524
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1525
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1526
- >
1527
-
1528
- type ThreeToJSXElements<T extends Record<string, any>> = {
1529
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1530
- }
1531
-
1532
- /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1533
- type Object3DMethod = NonNullable<
1534
- {
1535
- [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1536
- }[keyof Object3D]
1537
- >
1538
-
1539
- type ThreeExports = typeof THREE
1540
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1541
-
1542
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1543
- /**
1544
- * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1545
- * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1546
- * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1547
- * methods are left out of the typed surface: they return `this`, so a subclass element's
1548
- * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1549
- */
1550
- primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
1551
- object: object
1552
- ref?: React.Ref<any>
1553
- onUpdate?: (self: any) => void
1554
- [prop: string]: unknown
1555
- }
1556
- // Conflicts with DOM types can be accessed through a three* prefix
1557
- threeAudio: ThreeElementsImpl['audio']
1558
- threeSource: ThreeElementsImpl['source']
1559
- threeLine: ThreeElementsImpl['line']
1560
- threePath: ThreeElementsImpl['path']
1561
- }
1562
-
1563
- declare module 'react' {
1564
- namespace JSX {
1565
- interface IntrinsicElements extends ThreeElements {}
1566
- }
1567
- }
1568
-
1569
- declare module 'react/jsx-runtime' {
1570
- namespace JSX {
1571
- interface IntrinsicElements extends ThreeElements {}
1572
- }
1573
- }
1574
-
1575
- declare module 'react/jsx-dev-runtime' {
1576
- namespace JSX {
1577
- interface IntrinsicElements extends ThreeElements {}
1578
- }
1579
- }
1580
-
1581
- type three_d_Color = Color;
1582
- type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1583
- type three_d_Euler = Euler;
1584
- type three_d_EventProps<P> = EventProps<P>;
1585
- type three_d_GeometryProps<P> = GeometryProps<P>;
1586
- type three_d_GeometryTransformProps = GeometryTransformProps;
1587
- type three_d_Layers = Layers;
1588
- type three_d_MathProps<P> = MathProps<P>;
1589
- type three_d_MathRepresentation = MathRepresentation;
1590
- type three_d_MathType<T extends MathTypes> = MathType<T>;
1591
- type three_d_MathTypes = MathTypes;
1592
- type three_d_Matrix3 = Matrix3;
1593
- type three_d_Matrix4 = Matrix4;
1594
- type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1595
- type three_d_NodeProps<P> = NodeProps<P>;
1596
- type three_d_Object3DMethod = Object3DMethod;
1597
- type three_d_Quaternion = Quaternion;
1598
- type three_d_RaycastableRepresentation = RaycastableRepresentation;
1599
- type three_d_ReactProps<P> = ReactProps<P>;
1600
- type three_d_TSLNodeInput = TSLNodeInput;
1601
- type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1602
- type three_d_ThreeElements = ThreeElements;
1603
- type three_d_ThreeElementsImpl = ThreeElementsImpl;
1604
- type three_d_ThreeExports = ThreeExports;
1605
- type three_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
1606
- type three_d_Vector2 = Vector2;
1607
- type three_d_Vector3 = Vector3;
1608
- type three_d_Vector4 = Vector4;
1609
- type three_d_VectorRepresentation = VectorRepresentation;
1610
- declare namespace three_d {
1611
- 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 };
1612
- }
1613
-
1614
- /**
1615
- * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1616
- *
1617
- * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1618
- * a single WebGPURenderer using Three.js CanvasTarget API.
1619
- *
1620
- * Primary canvas: Has `id` prop, creates its own renderer, registers here
1621
- * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1622
- */
1623
-
1624
- interface PrimaryCanvasEntry {
1625
- /** The WebGPURenderer instance owned by this primary canvas */
1626
- renderer: WebGPURenderer;
1627
- /** The zustand store for this canvas */
1628
- store: RootStore;
1629
- }
1630
- /**
1631
- * Register a primary canvas that can be targeted by secondary canvases.
1632
- *
1633
- * @param id - Unique identifier for this primary canvas
1634
- * @param renderer - The WebGPURenderer owned by this canvas
1635
- * @param store - The zustand store for this canvas
1636
- * @returns Cleanup function to unregister on unmount
1637
- */
1638
- declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1639
- /**
1640
- * Get a registered primary canvas by id.
1641
- *
1642
- * @param id - The id of the primary canvas to look up
1643
- * @returns The primary canvas entry or undefined if not found
1644
- */
1645
- declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1646
- /**
1647
- * Wait for a primary canvas to be registered.
1648
- * Returns immediately if already registered, otherwise waits.
1649
- *
1650
- * @param id - The id of the primary canvas to wait for
1651
- * @param timeout - Optional timeout in ms (default: 5000)
1652
- * @returns Promise that resolves with the primary canvas entry
1653
- */
1654
- declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1655
- /**
1656
- * Check if a primary canvas with the given id exists.
1657
- *
1658
- * @param id - The id to check
1659
- * @returns True if a primary canvas with this id is registered
1660
- */
1661
- declare function hasPrimary(id: string): boolean;
1662
- /**
1663
- * Unregister a primary canvas. Called on unmount.
1664
- *
1665
- * @param id - The id of the primary canvas to unregister
1666
- */
1667
- declare function unregisterPrimary(id: string): void;
1668
- /**
1669
- * Get all registered primary canvas ids. Useful for debugging.
1670
- */
1671
- declare function getPrimaryIds(): string[];
1672
-
1673
- type EnvironmentLoaderProps = {
1674
- files?: string | string[];
1675
- path?: string;
1676
- preset?: PresetsType;
1677
- extensions?: (loader: Loader) => void;
1678
- colorSpace?: ColorSpace;
1679
- };
1680
- /**
1681
- * Loads environment textures for reflections and lighting.
1682
- * Supports HDR files, presets, and cubemaps.
1683
- *
1684
- * @example Basic usage
1685
- * ```jsx
1686
- * const texture = useEnvironment({ preset: 'sunset' })
1687
- * ```
1688
- */
1689
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1690
- declare namespace useEnvironment {
1691
- var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1692
- var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1693
- }
1694
- /**
1695
- * Options accepted by `useEnvironment.preload`.
1696
- *
1697
- * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1698
- * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1699
- * advertise an option this function silently ignores.
1700
- *
1701
- * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1702
- * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1703
- * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1704
- */
1705
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1706
- type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1707
-
1708
- /**
1709
- * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1710
- *
1711
- * @property children - React children to render into custom environment portal
1712
- * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1713
- * @property near - Near clipping plane for cube camera (default: 0.1)
1714
- * @property far - Far clipping plane for cube camera (default: 1000)
1715
- * @property resolution - Resolution of the cube render target (default: 256)
1716
- * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1717
- *
1718
- * @property blur - @deprecated Use backgroundBlurriness instead
1719
- * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1720
- * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1721
- * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1722
- * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1723
- * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1724
- *
1725
- * @property map - Pre-existing texture to use as environment map
1726
- * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1727
- * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1728
- * @property ground - Ground projection settings. Use true for defaults or object with:
1729
- * - height: Height of camera used to create env map (default: 15)
1730
- * - radius: Radius of the world (default: 60)
1731
- * - scale: Scale of backside projected sphere (default: 1000)
1732
- *
1733
- * Additional loader props:
1734
- * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1735
- * @property path - Base path for file loading
1736
- * @property extensions - Texture extensions override
1737
- */
1738
- type EnvironmentProps = {
1739
- children?: React$1.ReactNode;
1740
- frames?: number;
1741
- near?: number;
1742
- far?: number;
1743
- resolution?: number;
1744
- background?: boolean | 'only';
1745
- /** deprecated, use backgroundBlurriness */
1746
- blur?: number;
1747
- backgroundBlurriness?: number;
1748
- backgroundIntensity?: number;
1749
- backgroundRotation?: Euler;
1750
- environmentIntensity?: number;
1751
- environmentRotation?: Euler;
1752
- map?: Texture$1;
1753
- preset?: PresetsType;
1754
- scene?: Scene | React$1.RefObject<Scene>;
1755
- ground?: boolean | {
1756
- radius?: number;
1757
- height?: number;
1758
- scale?: number;
1759
- };
1760
- /** Solid color for background (alternative to files/preset) */
1761
- color?: ColorRepresentation;
1762
- /** Separate files for background (when different from environment files) */
1763
- backgroundFiles?: string | string[];
1764
- } & EnvironmentLoaderProps;
1765
- /**
1766
- * Internal component that applies a pre-existing texture as environment map.
1767
- * Sets scene.environment and optionally scene.background.
1768
- *
1769
- * @example
1770
- * ```jsx
1771
- * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1772
- * ```
1773
- */
1774
- declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1775
- /**
1776
- * Internal component that loads environment textures from files or presets.
1777
- * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1778
- * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1779
- *
1780
- * @example With preset
1781
- * ```jsx
1782
- * <EnvironmentCube preset="sunset" />
1783
- * ```
1784
- *
1785
- * @example From HDR file
1786
- * ```jsx
1787
- * <EnvironmentCube files="environment.hdr" />
1788
- * ```
1789
- *
1790
- * @example From gainmap (smallest footprint)
1791
- * ```jsx
1792
- * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1793
- * ```
1794
- *
1795
- * @example From cube faces
1796
- * ```jsx
1797
- * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1798
- * ```
1799
- */
1800
- declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1801
- /**
1802
- * Internal component that renders custom environment using a portal and cube camera.
1803
- * Renders children into an off-buffer and films with a cube camera to create environment map.
1804
- * Can be static (frames=1) or animated (frames=Infinity).
1805
- *
1806
- * @example Custom environment with sphere
1807
- * ```jsx
1808
- * <EnvironmentPortal background near={1} far={1000} resolution={256}>
1809
- * <mesh scale={100}>
1810
- * <sphereGeometry args={[1, 64, 64]} />
1811
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1812
- * </mesh>
1813
- * </EnvironmentPortal>
1814
- * ```
1815
- *
1816
- * @example Animated environment
1817
- * ```jsx
1818
- * <EnvironmentPortal frames={Infinity} resolution={256}>
1819
- * <Float>
1820
- * <mesh />
1821
- * </Float>
1822
- * </EnvironmentPortal>
1823
- * ```
1824
- *
1825
- * @example Mixed with preset
1826
- * ```jsx
1827
- * <EnvironmentPortal preset="warehouse">
1828
- * <mesh />
1829
- * </EnvironmentPortal>
1830
- * ```
1831
- */
1832
- 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;
1833
- declare module '@react-three/fiber' {
1834
- interface ThreeElements {
1835
- groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
1836
- }
1837
- }
1838
- /**
1839
- * Sets up a global environment map for PBR materials and backgrounds.
1840
- * Affects scene.environment and optionally scene.background unless a custom scene is passed.
1841
- *
1842
- * Supports multiple input methods:
1843
- * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1844
- * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
1845
- * - **Texture**: Pre-existing cube texture via `map` prop
1846
- * - **Custom Scene**: Render children into environment using portal and cube camera
1847
- * - **Ground Projection**: Project environment onto ground plane
1848
- *
1849
- * @remarks
1850
- * - Preset property is NOT meant for production and may fail (relies on CDNs)
1851
- * - Gainmap format has the smallest file footprint
1852
- * - Use `frames={Infinity}` for animated environments with low resolution for performance
1853
- * - Ground projection places models on the "ground" within the environment map
1854
- * - Supports self-hosting with @pmndrs/assets using dynamic imports
1855
- *
1856
- * @example Basic preset usage
1857
- * ```jsx
1858
- * <Environment preset="sunset" />
1859
- * ```
1860
- *
1861
- * @example From HDR file
1862
- * ```jsx
1863
- * <Environment files="/hdr/environment.hdr" />
1864
- * ```
1865
- *
1866
- * @example From gainmap (smallest footprint)
1867
- * ```jsx
1868
- * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1869
- * ```
1870
- *
1871
- * @example With self-hosted assets
1872
- * ```jsx
1873
- * import { suspend } from 'suspend-react'
1874
- * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
1875
- *
1876
- * <Environment files={suspend(city)} />
1877
- * ```
1878
- *
1879
- * @example From existing texture
1880
- * ```jsx
1881
- * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
1882
- * ```
1883
- *
1884
- * @example Custom environment scene
1885
- * ```jsx
1886
- * <Environment background near={1} far={1000} resolution={256}>
1887
- * <mesh scale={100}>
1888
- * <sphereGeometry args={[1, 64, 64]} />
1889
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1890
- * </mesh>
1891
- * </Environment>
1892
- * ```
1893
- *
1894
- * @example Animated environment
1895
- * ```jsx
1896
- * <Environment frames={Infinity} resolution={256}>
1897
- * <Float>
1898
- * <mesh />
1899
- * </Float>
1900
- * </Environment>
1901
- * ```
1902
- *
1903
- * @example Mixed custom scene with preset
1904
- * ```jsx
1905
- * <Environment background preset="warehouse">
1906
- * <mesh />
1907
- * </Environment>
1908
- * ```
1909
- *
1910
- * @example With ground projection
1911
- * ```jsx
1912
- * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
1913
- * ```
1914
- *
1915
- * @example As background only
1916
- * ```jsx
1917
- * <Environment background="only" preset="sunset" />
1918
- * ```
1919
- *
1920
- * @example With rotation and intensity
1921
- * ```jsx
1922
- * <Environment
1923
- * background
1924
- * backgroundBlurriness={0.5}
1925
- * backgroundIntensity={0.8}
1926
- * backgroundRotation={[0, Math.PI / 2, 0]}
1927
- * environmentIntensity={1.2}
1928
- * environmentRotation={[0, Math.PI / 4, 0]}
1929
- * preset="studio"
1930
- * />
1931
- * ```
1932
- */
1933
- declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
1934
-
1935
- /**
1936
- * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1937
- *
1938
- * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1939
- * instance. Removing the old object from the interaction state and registering the new one from
1940
- * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1941
- * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1942
- * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1943
- * swap the user never asked to see (#3744).
1944
- *
1945
- * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1946
- * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1947
- *
1948
- * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1949
- * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1950
- * cannot outlive the object it described.
1951
- */
1952
- declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
1953
- declare function removeInteractivity(store: RootStore, object: Object3D): void;
1954
- declare function createEvents(store: RootStore): {
1955
- handlePointer: (name: string) => (event: DomEvent) => void;
1956
- flushDeferredPointers: () => void;
1957
- processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1958
- };
1959
- /** Default R3F event manager for web */
1960
- declare function createPointerEvents(store: RootStore): EventManager<Element>;
1961
-
1962
- /**
1963
- * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
1964
- * This allows external code to access loader methods like abort().
1965
- */
1966
- declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
1967
- /**
1968
- * Synchronously loads and caches assets with a three loader.
1969
- *
1970
- * Note: this hook's caller must be wrapped with `React.Suspense`
1971
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1972
- */
1973
- 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>;
1974
- declare namespace useLoader {
1975
- 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;
1976
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
1977
- var loader: typeof getLoader;
1978
- }
1979
-
1980
- /**
1981
- * Frame hook with phase-based ordering, priority, and FPS throttling.
1982
- *
1983
- * Always delivers full RootState — works both inside and outside Canvas context:
1984
- * - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
1985
- * - Outside Canvas: The job registers immediately but the callback is held until a
1986
- * Canvas adopts it, then runs with full RootState. For hostless / standalone
1987
- * frame loops with no Canvas, use `@pmndrs/scheduler` directly.
1988
- *
1989
- * Returns a controls object for manual stepping, pausing, and resuming.
1990
- *
1991
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1992
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1993
- * @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
1994
- *
1995
- * @example
1996
- * // Simple priority (backwards compat)
1997
- * useFrame((state, delta) => { ... }, 5)
1998
- *
1999
- * @example
2000
- * // With phase-based ordering
2001
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
2002
- *
2003
- * @example
2004
- * // Outside Canvas - callback waits for a Canvas, then always has full state
2005
- * function UI() {
2006
- * useFrame((state, delta) => { syncUI(state.camera) });
2007
- * return <button>...</button>;
2008
- * }
2009
- *
2010
- * @example
2011
- * // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
2012
- * import { getScheduler } from '@pmndrs/scheduler'
2013
- * getScheduler().register((state, delta) => { updateGame(delta) })
2014
- *
2015
- * @example
2016
- * // Scheduler-only access (no callback)
2017
- * const { scheduler } = useFrame()
2018
- * scheduler.pauseJob('some-job-id')
2019
- *
2020
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
2021
- */
2022
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
2023
-
2024
- declare const IsObject: (url: unknown) => url is Record<string, string>;
2025
- type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2026
- type TextureRecord<T> = T extends Record<string, string> ? {
2027
- [key in keyof T]: Texture$1;
2028
- } : never;
2029
- type SingleTexture<T> = T extends string ? Texture$1 : never;
2030
- type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
2031
- /** Options for useTexture hook */
2032
- type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
2033
- /** Callback when texture(s) finish loading */
2034
- onLoad?: (texture: MappedTextureType<Url>) => void;
2035
- /**
2036
- * Register the texture(s) in R3F's global texture registry for access via useTextures().
2037
- * When true (the default):
2038
- * - Textures persist until explicitly disposed
2039
- * - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
2040
- *
2041
- * Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
2042
- * changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
2043
- *
2044
- * Pass `false` to opt out of registry enrollment entirely.
2045
- * @default true
2046
- */
2047
- cache?: boolean;
2048
- };
2049
- /**
2050
- * Load texture(s) using Three's TextureLoader with Suspense support.
2051
- *
2052
- * @param input - URL string, array of URLs, or object mapping keys to URLs
2053
- * @param optionsOrOnLoad - Options object or legacy onLoad callback
2054
- *
2055
- * @example
2056
- * ```tsx
2057
- * // Single texture
2058
- * const diffuse = useTexture('/textures/diffuse.png')
2059
- *
2060
- * // Multiple textures (array)
2061
- * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
2062
- *
2063
- * // Named textures (object)
2064
- * const { diffuse, normal } = useTexture({
2065
- * diffuse: '/diffuse.png',
2066
- * normal: '/normal.png'
2067
- * })
2068
- *
2069
- * // Textures are registered in the global registry by default — the same texture
2070
- * // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
2071
- * const diffuse = useTexture('/diffuse.png')
2072
- * diffuse.colorSpace = THREE.SRGBColorSpace
2073
- *
2074
- * // Another component gets the SAME texture with colorSpace already set
2075
- * const sameDiffuse = useTexture('/diffuse.png')
2076
- *
2077
- * // Opt out of registry enrollment for a one-off texture
2078
- * const scratch = useTexture('/scratch.png', { cache: false })
2079
- *
2080
- * // Access the registry directly
2081
- * const { get } = useTextures()
2082
- * const cached = get('/diffuse.png')
2083
- * ```
2084
- */
2085
- declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
2086
- declare namespace useTexture {
2087
- var preload: (url: string | string[]) => void;
2088
- var clear: (input: string | string[]) => void;
2089
- }
2090
- declare const Texture: ({ children, input, onLoad, cache, }: {
2091
- children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
2092
- input: Parameters<typeof useTexture>[0];
2093
- onLoad?: Parameters<typeof useTexture>[1];
2094
- cache?: boolean;
2095
- }) => react_jsx_runtime.JSX.Element;
2096
-
2097
- /** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
2098
- type TextureInput = string | string[] | Record<string, string>;
2099
- /** Result of a `get()` read, mirroring the input shape. */
2100
- type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
2101
- [K in keyof Input]: Texture$1 | undefined;
2102
- };
2103
- /** Options for `dispose()`. */
2104
- interface DisposeOptions {
2105
- /** Dispose even if the texture still has active references (default false). */
2106
- force?: boolean;
2107
- }
2108
- interface UseTexturesReturn {
2109
- /** The live registry Map (key → Texture). Treat as read-only. */
2110
- readonly all: Map<string, Texture$1>;
2111
- /** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
2112
- get<Input extends TextureInput>(input: Input): TextureResult<Input>;
2113
- /** Check whether a key exists in the registry. */
2114
- has(key: string): boolean;
2115
- /**
2116
- * Register a texture (or a record of textures) that has no URL — e.g. a render
2117
- * target or procedural texture. URL-loaded textures are registered automatically
2118
- * by `useTexture` (registry enrollment is on by default).
2119
- */
2120
- add(key: string, texture: Texture$1): void;
2121
- add(record: Record<string, Texture$1>): void;
2122
- /**
2123
- * Dispose a texture's GPU resources and remove it from the registry.
2124
- * Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
2125
- * skipped (with a warning) unless `{ force: true }` is passed.
2126
- * @returns true if disposed, false if skipped.
2127
- */
2128
- dispose(key: string, options?: DisposeOptions): boolean;
2129
- /** Dispose every texture in the registry and clear it. Use on scene teardown. */
2130
- disposeAll(): void;
2131
- }
2132
- /**
2133
- * Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
2134
- *
2135
- * This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
2136
- * a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
2137
- * `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
2138
- *
2139
- * The returned handle is **reactive**: the calling component re-renders when the registry
2140
- * changes. Pass a selector to scope the subscription to a single read.
2141
- *
2142
- * @example
2143
- * ```tsx
2144
- * // Load + register once (anywhere in the tree) — registered by default
2145
- * useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
2146
- *
2147
- * // Reach them from another component — record form lands straight into a material
2148
- * const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
2149
- * return <meshStandardMaterial map={map} normalMap={normalMap} />
2150
- *
2151
- * // A set of heightmaps at once
2152
- * const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
2153
- *
2154
- * // Register a non-URL texture (render target / procedural)
2155
- * useTextures().add('rt-main', renderTarget.texture)
2156
- *
2157
- * // Deliberate GPU cleanup (refcount-aware; force to override)
2158
- * useTextures().dispose('/diffuse.jpg')
2159
- * useTextures().disposeAll() // scene teardown
2160
- * ```
2161
- *
2162
- * @remarks
2163
- * **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
2164
- * intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
2165
- * populate the registry without Suspense, at the cost of putting loading back into this hook. It
2166
- * will be added only if a concrete consumer needs imperative loading; for now, loading lives in
2167
- * `useTexture`.
2168
- */
2169
- declare function useTextures(): UseTexturesReturn;
2170
- declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
2171
-
2172
- /**
2173
- * Creates a render target compatible with the current renderer.
2174
- *
2175
- * - Legacy build: Returns WebGLRenderTarget
2176
- * - WebGPU build: Returns RenderTarget
2177
- * - Default build: Returns whichever matches the active renderer
2178
- *
2179
- * @example
2180
- * ```tsx
2181
- * // Use canvas size
2182
- * const fbo = useRenderTarget()
2183
- *
2184
- * // Use canvas size with options
2185
- * const fbo = useRenderTarget({ samples: 4 })
2186
- *
2187
- * // Square render target
2188
- * const fbo = useRenderTarget(512)
2189
- *
2190
- * // Square render target with options
2191
- * const fbo = useRenderTarget(512, { depthBuffer: true })
2192
- *
2193
- * // Explicit dimensions
2194
- * const fbo = useRenderTarget(512, 256)
2195
- *
2196
- * // Explicit dimensions with options
2197
- * const fbo = useRenderTarget(512, 256, { samples: 4 })
2198
- * ```
2199
- */
2200
- declare function useRenderTarget(options?: RenderTargetOptions): WebGLRenderTarget;
2201
- declare function useRenderTarget(size: number, options?: RenderTargetOptions): WebGLRenderTarget;
2202
- declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): WebGLRenderTarget;
2203
-
2204
- /**
2205
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2206
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2207
- */
2208
- declare function useStore(): RootStore;
2209
- /**
2210
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2211
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2212
- */
2213
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2214
- /**
2215
- * Exposes an object's {@link Instance}.
2216
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
2217
- *
2218
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
2219
- */
2220
- declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
2221
- /**
2222
- * Returns a node graph of an object with named nodes & materials.
2223
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
2224
- */
2225
- declare function useGraph(object: Object3D): ObjectMap;
2226
-
2227
- /**
2228
- * Adds a global render callback which is called each frame BEFORE rendering.
2229
- *
2230
- * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
2231
- * This function will be removed in a future version.
2232
- *
2233
- * @param callback - Function called each frame with timestamp
2234
- * @returns Unsubscribe function
2235
- *
2236
- * @example
2237
- * // OLD (deprecated)
2238
- * const unsub = addEffect((timestamp) => { ... })
2239
- *
2240
- * // NEW
2241
- * useFrame((state, delta) => { ... }, { phase: 'start' })
2242
- *
2243
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
2244
- */
2245
- declare function addEffect(callback: GlobalRenderCallback): () => void;
2246
- /**
2247
- * Adds a global after-render callback which is called each frame AFTER rendering.
2248
- *
2249
- * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
2250
- * This function will be removed in a future version.
2251
- *
2252
- * @param callback - Function called each frame with timestamp
2253
- * @returns Unsubscribe function
2254
- *
2255
- * @example
2256
- * // OLD (deprecated)
2257
- * const unsub = addAfterEffect((timestamp) => { ... })
2258
- *
2259
- * // NEW
2260
- * useFrame((state, delta) => { ... }, { phase: 'finish' })
2261
- *
2262
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
2263
- */
2264
- declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
2265
- /**
2266
- * Adds a global callback which is called when rendering stops.
2267
- *
2268
- * @deprecated Use `scheduler.onIdle(callback)` instead.
2269
- * This function will be removed in a future version.
2270
- *
2271
- * @param callback - Function called when rendering stops
2272
- * @returns Unsubscribe function
2273
- *
2274
- * @example
2275
- * // OLD (deprecated)
2276
- * const unsub = addTail((timestamp) => { ... })
2277
- *
2278
- * // NEW
2279
- * const { scheduler } = useFrame()
2280
- * const unsub = scheduler.onIdle((timestamp) => { ... })
2281
- *
2282
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
2283
- */
2284
- declare function addTail(callback: GlobalRenderCallback): () => void;
2285
- /**
2286
- * Invalidates the view, requesting a frame to be rendered.
2287
- * In demand mode, this triggers the scheduler to run frames.
2288
- *
2289
- * With a state argument, only that root's jobs run on the requested frames; other
2290
- * roots on 'demand' stay idle. Without one, every registered root is invalidated.
2291
- *
2292
- * @param state - Optional root state; targets the invalidation at that root
2293
- * @param frames - Number of frames to request (default: 1)
2294
- * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2295
- *
2296
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
2297
- */
2298
- declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
2299
- /**
2300
- * Advances the frameloop and runs render effects.
2301
- * Useful for when manually rendering via `frameloop="never"`.
2302
- *
2303
- * With a state argument, only that root is stepped. Without one, every
2304
- * registered root is stepped for backwards compatibility.
2305
- *
2306
- * @param timestamp - The timestamp to use for this frame
2307
- * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2308
- * @param state - Optional root state; targets the manual step at that root
2309
- *
2310
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2311
- */
2312
- declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
2313
-
2314
- /* eslint-disable @definitelytyped/no-unnecessary-generics */
2315
- declare function ReactReconciler<
2316
- Type,
2317
- Props,
2318
- Container,
2319
- Instance,
2320
- TextInstance,
2321
- SuspenseInstance,
2322
- HydratableInstance,
2323
- FormInstance,
2324
- PublicInstance,
2325
- HostContext,
2326
- ChildSet,
2327
- TimeoutHandle,
2328
- NoTimeout,
2329
- TransitionStatus,
2330
- >(
2331
- /* eslint-enable @definitelytyped/no-unnecessary-generics */
2332
- config: ReactReconciler.HostConfig<
2333
- Type,
2334
- Props,
2335
- Container,
2336
- Instance,
2337
- TextInstance,
2338
- SuspenseInstance,
2339
- HydratableInstance,
2340
- FormInstance,
2341
- PublicInstance,
2342
- HostContext,
2343
- ChildSet,
2344
- TimeoutHandle,
2345
- NoTimeout,
2346
- TransitionStatus
2347
- >,
2348
- ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
2349
-
2350
- declare namespace ReactReconciler {
2351
- interface HostConfig<
2352
- Type,
2353
- Props,
2354
- Container,
2355
- Instance,
2356
- TextInstance,
2357
- SuspenseInstance,
2358
- HydratableInstance,
2359
- FormInstance,
2360
- PublicInstance,
2361
- HostContext,
2362
- ChildSet,
2363
- TimeoutHandle,
2364
- NoTimeout,
2365
- TransitionStatus,
2366
- > {
2367
- // -------------------
2368
- // Modes
2369
- // -------------------
2370
- /**
2371
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2372
- *
2373
- * 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.
2374
- *
2375
- * ```js
2376
- * const HostConfig = {
2377
- * // ...
2378
- * supportsMutation: true,
2379
- * // ...
2380
- * }
2381
- * ```
2382
- *
2383
- * Depending on the mode, the reconciler will call different methods on your host config.
2384
- *
2385
- * If you're not sure which one you want, you likely need the mutation mode.
2386
- */
2387
- supportsMutation: boolean;
2388
-
2389
- /**
2390
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2391
- *
2392
- * 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".
2393
- *
2394
- * ```js
2395
- * const HostConfig = {
2396
- * // ...
2397
- * supportsPersistence: true,
2398
- * // ...
2399
- * }
2400
- * ```
2401
- *
2402
- * Depending on the mode, the reconciler will call different methods on your host config.
2403
- *
2404
- * If you're not sure which one you want, you likely need the mutation mode.
2405
- */
2406
- supportsPersistence: boolean;
2407
-
2408
- // -------------------
2409
- // Core Methods
2410
- // -------------------
2411
-
2412
- /**
2413
- * 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`.
2414
- *
2415
- * 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.
2416
- *
2417
- * 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.
2418
- *
2419
- * 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.
2420
- *
2421
- * 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.
2422
- */
2423
- createInstance(
2424
- type: Type,
2425
- props: Props,
2426
- rootContainer: Container,
2427
- hostContext: HostContext,
2428
- internalHandle: OpaqueHandle,
2429
- ): Instance;
2430
-
2431
- /**
2432
- * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
2433
- */
2434
- createTextInstance(
2435
- text: string,
2436
- rootContainer: Container,
2437
- hostContext: HostContext,
2438
- internalHandle: OpaqueHandle,
2439
- ): TextInstance;
2440
-
2441
- /**
2442
- * 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.
2443
- *
2444
- * 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.
2445
- */
2446
- appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
2447
-
2448
- /**
2449
- * 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.
2450
- *
2451
- * 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.
2452
- *
2453
- * 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.
2454
- *
2455
- * If you don't want to do anything here, you should return `false`.
2456
- */
2457
- finalizeInitialChildren(
2458
- instance: Instance,
2459
- type: Type,
2460
- props: Props,
2461
- rootContainer: Container,
2462
- hostContext: HostContext,
2463
- ): boolean;
2464
-
2465
- /**
2466
- * 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.
2467
- *
2468
- * 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.
2469
- *
2470
- * If you don't want to do anything here, you should return `false`.
2471
- *
2472
- * This method happens **in the render phase**. Do not mutate the tree from it.
2473
- */
2474
- shouldSetTextContent(type: Type, props: Props): boolean;
2475
-
2476
- /**
2477
- * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
2478
- *
2479
- * If you don't intend to use host context, you can return `null`.
2480
- *
2481
- * This method happens **in the render phase**. Do not mutate the tree from it.
2482
- */
2483
- getRootHostContext(rootContainer: Container): HostContext | null;
2484
-
2485
- /**
2486
- * 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.
2487
- *
2488
- * 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.
2489
- *
2490
- * If you don't want to do anything here, return `parentHostContext`.
2491
- *
2492
- * This method happens **in the render phase**. Do not mutate the tree from it.
2493
- */
2494
- getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
2495
-
2496
- /**
2497
- * 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.
2498
- *
2499
- * If you don't want to do anything here, return `instance`.
2500
- */
2501
- getPublicInstance(instance: Instance | TextInstance): PublicInstance;
2502
-
2503
- /**
2504
- * 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`.
2505
- *
2506
- * Even if you don't want to do anything here, you need to return `null` from it.
2507
- */
2508
- prepareForCommit(containerInfo: Container): Record<string, any> | null;
2509
-
2510
- /**
2511
- * 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.
2512
- *
2513
- * You can leave it empty.
2514
- */
2515
- resetAfterCommit(containerInfo: Container): void;
2516
-
2517
- /**
2518
- * This method is called for a container that's used as a portal target. Usually you can leave it empty.
2519
- */
2520
- preparePortalMount(containerInfo: Container): void;
2521
-
2522
- /**
2523
- * You can proxy this to `setTimeout` or its equivalent in your environment.
2524
- */
2525
- scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
2526
-
2527
- /**
2528
- * You can proxy this to `clearTimeout` or its equivalent in your environment.
2529
- */
2530
- cancelTimeout(id: TimeoutHandle): void;
2531
-
2532
- /**
2533
- * 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`.
2534
- */
2535
- noTimeout: NoTimeout;
2536
-
2537
- /**
2538
- * 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.
2539
- */
2540
- supportsMicrotasks?: boolean;
2541
-
2542
- /**
2543
- * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
2544
- */
2545
- scheduleMicrotask?(fn: () => unknown): void;
2546
-
2547
- /**
2548
- * 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`.
2549
- */
2550
- isPrimaryRenderer: boolean;
2551
-
2552
- /**
2553
- * Whether the renderer shouldn't trigger missing `act()` warnings
2554
- */
2555
- warnsIfNotActing?: boolean;
2556
-
2557
- getInstanceFromNode(node: any): Fiber | null | undefined;
2558
-
2559
- beforeActiveInstanceBlur(): void;
2560
-
2561
- afterActiveInstanceBlur(): void;
2562
-
2563
- prepareScopeUpdate(scopeInstance: any, instance: any): void;
2564
-
2565
- getInstanceFromScope(scopeInstance: any): null | Instance;
2566
-
2567
- detachDeletedInstance(node: Instance): void;
2568
-
2569
- // -------------------
2570
- // Mutation Methods
2571
- // (optional)
2572
- // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
2573
- // -------------------
2574
-
2575
- /**
2576
- * 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.
2577
- *
2578
- * 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`.
2579
- */
2580
- appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
2581
-
2582
- /**
2583
- * 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.
2584
- */
2585
- appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
2586
-
2587
- /**
2588
- * 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.
2589
- *
2590
- * 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.
2591
- */
2592
- insertBefore?(
2593
- parentInstance: Instance,
2594
- child: Instance | TextInstance,
2595
- beforeChild: Instance | TextInstance | SuspenseInstance,
2596
- ): void;
2597
-
2598
- /**
2599
- * 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.
2600
- */
2601
- insertInContainerBefore?(
2602
- container: Container,
2603
- child: Instance | TextInstance,
2604
- beforeChild: Instance | TextInstance | SuspenseInstance,
2605
- ): void;
2606
-
2607
- /**
2608
- * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
2609
- *
2610
- * 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.
2611
- */
2612
- removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
2613
-
2614
- /**
2615
- * 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.
2616
- */
2617
- removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
2618
-
2619
- /**
2620
- * 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 = ''`.
2621
- *
2622
- * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
2623
- */
2624
- resetTextContent?(instance: Instance): void;
2625
-
2626
- /**
2627
- * This method should mutate the `textInstance` and update its text content to `nextText`.
2628
- *
2629
- * Here, `textInstance` is a node created by `createTextInstance`.
2630
- */
2631
- commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
2632
-
2633
- /**
2634
- * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
2635
- *
2636
- * 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.
2637
- *
2638
- * 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.
2639
- *
2640
- * 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.
2641
- *
2642
- * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
2643
- */
2644
- commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
2645
-
2646
- /**
2647
- * This method should mutate the instance to match nextProps.
2648
- *
2649
- * 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.
2650
- */
2651
- commitUpdate?(
2652
- instance: Instance,
2653
- type: Type,
2654
- prevProps: Props,
2655
- nextProps: Props,
2656
- internalHandle: OpaqueHandle,
2657
- ): void;
2658
-
2659
- /**
2660
- * 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.
2661
- */
2662
- hideInstance?(instance: Instance): void;
2663
-
2664
- /**
2665
- * Same as `hideInstance`, but for nodes created by `createTextInstance`.
2666
- */
2667
- hideTextInstance?(textInstance: TextInstance): void;
2668
-
2669
- /**
2670
- * This method should make the `instance` visible, undoing what `hideInstance` did.
2671
- */
2672
- unhideInstance?(instance: Instance, props: Props): void;
2673
-
2674
- /**
2675
- * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
2676
- */
2677
- unhideTextInstance?(textInstance: TextInstance, text: string): void;
2678
-
2679
- /**
2680
- * This method should mutate the `container` root node and remove all children from it.
2681
- */
2682
- clearContainer?(container: Container): void;
2683
-
2684
- // -------------------
2685
- // Persistence Methods
2686
- // (optional)
2687
- // 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.
2688
- // -------------------
2689
- cloneInstance?(
2690
- instance: Instance,
2691
- type: Type,
2692
- oldProps: Props,
2693
- newProps: Props,
2694
- keepChildren: boolean,
2695
- recyclableInstance: null | Instance,
2696
- ): Instance;
2697
- createContainerChildSet?(container: Container): ChildSet;
2698
- appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
2699
- finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
2700
- replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
2701
- cloneHiddenInstance?(
2702
- instance: Instance,
2703
- type: Type,
2704
- props: Props,
2705
- internalInstanceHandle: OpaqueHandle,
2706
- ): Instance;
2707
- cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
2708
-
2709
- // -------------------
2710
- // Hydration Methods
2711
- // (optional)
2712
- // 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.
2713
- //
2714
- // 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.
2715
- // -------------------
2716
- supportsHydration: boolean;
2717
-
2718
- canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
2719
-
2720
- canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
2721
-
2722
- canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
2723
-
2724
- isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
2725
-
2726
- isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
2727
-
2728
- registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
2729
-
2730
- getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
2731
-
2732
- getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
2733
-
2734
- hydrateInstance?(
2735
- instance: Instance,
2736
- type: Type,
2737
- props: Props,
2738
- rootContainerInstance: Container,
2739
- hostContext: HostContext,
2740
- internalInstanceHandle: any,
2741
- ): null | any[];
2742
-
2743
- hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
2744
-
2745
- hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
2746
-
2747
- getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
2748
-
2749
- // Returns the SuspenseInstance if this node is a direct child of a
2750
- // SuspenseInstance. I.e. if its previous sibling is a Comment with
2751
- // SUSPENSE_x_START_DATA. Otherwise, null.
2752
- getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
2753
-
2754
- commitHydratedContainer?(container: Container): void;
2755
-
2756
- commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
2757
-
2758
- didNotMatchHydratedContainerTextInstance?(
2759
- parentContainer: Container,
2760
- textInstance: TextInstance,
2761
- text: string,
2762
- ): void;
2763
-
2764
- didNotMatchHydratedTextInstance?(
2765
- parentType: Type,
2766
- parentProps: Props,
2767
- parentInstance: Instance,
2768
- textInstance: TextInstance,
2769
- text: string,
2770
- ): void;
2771
-
2772
- didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
2773
-
2774
- didNotHydrateInstance?(
2775
- parentType: Type,
2776
- parentProps: Props,
2777
- parentInstance: Instance,
2778
- instance: HydratableInstance,
2779
- ): void;
2780
-
2781
- didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
2782
-
2783
- didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
2784
-
2785
- didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
2786
-
2787
- didNotFindHydratableInstance?(
2788
- parentType: Type,
2789
- parentProps: Props,
2790
- parentInstance: Instance,
2791
- type: Type,
2792
- props: Props,
2793
- ): void;
2794
-
2795
- didNotFindHydratableTextInstance?(
2796
- parentType: Type,
2797
- parentProps: Props,
2798
- parentInstance: Instance,
2799
- text: string,
2800
- ): void;
2801
-
2802
- didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
2803
-
2804
- errorHydratingContainer?(parentContainer: Container): void;
2805
-
2806
- // Undocumented
2807
- // https://github.com/facebook/react/pull/26722
2808
- NotPendingTransition: TransitionStatus | null;
2809
- HostTransitionContext: ReactContext<TransitionStatus>;
2810
-
2811
- // https://github.com/facebook/react/pull/28751
2812
- setCurrentUpdatePriority(newPriority: EventPriority): void;
2813
- getCurrentUpdatePriority(): EventPriority;
2814
- resolveUpdatePriority(): EventPriority;
2815
-
2816
- // https://github.com/facebook/react/pull/28804
2817
- resetFormInstance(form: FormInstance): void;
2818
-
2819
- // https://github.com/facebook/react/pull/25105
2820
- requestPostPaintCallback(callback: (time: number) => void): void;
2821
-
2822
- // https://github.com/facebook/react/pull/26025
2823
- shouldAttemptEagerTransition(): boolean;
2824
-
2825
- // https://github.com/facebook/react/pull/31528
2826
- trackSchedulerEvent(): void;
2827
-
2828
- // https://github.com/facebook/react/pull/31008
2829
- resolveEventType(): null | string;
2830
- resolveEventTimeStamp(): number;
2831
-
2832
- /**
2833
- * 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.
2834
- */
2835
- maySuspendCommit(type: Type, props: Props): boolean;
2836
-
2837
- /**
2838
- * 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.
2839
- */
2840
- preloadInstance(type: Type, props: Props): boolean;
2841
-
2842
- /**
2843
- * 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.
2844
- */
2845
- startSuspendingCommit(): void;
2846
-
2847
- /**
2848
- * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
2849
- */
2850
- suspendInstance(type: Type, props: Props): void;
2851
-
2852
- /**
2853
- * This method is called after all `suspendInstance` calls are complete.
2854
- *
2855
- * Return `null` if the commit can happen immediately.
2856
- *
2857
- * 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.
2858
- */
2859
- waitForCommitToBeReady():
2860
- | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
2861
- | null;
2862
- }
2863
-
2864
- interface Thenable<T> {
2865
- then(resolve: () => T, reject?: () => T): T;
2866
- }
2867
-
2868
- type RootTag = 0 | 1 | 2;
2869
-
2870
- type WorkTag =
2871
- | 0
2872
- | 1
2873
- | 2
2874
- | 3
2875
- | 4
2876
- | 5
2877
- | 6
2878
- | 7
2879
- | 8
2880
- | 9
2881
- | 10
2882
- | 11
2883
- | 12
2884
- | 13
2885
- | 14
2886
- | 15
2887
- | 16
2888
- | 17
2889
- | 18
2890
- | 19
2891
- | 20
2892
- | 21
2893
- | 22
2894
- | 23
2895
- | 24;
2896
-
2897
- type HookType =
2898
- | "useState"
2899
- | "useReducer"
2900
- | "useContext"
2901
- | "useRef"
2902
- | "useEffect"
2903
- | "useLayoutEffect"
2904
- | "useCallback"
2905
- | "useMemo"
2906
- | "useImperativeHandle"
2907
- | "useDebugValue"
2908
- | "useDeferredValue"
2909
- | "useTransition"
2910
- | "useMutableSource"
2911
- | "useOpaqueIdentifier"
2912
- | "useCacheRefresh";
2913
-
2914
- interface Source {
2915
- fileName: string;
2916
- lineNumber: number;
2917
- }
2918
-
2919
- // TODO: Ideally these types would be opaque but that doesn't work well with
2920
- // our reconciler fork infra, since these leak into non-reconciler packages.
2921
- type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
2922
-
2923
- type Lanes = number;
2924
- type Lane = number;
2925
-
2926
- type Flags = number;
2927
-
2928
- type TypeOfMode = number;
2929
-
2930
- type EventPriority = number;
2931
-
2932
- interface ReactProvider<T> {
2933
- $$typeof: symbol | number;
2934
- type: ReactProviderType<T>;
2935
- key: null | string;
2936
- ref: null;
2937
- props: {
2938
- value: T;
2939
- children?: ReactNode;
2940
- };
2941
- }
2942
-
2943
- interface ReactProviderType<T> {
2944
- $$typeof: symbol | number;
2945
- _context: ReactContext<T>;
2946
- }
2947
-
2948
- interface ReactConsumer<T> {
2949
- $$typeof: symbol | number;
2950
- type: ReactContext<T>;
2951
- key: null | string;
2952
- ref: null;
2953
- props: {
2954
- children: (value: T) => ReactNode;
2955
- unstable_observedBits?: number;
2956
- };
2957
- }
2958
-
2959
- interface ReactContext<T> {
2960
- $$typeof: symbol | number;
2961
- Consumer: ReactContext<T>;
2962
- Provider: ReactProviderType<T>;
2963
- _currentValue: T;
2964
- _currentValue2: T;
2965
- _threadCount: number;
2966
- // DEV only
2967
- _currentRenderer?: {
2968
- [key: string]: any;
2969
- } | null;
2970
- _currentRenderer2?: {
2971
- [key: string]: any;
2972
- } | null;
2973
- // This value may be added by application code
2974
- // to improve DEV tooling display names
2975
- displayName?: string;
2976
- }
2977
-
2978
- interface ReactPortal {
2979
- $$typeof: symbol | number;
2980
- key: null | string;
2981
- containerInfo: any;
2982
- children: ReactNode;
2983
- // TODO: figure out the API for cross-renderer implementation.
2984
- implementation: any;
2985
- }
2986
-
2987
- interface RefObject {
2988
- current: any;
2989
- }
2990
-
2991
- interface ContextDependency<T> {
2992
- context: ReactContext<T>;
2993
- observedBits: number;
2994
- next: ContextDependency<unknown> | null;
2995
- }
2996
-
2997
- interface Dependencies {
2998
- lanes: Lanes;
2999
- firstContext: ContextDependency<unknown> | null;
3000
- }
3001
-
3002
- interface Fiber {
3003
- // These first fields are conceptually members of an Instance. This used to
3004
- // be split into a separate type and intersected with the other Fiber fields,
3005
- // but until Flow fixes its intersection bugs, we've merged them into a
3006
- // single type.
3007
-
3008
- // An Instance is shared between all versions of a component. We can easily
3009
- // break this out into a separate object to avoid copying so much to the
3010
- // alternate versions of the tree. We put this on a single object for now to
3011
- // minimize the number of objects created during the initial render.
3012
-
3013
- // Tag identifying the type of fiber.
3014
- tag: WorkTag;
3015
-
3016
- // Unique identifier of this child.
3017
- key: null | string;
3018
-
3019
- // The value of element.type which is used to preserve the identity during
3020
- // reconciliation of this child.
3021
- elementType: any;
3022
-
3023
- // The resolved function/class/ associated with this fiber.
3024
- type: any;
3025
-
3026
- // The local state associated with this fiber.
3027
- stateNode: any;
3028
-
3029
- // Conceptual aliases
3030
- // parent : Instance -> return The parent happens to be the same as the
3031
- // return fiber since we've merged the fiber and instance.
3032
-
3033
- // Remaining fields belong to Fiber
3034
-
3035
- // The Fiber to return to after finishing processing this one.
3036
- // This is effectively the parent, but there can be multiple parents (two)
3037
- // so this is only the parent of the thing we're currently processing.
3038
- // It is conceptually the same as the return address of a stack frame.
3039
- return: Fiber | null;
3040
-
3041
- // Singly Linked List Tree Structure.
3042
- child: Fiber | null;
3043
- sibling: Fiber | null;
3044
- index: number;
3045
-
3046
- // The ref last used to attach this node.
3047
- // I'll avoid adding an owner field for prod and model that as functions.
3048
- ref:
3049
- | null
3050
- | (((handle: unknown) => void) & {
3051
- _stringRef?: string | null;
3052
- })
3053
- | RefObject;
3054
-
3055
- // Input is the data coming into process this fiber. Arguments. Props.
3056
- pendingProps: any; // This type will be more specific once we overload the tag.
3057
- memoizedProps: any; // The props used to create the output.
3058
-
3059
- // A queue of state updates and callbacks.
3060
- updateQueue: unknown;
3061
-
3062
- // The state used to create the output
3063
- memoizedState: any;
3064
-
3065
- // Dependencies (contexts, events) for this fiber, if it has any
3066
- dependencies: Dependencies | null;
3067
-
3068
- // Bitfield that describes properties about the fiber and its subtree. E.g.
3069
- // the ConcurrentMode flag indicates whether the subtree should be async-by-
3070
- // default. When a fiber is created, it inherits the mode of its
3071
- // parent. Additional flags can be set at creation time, but after that the
3072
- // value should remain unchanged throughout the fiber's lifetime, particularly
3073
- // before its child fibers are created.
3074
- mode: TypeOfMode;
3075
-
3076
- // Effect
3077
- flags: Flags;
3078
- subtreeFlags: Flags;
3079
- deletions: Fiber[] | null;
3080
-
3081
- // Singly linked list fast path to the next fiber with side-effects.
3082
- nextEffect: Fiber | null;
3083
-
3084
- // The first and last fiber with side-effect within this subtree. This allows
3085
- // us to reuse a slice of the linked list when we reuse the work done within
3086
- // this fiber.
3087
- firstEffect: Fiber | null;
3088
- lastEffect: Fiber | null;
3089
-
3090
- lanes: Lanes;
3091
- childLanes: Lanes;
3092
-
3093
- // This is a pooled version of a Fiber. Every fiber that gets updated will
3094
- // eventually have a pair. There are cases when we can clean up pairs to save
3095
- // memory if we need to.
3096
- alternate: Fiber | null;
3097
-
3098
- // Time spent rendering this Fiber and its descendants for the current update.
3099
- // This tells us how well the tree makes use of sCU for memoization.
3100
- // It is reset to 0 each time we render and only updated when we don't bailout.
3101
- // This field is only set when the enableProfilerTimer flag is enabled.
3102
- actualDuration?: number;
3103
-
3104
- // If the Fiber is currently active in the "render" phase,
3105
- // This marks the time at which the work began.
3106
- // This field is only set when the enableProfilerTimer flag is enabled.
3107
- actualStartTime?: number;
3108
-
3109
- // Duration of the most recent render time for this Fiber.
3110
- // This value is not updated when we bailout for memoization purposes.
3111
- // This field is only set when the enableProfilerTimer flag is enabled.
3112
- selfBaseDuration?: number;
3113
-
3114
- // Sum of base times for all descendants of this Fiber.
3115
- // This value bubbles up during the "complete" phase.
3116
- // This field is only set when the enableProfilerTimer flag is enabled.
3117
- treeBaseDuration?: number;
3118
-
3119
- // Conceptual aliases
3120
- // workInProgress : Fiber -> alternate The alternate used for reuse happens
3121
- // to be the same as work in progress.
3122
- // __DEV__ only
3123
- _debugID?: number;
3124
- _debugSource?: Source | null;
3125
- _debugOwner?: Fiber | null;
3126
- _debugIsCurrentlyTiming?: boolean;
3127
- _debugNeedsRemount?: boolean;
3128
-
3129
- // Used to verify that the order of hooks does not change between renders.
3130
- _debugHookTypes?: HookType[] | null;
3131
- }
3132
-
3133
- type FiberRoot = any;
3134
-
3135
- // Concurrent related struct
3136
- type MutableSource = any;
3137
-
3138
- type OpaqueHandle = any;
3139
- type OpaqueRoot = any;
3140
-
3141
- // 0 is PROD, 1 is DEV.
3142
- // Might add PROFILE later.
3143
- type BundleType = 0 | 1;
3144
-
3145
- interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
3146
- bundleType: BundleType;
3147
- version: string;
3148
- rendererPackageName: string;
3149
- // Note: this actually *does* depend on Fiber internal fields.
3150
- // Used by "inspect clicked DOM element" in React DevTools.
3151
- findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
3152
- rendererConfig?: RendererInspectionConfig;
3153
- }
3154
-
3155
- interface SuspenseHydrationCallbacks<SuspenseInstance> {
3156
- onHydrated?: (suspenseInstance: SuspenseInstance) => void;
3157
- onDeleted?: (suspenseInstance: SuspenseInstance) => void;
3158
- }
3159
-
3160
- interface TransitionTracingCallbacks {
3161
- onTransitionStart?: (transitionName: string, startTime: number) => void;
3162
- onTransitionProgress?: (
3163
- transitionName: string,
3164
- startTime: number,
3165
- currentTime: number,
3166
- pending: Array<{ name: null | string }>,
3167
- ) => void;
3168
- onTransitionIncomplete?: (
3169
- transitionName: string,
3170
- startTime: number,
3171
- deletions: Array<{
3172
- type: string;
3173
- name?: string;
3174
- newName?: string;
3175
- endTime: number;
3176
- }>,
3177
- ) => void;
3178
- onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
3179
- onMarkerProgress?: (
3180
- transitionName: string,
3181
- marker: string,
3182
- startTime: number,
3183
- currentTime: number,
3184
- pending: Array<{ name: null | string }>,
3185
- ) => void;
3186
- onMarkerIncomplete?: (
3187
- transitionName: string,
3188
- marker: string,
3189
- startTime: number,
3190
- deletions: Array<{
3191
- type: string;
3192
- name?: string;
3193
- newName?: string;
3194
- endTime: number;
3195
- }>,
3196
- ) => void;
3197
- onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
3198
- }
3199
-
3200
- interface ComponentSelector {
3201
- $$typeof: symbol | number;
3202
- value: React$AbstractComponent<never, unknown>;
3203
- }
3204
-
3205
- interface HasPseudoClassSelector {
3206
- $$typeof: symbol | number;
3207
- value: Selector[];
3208
- }
3209
-
3210
- interface RoleSelector {
3211
- $$typeof: symbol | number;
3212
- value: string;
3213
- }
3214
-
3215
- interface TextSelector {
3216
- $$typeof: symbol | number;
3217
- value: string;
3218
- }
3219
-
3220
- interface TestNameSelector {
3221
- $$typeof: symbol | number;
3222
- value: string;
3223
- }
3224
-
3225
- type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
3226
-
3227
- // TODO can not find React$AbstractComponent def
3228
- type React$AbstractComponent<Config, Instance = any> = any;
3229
-
3230
- interface BoundingRect {
3231
- x: number;
3232
- y: number;
3233
- width: number;
3234
- height: number;
3235
- }
3236
-
3237
- type IntersectionObserverOptions = any;
3238
-
3239
- interface BaseErrorInfo {
3240
- componentStack?: string;
3241
- }
3242
-
3243
- interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
3244
- createContainer(
3245
- containerInfo: Container,
3246
- tag: RootTag,
3247
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3248
- isStrictMode: boolean,
3249
- concurrentUpdatesByDefaultOverride: null | boolean,
3250
- identifierPrefix: string,
3251
- onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
3252
- onCaughtError: (error: Error, info: BaseErrorInfo) => void,
3253
- onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
3254
- onDefaultTransitionIndicator: () => void,
3255
- transitionCallbacks: null | TransitionTracingCallbacks,
3256
- ): OpaqueRoot;
3257
-
3258
- createPortal(
3259
- children: ReactNode,
3260
- containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
3261
- implementation: any,
3262
- key?: string | null,
3263
- ): ReactPortal;
3264
-
3265
- registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
3266
-
3267
- createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
3268
-
3269
- createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
3270
-
3271
- createRoleSelector(role: string): RoleSelector;
3272
-
3273
- createTextSelector(text: string): TextSelector;
3274
-
3275
- createTestNameSelector(id: string): TestNameSelector;
3276
-
3277
- getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
3278
-
3279
- findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
3280
-
3281
- findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
3282
-
3283
- focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
3284
-
3285
- observeVisibleRects(
3286
- hostRoot: Instance,
3287
- selectors: Selector[],
3288
- callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
3289
- options?: IntersectionObserverOptions,
3290
- ): { disconnect: () => void };
3291
-
3292
- createHydrationContainer(
3293
- initialChildren: ReactNode,
3294
- callback: (() => void) | null | undefined,
3295
- containerInfo: Container,
3296
- tag: RootTag,
3297
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3298
- isStrictMode: boolean,
3299
- concurrentUpdatesByDefaultOverride: null | boolean,
3300
- identifierPrefix: string,
3301
- onRecoverableError: (error: Error) => void,
3302
- transitionCallbacks: null | TransitionTracingCallbacks,
3303
- ): OpaqueRoot;
3304
-
3305
- updateContainer(
3306
- element: ReactNode,
3307
- container: OpaqueRoot,
3308
- parentComponent?: Component<any, any> | null,
3309
- callback?: (() => void) | null,
3310
- ): Lane;
3311
-
3312
- batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
3313
-
3314
- deferredUpdates<A>(fn: () => A): A;
3315
-
3316
- 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;
3317
-
3318
- flushControlled(fn: () => any): void;
3319
-
3320
- flushSync(): void;
3321
- flushSync<R>(fn: () => R): R;
3322
-
3323
- isAlreadyRendering(): boolean;
3324
-
3325
- flushPassiveEffects(): boolean;
3326
-
3327
- getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
3328
-
3329
- attemptSynchronousHydration(fiber: Fiber): void;
3330
-
3331
- attemptDiscreteHydration(fiber: Fiber): void;
3332
-
3333
- attemptContinuousHydration(fiber: Fiber): void;
3334
-
3335
- attemptHydrationAtCurrentPriority(fiber: Fiber): void;
3336
-
3337
- getCurrentUpdatePriority(): LanePriority;
3338
-
3339
- runWithPriority<T>(priority: LanePriority, fn: () => T): T;
3340
-
3341
- findHostInstance(component: any): PublicInstance | null;
3342
-
3343
- findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
3344
-
3345
- findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
3346
-
3347
- shouldError(fiber: Fiber): boolean | undefined;
3348
-
3349
- shouldSuspend(fiber: Fiber): boolean;
3350
-
3351
- injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
3352
- }
3353
- }
3354
-
3355
- declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3356
- declare function extend<T extends Catalogue>(objects: T): void;
3357
- declare function extend(objects: Record<string, unknown>): void;
3358
- declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3359
-
3360
- declare const isRenderer: (def: any) => boolean;
3361
- interface OffscreenCanvas extends EventTarget {
3362
- }
3363
- declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3364
- declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3365
- declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3366
- declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3367
- interface PortalProps {
3368
- children: ReactNode;
3369
- state?: InjectState;
3370
- container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3371
- }
3372
- declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3373
- /**
3374
- * Force React to flush any updates inside the provided callback synchronously and immediately.
3375
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
3376
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
3377
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
3378
- */
3379
- declare function flushSync<R>(fn: () => R): R;
3380
-
3381
- declare const context: React$1.Context<RootStore>;
3382
- declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3383
-
3384
- /**
3385
- * An SSR-friendly useLayoutEffect.
3386
- *
3387
- * React currently throws a warning when using useLayoutEffect on the server.
3388
- * To get around it, we can conditionally useEffect on the server (no-op) and
3389
- * useLayoutEffect elsewhere.
3390
- *
3391
- * @see https://github.com/facebook/react/issues/14927
3392
- */
3393
- declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
3394
- /**
3395
- * Creates a stable ref that always contains the latest callback.
3396
- * Useful for avoiding dependency arrays while ensuring the latest closure is called.
3397
- *
3398
- * @param fn - The callback function to wrap
3399
- * @returns A ref containing the current callback
3400
- */
3401
- declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
3402
- /**
3403
- * Bridges renderer Context and StrictMode from a primary renderer.
3404
- * Used to maintain React context when rendering into portals or secondary canvases.
3405
- *
3406
- * @returns A Bridge component that wraps children with the parent renderer's context
3407
- */
3408
- declare function useBridge(): Bridge;
3409
- /**
3410
- * Internal component that blocks rendering until a promise resolves.
3411
- * Used for suspense-like blocking behavior.
3412
- *
3413
- * @param set - Function to set the blocking promise
3414
- */
3415
- declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
3416
- /**
3417
- * Error boundary component for catching and handling errors in the React tree.
3418
- * Forwards errors to a state setter for external handling.
3419
- *
3420
- * NOTE: static members get down-level transpiled to mutations which break tree-shaking
3421
- */
3422
- declare const ErrorBoundary: {
3423
- new (props: {
3424
- set: React$1.Dispatch<Error | undefined>;
3425
- children: React$1.ReactNode;
3426
- }): {
3427
- state: {
3428
- error: boolean;
3429
- };
3430
- componentDidCatch(err: Error): void;
3431
- render(): React$1.ReactNode;
3432
- context: unknown;
3433
- setState<K extends "error">(state: {
3434
- error: boolean;
3435
- } | ((prevState: Readonly<{
3436
- error: boolean;
3437
- }>, props: Readonly<{
3438
- set: React$1.Dispatch<Error | undefined>;
3439
- children: React$1.ReactNode;
3440
- }>) => {
3441
- error: boolean;
3442
- } | Pick<{
3443
- error: boolean;
3444
- }, K> | null) | Pick<{
3445
- error: boolean;
3446
- }, K> | null, callback?: (() => void) | undefined): void;
3447
- forceUpdate(callback?: (() => void) | undefined): void;
3448
- readonly props: Readonly<{
3449
- set: React$1.Dispatch<Error | undefined>;
3450
- children: React$1.ReactNode;
3451
- }>;
3452
- componentDidMount?(): void;
3453
- shouldComponentUpdate?(nextProps: Readonly<{
3454
- set: React$1.Dispatch<Error | undefined>;
3455
- children: React$1.ReactNode;
3456
- }>, nextState: Readonly<{
3457
- error: boolean;
3458
- }>, nextContext: any): boolean;
3459
- componentWillUnmount?(): void;
3460
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3461
- set: React$1.Dispatch<Error | undefined>;
3462
- children: React$1.ReactNode;
3463
- }>, prevState: Readonly<{
3464
- error: boolean;
3465
- }>): any;
3466
- componentDidUpdate?(prevProps: Readonly<{
3467
- set: React$1.Dispatch<Error | undefined>;
3468
- children: React$1.ReactNode;
3469
- }>, prevState: Readonly<{
3470
- error: boolean;
3471
- }>, snapshot?: any): void;
3472
- componentWillMount?(): void;
3473
- UNSAFE_componentWillMount?(): void;
3474
- componentWillReceiveProps?(nextProps: Readonly<{
3475
- set: React$1.Dispatch<Error | undefined>;
3476
- children: React$1.ReactNode;
3477
- }>, nextContext: any): void;
3478
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3479
- set: React$1.Dispatch<Error | undefined>;
3480
- children: React$1.ReactNode;
3481
- }>, nextContext: any): void;
3482
- componentWillUpdate?(nextProps: Readonly<{
3483
- set: React$1.Dispatch<Error | undefined>;
3484
- children: React$1.ReactNode;
3485
- }>, nextState: Readonly<{
3486
- error: boolean;
3487
- }>, nextContext: any): void;
3488
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3489
- set: React$1.Dispatch<Error | undefined>;
3490
- children: React$1.ReactNode;
3491
- }>, nextState: Readonly<{
3492
- error: boolean;
3493
- }>, nextContext: any): void;
3494
- };
3495
- new (props: {
3496
- set: React$1.Dispatch<Error | undefined>;
3497
- children: React$1.ReactNode;
3498
- }, context: any): {
3499
- state: {
3500
- error: boolean;
3501
- };
3502
- componentDidCatch(err: Error): void;
3503
- render(): React$1.ReactNode;
3504
- context: unknown;
3505
- setState<K extends "error">(state: {
3506
- error: boolean;
3507
- } | ((prevState: Readonly<{
3508
- error: boolean;
3509
- }>, props: Readonly<{
3510
- set: React$1.Dispatch<Error | undefined>;
3511
- children: React$1.ReactNode;
3512
- }>) => {
3513
- error: boolean;
3514
- } | Pick<{
3515
- error: boolean;
3516
- }, K> | null) | Pick<{
3517
- error: boolean;
3518
- }, K> | null, callback?: (() => void) | undefined): void;
3519
- forceUpdate(callback?: (() => void) | undefined): void;
3520
- readonly props: Readonly<{
3521
- set: React$1.Dispatch<Error | undefined>;
3522
- children: React$1.ReactNode;
3523
- }>;
3524
- componentDidMount?(): void;
3525
- shouldComponentUpdate?(nextProps: Readonly<{
3526
- set: React$1.Dispatch<Error | undefined>;
3527
- children: React$1.ReactNode;
3528
- }>, nextState: Readonly<{
3529
- error: boolean;
3530
- }>, nextContext: any): boolean;
3531
- componentWillUnmount?(): void;
3532
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3533
- set: React$1.Dispatch<Error | undefined>;
3534
- children: React$1.ReactNode;
3535
- }>, prevState: Readonly<{
3536
- error: boolean;
3537
- }>): any;
3538
- componentDidUpdate?(prevProps: Readonly<{
3539
- set: React$1.Dispatch<Error | undefined>;
3540
- children: React$1.ReactNode;
3541
- }>, prevState: Readonly<{
3542
- error: boolean;
3543
- }>, snapshot?: any): void;
3544
- componentWillMount?(): void;
3545
- UNSAFE_componentWillMount?(): void;
3546
- componentWillReceiveProps?(nextProps: Readonly<{
3547
- set: React$1.Dispatch<Error | undefined>;
3548
- children: React$1.ReactNode;
3549
- }>, nextContext: any): void;
3550
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3551
- set: React$1.Dispatch<Error | undefined>;
3552
- children: React$1.ReactNode;
3553
- }>, nextContext: any): void;
3554
- componentWillUpdate?(nextProps: Readonly<{
3555
- set: React$1.Dispatch<Error | undefined>;
3556
- children: React$1.ReactNode;
3557
- }>, nextState: Readonly<{
3558
- error: boolean;
3559
- }>, nextContext: any): void;
3560
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3561
- set: React$1.Dispatch<Error | undefined>;
3562
- children: React$1.ReactNode;
3563
- }>, nextState: Readonly<{
3564
- error: boolean;
3565
- }>, nextContext: any): void;
3566
- };
3567
- getDerivedStateFromError: () => {
3568
- error: boolean;
3569
- };
3570
- contextType?: React$1.Context<any> | undefined;
3571
- propTypes?: any;
3572
- };
3573
-
3574
- /**
3575
- * React internal props that should not be passed to Three.js objects.
3576
- */
3577
- declare const REACT_INTERNAL_PROPS: string[];
3578
- /**
3579
- * Returns the instance's initial (outermost) root.
3580
- * Traverses through previousRoot links to find the original root store.
3581
- *
3582
- * @param instance - R3F instance to find root for
3583
- * @returns The outermost root store
3584
- */
3585
- declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
3586
- /**
3587
- * Returns instance root state.
3588
- * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
3589
- * traverses ancestors to find the nearest managed parent.
3590
- *
3591
- * @param obj - Three.js object to get root state for
3592
- * @returns Root state if found, undefined otherwise
3593
- */
3594
- declare function getRootState<T extends Object3D = Object3D>(obj: T): RootState | undefined;
3595
- /**
3596
- * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
3597
- * Handles duplicate material names by appending UUID prefixes.
3598
- *
3599
- * @param object - Root object to traverse
3600
- * @returns ObjectMap containing named nodes, materials, and meshes
3601
- *
3602
- * @example
3603
- * const { nodes, materials, meshes } = buildGraph(gltf.scene)
3604
- * // Access by name: nodes.Head, materials.Metal, meshes.Body
3605
- */
3606
- declare function buildGraph(object: Object3D): ObjectMap;
3607
- /**
3608
- * Disposes an object and all its disposable properties.
3609
- * Skips Scene objects as they should not be disposed automatically.
3610
- *
3611
- * @param obj - Object to dispose
3612
- */
3613
- declare function dispose<T extends Disposable>(obj: T): void;
3614
- /**
3615
- * Extracts instance props from React reconciler fiber props.
3616
- * Filters out React-internal props (children, key, ref).
3617
- *
3618
- * @param queue - Pending props from reconciler fiber
3619
- * @returns Props object without React-internal keys
3620
- */
3621
- declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
3622
- /**
3623
- * Creates or retrieves an R3F instance descriptor for a Three.js object.
3624
- * Each object in the scene carries a LocalState descriptor (__r3f).
3625
- *
3626
- * @param target - Target object to prepare
3627
- * @param root - Root store for this instance
3628
- * @param type - String identifier for the object type
3629
- * @param props - Initial props for the instance
3630
- * @returns Instance descriptor
3631
- */
3632
- declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3633
- /**
3634
- * Triggers an update for an instance.
3635
- * Calls onUpdate callback and invalidates the frame if necessary.
3636
- *
3637
- * @param instance - Instance to invalidate
3638
- */
3639
- declare function invalidateInstance(instance: Instance): void;
3640
-
3641
- /**
3642
- * Reserved prop names that should not be applied to Three.js objects.
3643
- */
3644
- declare const RESERVED_PROPS: string[];
3645
- /**
3646
- * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
3647
- * First tries the entire key as a single property, then attempts piercing.
3648
- *
3649
- * @param root - Root object to resolve from
3650
- * @param key - Property key (may contain dashes for piercing)
3651
- * @returns Object containing root, key, and target value
3652
- *
3653
- * @example
3654
- * resolve(mesh, 'material-color')
3655
- * // => { root: mesh.material, key: 'color', target: mesh.material.color }
3656
- */
3657
- declare function resolve(root: any, key: string): {
3658
- root: any;
3659
- key: string;
3660
- target: any;
3661
- };
3662
- /**
3663
- * Attaches a child instance to a parent instance.
3664
- * Handles both string-based attachment (e.g., 'geometry', 'material-map')
3665
- * and function-based attachment for custom logic.
3666
- *
3667
- * @param parent - Parent instance
3668
- * @param child - Child instance to attach
3669
- *
3670
- * @example
3671
- * // String attachment
3672
- * <bufferGeometry attach="geometry" />
3673
- * // Array attachment
3674
- * <light attach="lights-0" />
3675
- * // Function attachment
3676
- * <thing attach={(parent, self) => { parent.customProp = self }} />
3677
- */
3678
- declare function attach(parent: Instance, child: Instance): void;
3679
- /**
3680
- * Detaches a child instance from a parent instance.
3681
- * Restores the previous value or deletes the property if it was never set.
3682
- *
3683
- * @param parent - Parent instance
3684
- * @param child - Child instance to detach
3685
- */
3686
- declare function detach(parent: Instance, child: Instance): void;
3687
- /**
3688
- * Compares old and new props to determine which properties have changed.
3689
- * Also handles resetting removed props for HMR/fast-refresh.
3690
- *
3691
- * @param instance - Instance to diff props for
3692
- * @param newProps - New props to compare against
3693
- * @returns Object containing only changed props
3694
- *
3695
- * @example
3696
- * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
3697
- * // => { position: [1, 2, 3] } (only if position changed)
3698
- */
3699
- declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
3700
- /**
3701
- * Applies a set of props to a Three.js object.
3702
- * Handles special cases like colors, vectors, textures, events, and pierced props.
3703
- *
3704
- * @param object - Three.js object to apply props to
3705
- * @param props - Props to apply
3706
- * @returns The object with props applied
3707
- *
3708
- * @example
3709
- * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
3710
- */
3711
- declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
3712
-
3713
- /**
3714
- * Calculates the device pixel ratio for rendering.
3715
- * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
3716
- *
3717
- * @param dpr - Target DPR value or [min, max] range
3718
- * @returns Calculated DPR value
3719
- *
3720
- * @example
3721
- * calculateDpr(2) // => 2
3722
- * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
3723
- */
3724
- declare function calculateDpr(dpr: Dpr): number;
3725
- /**
3726
- * Extracts the first segment of a UUID string (before the first hyphen).
3727
- * Used for creating unique material names when duplicates exist.
3728
- *
3729
- * @param uuid - UUID string to extract prefix from
3730
- * @returns First segment of the UUID
3731
- *
3732
- * @example
3733
- * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
3734
- */
3735
- declare function getUuidPrefix(uuid: string): string;
3736
- /**
3737
- * Updates camera projection based on viewport size.
3738
- * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
3739
- * Respects camera.manual flag - manual cameras are not modified.
3740
- *
3741
- * @param camera - Camera to update
3742
- * @param size - Current viewport size
3743
- */
3744
- declare function updateCamera(camera: ThreeCamera, size: Size): void;
3745
- /**
3746
- * Updates a frustum from a camera's projection and world matrices.
3747
- * If no target frustum is provided, creates and returns a new one.
3748
- *
3749
- * @param camera - Camera to extract frustum from
3750
- * @param frustum - Optional existing frustum to update (creates new if not provided)
3751
- * @returns The updated or newly created frustum
3752
- *
3753
- * @example
3754
- * // Create new frustum
3755
- * const frustum = updateFrustum(camera)
3756
- *
3757
- * // Update existing frustum (no allocation)
3758
- * updateFrustum(camera, existingFrustum)
3759
- *
3760
- * // Use for visibility checks
3761
- * if (frustum.containsPoint(point)) { ... }
3762
- * if (frustum.intersectsObject(mesh)) { ... }
3763
- */
3764
- declare function updateFrustum(camera: ThreeCamera, frustum?: Frustum): Frustum;
3765
-
3766
- declare const is: {
3767
- obj: (a: any) => boolean;
3768
- fun: (a: any) => a is Function;
3769
- str: (a: any) => a is string;
3770
- num: (a: any) => a is number;
3771
- boo: (a: any) => a is boolean;
3772
- und: (a: any) => boolean;
3773
- nul: (a: any) => boolean;
3774
- arr: (a: any) => a is any[];
3775
- equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
3776
- };
3777
- declare const isOrthographicCamera: (def: ThreeCamera) => def is OrthographicCamera;
3778
- declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
3779
- declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation;
3780
- declare const isObject3D: (object: any) => object is Object3D;
3781
- declare const isTexture: (value: unknown) => value is Texture$1;
3782
- type VectorLike = {
3783
- set: (...args: any[]) => void;
3784
- constructor?: Function;
3785
- };
3786
- declare const isVectorLike: (object: unknown) => object is VectorLike;
3787
- type Copyable = {
3788
- copy: (...args: any[]) => void;
3789
- constructor?: Function;
3790
- };
3791
- declare const isCopyable: (object: unknown) => object is Copyable;
3792
- declare const hasConstructor: (object: unknown) => object is {
3793
- constructor?: Function;
3794
- };
3795
-
3796
- /**
3797
- * Symbol marker for deferred ref resolution.
3798
- * Used to identify values that should be resolved from refs after mount.
3799
- */
3800
- declare const FROM_REF: unique symbol;
3801
- /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3802
- interface FromRefMarker<T = unknown, R = T> {
3803
- [FROM_REF]: React$1.RefObject<T | null>;
3804
- /** Optional transform applied to the resolved ref before assignment. */
3805
- transform?: (value: T) => R;
3806
- }
3807
- /**
3808
- * Defers prop application until the referenced object is available.
3809
- * Useful for props like `target` that need sibling refs to be populated.
3810
- *
3811
- * Only top-level props on a three element are resolved: a marker nested inside another value
3812
- * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3813
- * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3814
- * what gets assigned.
3815
- *
3816
- * @param ref - React ref object to resolve at mount time
3817
- * @param transform - Optional mapping from the resolved object to the value the prop expects
3818
- * @returns A marker value that the reconciler resolves after mount
3819
- *
3820
- * @example
3821
- * const targetRef = useRef<THREE.Object3D>(null)
3822
- *
3823
- * <group ref={targetRef} position={[-3, -2, -15]} />
3824
- * <spotLight target={fromRef(targetRef)} intensity={100} />
3825
- *
3826
- * @example
3827
- * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3828
- * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3829
- */
3830
- declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3831
- declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3832
- /**
3833
- * Type guard to check if a value is a fromRef marker.
3834
- *
3835
- * @param value - Value to check
3836
- * @returns True if value is a fromRef marker
3837
- */
3838
- declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3839
-
3840
- /**
3841
- * Symbol marker for mount-only method calls.
3842
- * Used to identify methods that should only be called once on initial mount.
3843
- */
3844
- declare const ONCE: unique symbol;
3845
- /**
3846
- * Marks a method call to be executed only on initial mount.
3847
- * Useful for geometry transforms that should not be reapplied on every render.
3848
- *
3849
- * When `args` prop changes (triggering reconstruction), the method will be
3850
- * called again on the new instance since appliedOnce is not carried over.
3851
- *
3852
- * @param args - Arguments to pass to the method
3853
- * @returns A marker value that applyProps will execute once
3854
- *
3855
- * @example
3856
- * // Rotate geometry on mount
3857
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
3858
- *
3859
- * // Multiple arguments
3860
- * <bufferGeometry applyMatrix4={once(matrix)} />
3861
- *
3862
- * // No arguments
3863
- * <geometry center={once()} />
3864
- */
3865
- declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3866
- /**
3867
- * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3868
- * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3869
- * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3870
- *
3871
- * The runtime value is always the marker object; only the declared type follows the prop.
3872
- */
3873
- type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3874
- /**
3875
- * Type guard to check if a value is a once marker.
3876
- *
3877
- * @param value - Value to check
3878
- * @returns True if value is a once marker
3879
- */
3880
- declare function isOnce(value: unknown): value is {
3881
- [ONCE]: any[] | true;
3882
- };
3883
-
3884
- /**
3885
- * A DOM canvas which accepts threejs elements as children.
3886
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3887
- */
3888
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3889
127
 
3890
- 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 };
3891
- 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 };