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

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