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