@react-three/fiber 10.0.0-canary.979dc2d → 10.0.0-canary.98da52a

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