@react-three/fiber 10.0.0-canary.de17310 → 10.0.0-canary.de8b03c

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