@react-three/fiber 10.0.0-canary.dbbe704 → 10.0.0-canary.dd5379c

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