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

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