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

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