@react-three/fiber 10.0.0-canary.f49e56e → 10.0.0-canary.f81281f

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