@react-three/fiber 10.0.0-canary.eb6c14f → 10.0.0-canary.ee5a08a

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