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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1601 +1,13 @@
1
- import * as React$1 from 'react';
2
- import { ReactNode } from 'react';
3
- import * as THREE$1 from 'three';
4
- import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Euler as Euler$2, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
5
- import * as three_webgpu from 'three/webgpu';
6
- import { WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, CubeRenderTarget, RenderTarget, Euler as Euler$1, Color as Color$1, ColorRepresentation, 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 } from 'three/webgpu';
7
- import { StoreApi } from 'zustand';
8
- import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
9
- import { FrameCallback as FrameCallback$1, FrameTimingState, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
1
+ import { z as FrameNextCallback } from './shared/fiber.Bw8YnGg5.cjs';
2
+ 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, G as FrameCallback, 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, O as Overwrite, c as Performance, l as PointerCaptureTarget, P as PointerState, n as Properties, a4 as R3FRenderer, b as RenderCallback, R as RootExtension, a6 as RootState, d as RootStore, t as SetBlock, a as Size, S as Subscription, q as ThreeCamera, T as ThreeEvent, U as UnblockProps, V as Viewport, m as VisibilityEntry, 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.cjs';
3
+ import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
10
4
  export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, SchedulerApi, UseFrameNextOptions, UseFrameOptions } from '@pmndrs/scheduler';
11
- import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
12
- import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
13
- import { Inspector } from 'three/addons/inspector/Inspector.js';
14
- import { Options } from 'react-use-measure';
15
-
16
- function _mergeNamespaces(n, m) {
17
- m.forEach(function (e) {
18
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
19
- if (k !== 'default' && !(k in n)) {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- });
28
- return Object.freeze(n);
29
- }
30
-
31
- //* Utility Types ==============================
32
-
33
- type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
34
- type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
35
- type Properties<T> = Pick<T, NonFunctionKeys<T>>
36
- type Mutable<P> = { -readonly [K in keyof P]: P[K] }
37
- type IsOptional<T> = undefined extends T ? true : false
38
- type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
39
- ? IsOptional<First> extends true
40
- ? IsAllOptional<Rest>
41
- : false
42
- : true
43
-
44
- //* Camera Types ==============================
45
-
46
- type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
47
-
48
- //* Act Type ==============================
49
-
50
- type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
51
-
52
- //* Bridge & Block Types ==============================
53
-
54
- type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
55
-
56
- type SetBlock = false | Promise<null> | null
57
- type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
58
-
59
- //* Object Map Type ==============================
60
-
61
- /* Original version
62
- export interface ObjectMap {
63
- nodes: { [name: string]: THREE.Object3D }
64
- materials: { [name: string]: THREE.Material }
65
- meshes: { [name: string]: THREE.Mesh }
66
- }
67
- */
68
- /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
69
- It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
70
- I will keep the use here)
71
- https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
72
- His description is:
73
- The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
74
- */
75
- interface ObjectMap<
76
- T extends { nodes?: string; materials?: string; meshes?: string } = {
77
- nodes: string
78
- materials: string
79
- meshes: string
80
- },
81
- > {
82
- nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
83
- materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
84
- meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
85
- }
86
-
87
- //* Equality Config ==============================
88
-
89
- interface EquConfig {
90
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
91
- arrays?: 'reference' | 'shallow'
92
- /** Compare objects by reference equality a === b (default), or by shallow equality */
93
- objects?: 'reference' | 'shallow'
94
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
95
- strict?: boolean
96
- }
97
-
98
- //* Disposable Type ==============================
99
-
100
- interface Disposable {
101
- type?: string
102
- dispose?: () => void
103
- }
104
-
105
- //* Event-related Types =====================================
106
-
107
- interface Intersection extends THREE$1.Intersection {
108
- /** The event source (the object which registered the handler) */
109
- eventObject: THREE$1.Object3D
110
- }
111
-
112
- type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
113
-
114
- interface IntersectionEvent<TSourceEvent> extends Intersection {
115
- /** The event source (the object which registered the handler) */
116
- eventObject: THREE$1.Object3D
117
- /** An array of intersections */
118
- intersections: Intersection[]
119
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
120
- unprojectedPoint: THREE$1.Vector3
121
- /** Normalized event coordinates */
122
- pointer: THREE$1.Vector2
123
- /** pointerId of the original event for multiple pointer events */
124
- pointerId: number
125
- /** Delta between first click and this event */
126
- delta: number
127
- /** The ray that pierced it */
128
- ray: THREE$1.Ray
129
- /** The camera that was used by the raycaster */
130
- camera: Camera
131
- /** stopPropagation will stop underlying handlers from firing */
132
- stopPropagation: () => void
133
- /** The original host event */
134
- nativeEvent: TSourceEvent
135
- /** If the event was stopped by calling stopPropagation */
136
- stopped: boolean
137
- }
138
-
139
- type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
140
- type DomEvent = PointerEvent | MouseEvent | WheelEvent
141
-
142
- /** DOM event handlers registered on the canvas element */
143
- interface Events {
144
- onClick: EventListener
145
- onContextMenu: EventListener
146
- onDoubleClick: EventListener
147
- onWheel: EventListener
148
- onPointerDown: EventListener
149
- onPointerUp: EventListener
150
- onPointerLeave: EventListener
151
- onPointerMove: EventListener
152
- onPointerCancel: EventListener
153
- onLostPointerCapture: EventListener
154
- onDragEnter: EventListener
155
- onDragLeave: EventListener
156
- onDragOver: EventListener
157
- onDrop: EventListener
158
- }
159
-
160
- /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
161
- interface EventHandlers {
162
- onClick?: (event: ThreeEvent<MouseEvent>) => void
163
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
164
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
165
- /** Fires continuously while dragging over the object */
166
- onDragOver?: (event: ThreeEvent<DragEvent>) => void
167
- /** Fires once when drag enters the object */
168
- onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
169
- /** Fires once when drag leaves the object */
170
- onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
171
- /** Fires when drag misses this object (for objects that have drag handlers) */
172
- onDragOverMissed?: (event: DragEvent) => void
173
- /** Fires when a drop occurs on this object */
174
- onDrop?: (event: ThreeEvent<DragEvent>) => void
175
- /** Fires when a drop misses this object (for objects that have drop handlers) */
176
- onDropMissed?: (event: DragEvent) => void
177
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
178
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
179
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
180
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
181
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
182
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
183
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
184
- onPointerMissed?: (event: MouseEvent) => void
185
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
186
- onWheel?: (event: ThreeEvent<WheelEvent>) => void
187
- onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
188
-
189
- //* Visibility Events --------------------------------
190
- /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
191
- onFramed?: (inView: boolean) => void
192
- /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
193
- onOccluded?: (occluded: boolean) => void
194
- /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
195
- onVisible?: (visible: boolean) => void
196
- }
197
-
198
- type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
199
- type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
200
-
201
- /** Configuration for XR pointer registration (controllers/hands) */
202
- interface XRPointerConfig {
203
- /** Ray origin (updated each frame by XR system) */
204
- ray: THREE$1.Ray
205
- /** Optional: custom compute function for this pointer */
206
- compute?: (state: RootState) => void
207
- /** Pointer type identifier */
208
- type: 'controller' | 'hand' | 'gaze'
209
- /** Which hand (for controller/hand types) */
210
- handedness?: 'left' | 'right'
211
- }
212
-
213
- interface EventManager<TTarget> {
214
- /** Determines if the event layer is active */
215
- enabled: boolean
216
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
217
- priority: number
218
- /** The compute function needs to set up the raycaster and an xy- pointer */
219
- compute?: ComputeFunction
220
- /** The filter can re-order or re-structure the intersections */
221
- filter?: FilterFunction
222
- /** The target node the event layer is tied to */
223
- connected?: TTarget
224
- /** All the pointer event handlers through which the host forwards native events */
225
- handlers?: Events
226
- /** Allows re-connecting to another target */
227
- connect?: (target: TTarget) => void
228
- /** Removes all existing events handlers from the target */
229
- disconnect?: () => void
230
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
231
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
232
- * @param pointerId - Optional pointer ID to update specific pointer only
233
- */
234
- update?: (pointerId?: number) => void
235
- /** Defer pointer move raycasting to frame start (default: true) */
236
- frameTimedRaycasts?: boolean
237
- /** Always fire raycaster immediately on scroll events (default: true) */
238
- alwaysFireOnScroll?: boolean
239
- /** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
240
- updateOnFrame?: boolean
241
- /** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
242
- flush?: () => void
243
- /** Register an XR pointer (controller/hand). Returns assigned pointerId */
244
- registerPointer?: (config: XRPointerConfig) => number
245
- /** Unregister an XR pointer */
246
- unregisterPointer?: (pointerId: number) => void
247
- }
248
-
249
- interface PointerCaptureTarget {
250
- intersection: Intersection
251
- target: Element
252
- }
253
-
254
- //* Visibility System Types =====================================
255
-
256
- /** Entry in the visibility registry for tracking object visibility state */
257
- interface VisibilityEntry {
258
- object: THREE$1.Object3D
259
- handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
260
- lastFramedState: boolean | null
261
- lastOccludedState: boolean | null
262
- lastVisibleState: boolean | null
263
- }
264
-
265
- //* Scheduler Types (useFrame) ==============================
266
- //
267
- // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
268
- // This file re-exports them and layers r3f's RootState-aware frame state on top,
269
- // so existing `#types` imports across the codebase keep resolving unchanged.
270
-
271
-
272
-
273
- // Frame State (r3f-specific) --------------------------------
274
-
275
- /**
276
- * State passed to useFrame callbacks (extends RootState with timing).
277
- */
278
- interface FrameNextState extends RootState, FrameTimingState {}
279
-
280
- /** Alias for FrameNextState */
281
- type FrameState = FrameNextState
282
-
283
- // Callback Types (r3f-specific) --------------------------------
284
-
285
- /**
286
- * Callback function for useFrame. Receives the full r3f RootState plus timing.
287
- */
288
- type FrameNextCallback = FrameCallback$1<RootState>
289
-
290
- /** Alias for FrameNextCallback */
291
- type FrameCallback = FrameNextCallback
292
-
293
- //* Buffer Types (useBuffers) ========================================
294
-
295
- /**
296
- * Buffer-like types for GPU compute and storage operations.
297
- * Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
298
- *
299
- * @example
300
- * ```tsx
301
- * const { positions, velocities } = useBuffers(() => ({
302
- * positions: instancedArray(count, 'vec3'), // StorageBufferNode
303
- * velocities: new Float32Array(count * 3), // TypedArray
304
- * }), 'particles')
305
- * ```
306
- */
307
- type BufferLike =
308
- | Float32Array
309
- | Uint32Array
310
- | Int32Array
311
- | Float64Array
312
- | Uint8Array
313
- | Int8Array
314
- | Uint16Array
315
- | Int16Array
316
- | THREE$1.BufferAttribute // Base class for all buffer attributes
317
- | THREE$1.InterleavedBufferAttribute
318
- | Node // TSL buffer nodes (instancedArray, storage)
319
-
320
- /** Flat record of buffer-like values (no nested scopes) */
321
- type BufferRecord = Record<string, BufferLike>
322
-
323
- /**
324
- * Buffer store that can contain both root-level buffers and scoped buffer objects.
325
- * Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
326
- */
327
- type BufferStore = Record<string, BufferLike | BufferRecord>
328
-
329
- //* Node Types (useNodes) ========================================
330
-
331
- /**
332
- * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
333
- * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
334
- * code passes through. Creators are constrained to this same type, so the shape a creator returns
335
- * and the shape the store holds are one type by construction.
336
- */
337
- type NodeLike = TSLNodeType | LegacyTSLNodeLike
338
-
339
- /** Flat record of TSL nodes (no nested scopes) */
340
- type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
341
-
342
- /**
343
- * Node store that can contain both root-level nodes and scoped node objects.
344
- * Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
345
- */
346
- type NodeStore = Record<string, NodeLike | NodeRecord>
347
-
348
- //* Storage Types (useGPUStorage) ========================================
349
-
350
- /**
351
- * GPU storage types for texture-based storage operations.
352
- * Includes Three.js storage textures and TSL storage texture nodes.
353
- *
354
- * @example
355
- * ```tsx
356
- * const { heightMap } = useGPUStorage(() => ({
357
- * heightMap: new StorageTexture(512, 512),
358
- * }), 'terrain')
359
- * ```
360
- */
361
- type StorageLike =
362
- | StorageTexture // 2D GPU storage texture
363
- | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
364
- | StorageArrayTexture // 2D-array GPU storage texture
365
- | Data3DTexture // 3D texture (can be used as storage)
366
- | Node // TSL storage texture nodes (storageTexture)
367
-
368
- /** Flat record of storage-like values (no nested scopes) */
369
- type StorageRecord = Record<string, StorageLike>
370
-
371
- /**
372
- * Storage store that can contain both root-level storage and scoped storage objects.
373
- * Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
374
- */
375
- type StorageStore = Record<string, StorageLike | StorageRecord>
376
-
377
- //* Renderer Types ========================================
378
-
379
- /** Default renderer type - union of WebGL and WebGPU renderers */
380
- type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
381
-
382
- //* Core Store Types ========================================
383
-
384
- type Subscription = {
385
- ref: React$1.RefObject<RenderCallback>
386
- priority: number
387
- store: RootStore
388
- }
389
-
390
- /** Per-pointer state for multi-touch and XR support */
391
- type PointerState = {
392
- /** Objects currently hovered by this pointer */
393
- hovered: Map<string, ThreeEvent<DomEvent>>
394
- /** Objects capturing this pointer */
395
- captured: Map<THREE$1.Object3D, PointerCaptureTarget>
396
- /** Initial click position [x, y] */
397
- initialClick: [x: number, y: number]
398
- /** Objects hit on initial click */
399
- initialHits: THREE$1.Object3D[]
400
- }
401
-
402
- type Dpr = number | [min: number, max: number]
403
-
404
- interface Size {
405
- width: number
406
- height: number
407
- top: number
408
- left: number
409
- }
410
-
411
- type Frameloop = 'always' | 'demand' | 'never'
412
-
413
- interface Viewport extends Size {
414
- /** The initial pixel ratio */
415
- initialDpr: number
416
- /** Current pixel ratio */
417
- dpr: number
418
- /** size.width / viewport.width */
419
- factor: number
420
- /** Camera distance */
421
- distance: number
422
- /** Camera aspect ratio: width / height */
423
- aspect: number
424
- }
425
-
426
- type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
427
-
428
- interface Performance {
429
- /** Current performance normal, between min and max */
430
- current: number
431
- /** How low the performance can go, between 0 and max */
432
- min: number
433
- /** How high the performance can go, between min and max */
434
- max: number
435
- /** Time until current returns to max in ms */
436
- debounce: number
437
- /** Sets current to min, puts the system in regression */
438
- regress: () => void
439
- }
440
-
441
- interface InternalState {
442
- interaction: THREE$1.Object3D[]
443
- subscribers: Subscription[]
444
- /** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
445
- pointerMap: Map<number, PointerState>
446
- /** Pointers needing raycast this frame (used with frameTimedRaycasts) */
447
- pointerDirty: Map<number, DomEvent>
448
- /** Last event received (for events.update() compatibility) */
449
- lastEvent: React$1.RefObject<DomEvent | null>
450
- /** @deprecated Use pointerMap.get(pointerId).hovered instead */
451
- hovered: Map<string, ThreeEvent<DomEvent>>
452
- /** @deprecated Use pointerMap.get(pointerId).captured instead */
453
- capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
454
- /** @deprecated Use pointerMap.get(pointerId).initialClick instead */
455
- initialClick: [x: number, y: number]
456
- /** @deprecated Use pointerMap.get(pointerId).initialHits instead */
457
- initialHits: THREE$1.Object3D[]
458
- /** Visibility event registry (onFramed, onOccluded, onVisible) */
459
- visibilityRegistry: Map<string, VisibilityEntry>
460
- /** Whether occlusion queries are enabled (WebGPU only) */
461
- occlusionEnabled: boolean
462
- /** Reference to the invisible occlusion observer mesh */
463
- occlusionObserver: THREE$1.Mesh | null
464
- /** Cached occlusion results from render pass - keyed by Object3D */
465
- occlusionCache: Map<THREE$1.Object3D, boolean | null>
466
- /** Internal helper group for R3F system objects (occlusion observer, etc.) */
467
- helperGroup: THREE$1.Group | null
468
- active: boolean
469
- priority: number
470
- frames: number
471
- subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
472
- /** Internal renderer storage - use state.renderer or state.gl to access */
473
- actualRenderer: R3FRenderer
474
- /** Global scheduler reference (for useFrame hook) */
475
- scheduler: SchedulerApi | null
476
- /**
477
- * Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
478
- * `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
479
- * render-phase takeover. Used by `useRenderPipeline`.
480
- */
481
- renderOverride?: (() => void) | null
482
- /** This root's unique ID in the global scheduler */
483
- rootId?: string
484
- /** Function to unregister this root from the global scheduler */
485
- unregisterRoot?: () => void
486
- /** Container for child attachment (scene for root, original container for portals) */
487
- container?: THREE$1.Object3D
488
- /**
489
- * The CanvasTarget this root sizes and renders through.
490
- *
491
- * A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
492
- * around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
493
- * R3F created for its own element. Either way there is exactly one target per canvas element,
494
- * and the canvas-target job makes it the renderer's active one before this root renders.
495
- * Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
496
- * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
497
- */
498
- canvasTarget?: CanvasTarget
499
- /**
500
- * Set when this root's canvas target has been resized and the backend's cached render pass
501
- * descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
502
- *
503
- * Flushed by the canvas-target job in the `start` phase, which is the only place this root's
504
- * target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
505
- * whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
506
- * invalidate some other canvas's descriptor instead.
507
- *
508
- * @see https://github.com/pmndrs/react-three-fiber/issues/3847
509
- */
510
- canvasTargetSizeDirty?: boolean
511
- /**
512
- * Whether multi-canvas rendering is active.
513
- * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
514
- * When true, setCanvasTarget is called before each render.
515
- */
516
- isMultiCanvas?: boolean
517
- /**
518
- * Whether this canvas is a secondary canvas sharing another's renderer.
519
- * True when `target` prop is used.
520
- */
521
- isSecondary?: boolean
522
- /**
523
- * The id of the primary canvas this secondary canvas targets.
524
- * Only set when isSecondary is true.
525
- */
526
- targetId?: string
527
- /**
528
- * Function to unregister this primary canvas from the registry.
529
- * Only set when this canvas has an `id` prop.
530
- */
531
- unregisterPrimary?: () => void
532
- /** Whether canvas dimensions are forced to even numbers */
533
- forceEven?: boolean
534
- }
535
-
536
- interface XRManager {
537
- connect: () => void
538
- disconnect: () => void
539
- }
540
-
541
- //* Root State Interface ====================================
542
-
543
- interface RootState {
544
- /** Set current state */
545
- set: StoreApi<RootState>['setState']
546
- /** Get current state */
547
- get: StoreApi<RootState>['getState']
548
- /**
549
- * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
550
- * - For primary/independent canvases: points to its own store (self-reference)
551
- * - For secondary canvases: points to the primary canvas's store
552
- *
553
- * Hooks like useNodes/useUniforms should read from primaryStore to ensure
554
- * consistent shared state across all canvases sharing a renderer.
555
- */
556
- primaryStore: RootStore
557
- /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
558
- gl: THREE$1.WebGLRenderer
559
- /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
560
- renderer: R3FRenderer
561
- /** Inspector of the webGPU Renderer. Init in the canvas */
562
- inspector: any // Inspector type from three/webgpu
563
-
564
- /** Default camera */
565
- camera: ThreeCamera
566
- /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
567
- frustum: THREE$1.Frustum
568
- /** Whether to automatically update the frustum each frame (default: true) */
569
- autoUpdateFrustum: boolean
570
- /** Default scene (may be overridden in portals to point to the portal container) */
571
- scene: THREE$1.Scene
572
- /** The actual root THREE.Scene - always points to the true scene, even inside portals */
573
- rootScene: THREE$1.Scene
574
- /** Default raycaster */
575
- raycaster: THREE$1.Raycaster
576
- /** Event layer interface, contains the event handler and the node they're connected to */
577
- events: EventManager<any>
578
- /** XR interface */
579
- xr: XRManager
580
- /** Currently used controls */
581
- controls: THREE$1.EventDispatcher | null
582
- /** Normalized event coordinates */
583
- pointer: THREE$1.Vector2
584
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
585
- mouse: THREE$1.Vector2
586
- /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
587
- textureColorSpace: THREE$1.ColorSpace
588
- /** Render loop flags */
589
- frameloop: Frameloop
590
- performance: Performance
591
- /** Reactive pixel-size of the canvas */
592
- size: Size
593
- /** Reactive size of the viewport in threejs units */
594
- viewport: Viewport & {
595
- getCurrentViewport: (
596
- camera?: ThreeCamera,
597
- target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
598
- size?: Size,
599
- ) => Omit<Viewport, 'dpr' | 'initialDpr'>
600
- }
601
- /** Flags the canvas for render, but doesn't render in itself */
602
- invalidate: (frames?: number, stackFrames?: boolean) => void
603
- /** Advance (render) one step */
604
- advance: (timestamp: number, runGlobalEffects?: boolean) => void
605
- /** Shortcut to setting the event layer */
606
- setEvents: (events: Partial<EventManager<any>>) => void
607
- /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
608
- setSize: (width?: number, height?: number, top?: number, left?: number) => void
609
- /** Shortcut to manual setting the pixel ratio */
610
- setDpr: (dpr: Dpr) => void
611
- /** Shortcut to setting frameloop flags. No args resets to 'always'. */
612
- setFrameloop: (frameloop?: Frameloop) => void
613
- /** Set error state to propagate to error boundary */
614
- setError: (error: Error | null) => void
615
- /** Current error state (null when no error) */
616
- error: Error | null
617
- /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
618
- uniforms: UniformStore
619
- /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
620
- nodes: NodeStore
621
- /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
622
- buffers: BufferStore
623
- /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
624
- gpuStorage: StorageStore
625
- /** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
626
- textures: Map<string, THREE$1.Texture>
627
- /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
628
- _textureRefs: Map<string, number>
629
- /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
630
- renderPipeline: ThreeRenderPipeline | null
631
- /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
632
- passes: PassRecord
633
- /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
634
- _hmrVersion: number
635
- /** Internal: whether setSize() has taken ownership of canvas dimensions */
636
- _sizeImperative: boolean
637
- /** Internal: stored size props from Canvas for reset functionality */
638
- _sizeProps: { width?: number; height?: number } | null
639
- /** When the canvas was clicked but nothing was hit */
640
- onPointerMissed?: (event: MouseEvent) => void
641
- /** When a dragover event has missed any target */
642
- onDragOverMissed?: (event: DragEvent) => void
643
- /** When a drop event has missed any target */
644
- onDropMissed?: (event: DragEvent) => void
645
- /** If this state model is layered (via createPortal) then this contains the previous layer */
646
- previousRoot?: RootStore
647
- /** Internals */
648
- internal: InternalState
649
- // flags for triggers
650
- // if we are using the webGl renderer, this will be true
651
- isLegacy: boolean
652
- // regardless of renderer, if the system supports webGpu, this will be true
653
- webGPUSupported: boolean
654
- //if we are on native
655
- isNative: boolean
656
- }
657
-
658
- type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
659
-
660
- /**
661
- * @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
662
- *
663
- * This is the single source of truth for Three.js imports within R3F.
664
- * All internal code should import from '#three' (or '../three' relative).
665
- *
666
- * DEFAULT behavior (root import):
667
- * - Exports from three/webgpu (the new standard)
668
- * - Also exports WebGLRenderer for backwards compatibility (with deprecation)
669
- * - Both renderer types available, runtime decides which to use
670
- *
671
- * For explicit legacy or webgpu-only builds, use:
672
- * - #three/legacy - WebGL only, no WebGPU
673
- * - #three/webgpu - WebGPU only, no WebGL legacy
674
- */
675
- declare const R3F_BUILD_LEGACY = true;
676
- declare const R3F_BUILD_WEBGPU = true;
677
-
678
- /** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
679
- declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
680
-
681
- var THREE = /*#__PURE__*/_mergeNamespaces({
682
- __proto__: null,
683
- CubeRenderTarget: CubeRenderTarget,
684
- CubeRenderTargetCompat: CubeRenderTarget,
685
- Inspector: Inspector,
686
- R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
687
- R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
688
- RenderTargetCompat: RenderTarget,
689
- WebGLCubeRenderTarget: WebGLCubeRenderTarget,
690
- WebGLRenderTarget: WebGLRenderTarget,
691
- WebGLRenderer: WebGLRenderer,
692
- WebGLRendererParameters: WebGLRendererParameters,
693
- loadInspector: loadInspector
694
- }, [three_webgpu]);
695
-
696
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
697
-
698
- interface MathRepresentation {
699
- set(...args: number[]): any
700
- }
701
- interface VectorRepresentation extends MathRepresentation {
702
- setScalar(value: number): any
703
- }
704
- type MathTypes = MathRepresentation | Euler$1 | Color$1
705
-
706
- type MathType<T extends MathTypes> = T extends Color$1
707
- ? Args<typeof Color$1> | ColorRepresentation
708
- : T extends VectorRepresentation | Layers$1 | Euler$1
709
- ? T | MutableOrReadonlyParameters<T['set']> | number
710
- : T | MutableOrReadonlyParameters<T['set']>
711
-
712
- type MathProps<P> = {
713
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
714
- }
715
-
716
- type Vector2 = MathType<Vector2$1>
717
- type Vector3 = MathType<Vector3$1>
718
- type Vector4 = MathType<Vector4$1>
719
- type Color = MathType<Color$1>
720
- type Layers = MathType<Layers$1>
721
- type Quaternion = MathType<Quaternion$1>
722
- type Euler = MathType<Euler$1>
723
- type Matrix3 = MathType<Matrix3$1>
724
- type Matrix4 = MathType<Matrix4$1>
725
-
726
- interface RaycastableRepresentation {
727
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
728
- }
729
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
730
-
731
- /**
732
- * Props for geometry transform methods that can be called with `once()`.
733
- * These methods modify the geometry in-place and only make sense to call once on mount.
734
- *
735
- * @example
736
- * import { once } from '@react-three/fiber'
737
- *
738
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
739
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
740
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
741
- */
742
- interface GeometryTransformProps {
743
- /** Rotate the geometry about the X axis (radians). Use with once(). */
744
- rotateX?: number
745
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
746
- rotateY?: number
747
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
748
- rotateZ?: number
749
- /** Translate the geometry (x, y, z). Use with once(). */
750
- translate?: [x: number, y: number, z: number]
751
- /** Scale the geometry (x, y, z). Use with once(). */
752
- scale?: [x: number, y: number, z: number]
753
- /** Center the geometry based on bounding box. Use with once(). */
754
- center?: true
755
- /** Apply a Matrix4 transformation. Use with once(). */
756
- applyMatrix4?: Matrix4$1
757
- /** Apply a Quaternion rotation. Use with once(). */
758
- applyQuaternion?: Quaternion$1
759
- }
760
-
761
- type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
762
-
763
- /**
764
- * Workaround for @types/three TSL node type issues.
765
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
766
- * This transforms `Node | null` properties to accept any object with node-like shape.
767
- */
768
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
769
-
770
- /**
771
- * For node material properties (colorNode, positionNode, etc.), accept broader types
772
- * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
773
- * `nodeType`, so this structural key test remains neutral to the selected Three entry.
774
- */
775
- type NodeProps<P> = {
776
- [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
777
- }
778
-
779
- interface ReactProps<P> {
780
- children?: React.ReactNode
781
- ref?: React.Ref<P>
782
- key?: React.Key
783
- }
784
-
785
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
786
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
787
- >
788
-
789
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
790
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
791
- >
792
-
793
- type ThreeToJSXElements<T extends Record<string, any>> = {
794
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
795
- }
796
-
797
- /** Method names of Object3D, excluded from the `primitive` element's typed props. */
798
- type Object3DMethod = NonNullable<
799
- {
800
- [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
801
- }[keyof Object3D]
802
- >
803
-
804
- type ThreeExports = typeof THREE
805
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
806
-
807
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
808
- /**
809
- * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
810
- * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
811
- * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
812
- * methods are left out of the typed surface: they return `this`, so a subclass element's
813
- * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
814
- */
815
- primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
816
- object: object
817
- ref?: React.Ref<any>
818
- [prop: string]: unknown
819
- }
820
- // Conflicts with DOM types can be accessed through a three* prefix
821
- threeAudio: ThreeElementsImpl['audio']
822
- threeSource: ThreeElementsImpl['source']
823
- threeLine: ThreeElementsImpl['line']
824
- threePath: ThreeElementsImpl['path']
825
- }
826
-
827
- declare module 'react' {
828
- namespace JSX {
829
- interface IntrinsicElements extends ThreeElements {}
830
- }
831
- }
832
-
833
- declare module 'react/jsx-runtime' {
834
- namespace JSX {
835
- interface IntrinsicElements extends ThreeElements {}
836
- }
837
- }
838
-
839
- declare module 'react/jsx-dev-runtime' {
840
- namespace JSX {
841
- interface IntrinsicElements extends ThreeElements {}
842
- }
843
- }
844
-
845
- //* Base Renderer Types =====================================
846
-
847
- // Shim for OffscreenCanvas since it was removed from DOM types
848
- interface OffscreenCanvas extends EventTarget {}
849
-
850
- interface BaseRendererProps {
851
- canvas: HTMLCanvasElement | OffscreenCanvas
852
- powerPreference?: 'high-performance' | 'low-power' | 'default'
853
- antialias?: boolean
854
- alpha?: boolean
855
- }
856
-
857
- type RendererFactory<TRenderer, TParams> =
858
- | TRenderer
859
- | ((defaultProps: TParams) => TRenderer)
860
- | ((defaultProps: TParams) => Promise<TRenderer>)
861
-
862
- interface Renderer {
863
- render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
864
- }
865
-
866
- //* Color Management Config ==============================
867
-
868
- /**
869
- * Color management configuration shared by both WebGL and WebGPU renderers.
870
- */
871
- interface ColorManagementConfig {
872
- /**
873
- * Color space assigned to 8-bit input textures (color maps).
874
- * Defaults to sRGB. Most textures are authored in sRGB.
875
- * @default THREE.SRGBColorSpace
876
- */
877
- textureColorSpace?: THREE$1.ColorSpace
878
- }
879
-
880
- //* WebGL Renderer Props ==============================
881
-
882
- type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
883
- canvas: HTMLCanvasElement | OffscreenCanvas
884
- }
885
-
886
- type GLProps =
887
- | Renderer
888
- | ((defaultProps: DefaultGLProps) => Renderer)
889
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
890
- | (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
891
-
892
- //* WebGPU Renderer Props ==============================
893
-
894
- type DefaultRendererProps = {
895
- canvas: HTMLCanvasElement | OffscreenCanvas
896
- [key: string]: any
897
- }
898
-
899
- /**
900
- * Canvas-level scheduler configuration.
901
- * Controls render timing relative to other canvases.
902
- */
903
- interface CanvasSchedulerConfig {
904
- /**
905
- * Run this Canvas root before the referenced Canvas root id(s).
906
- */
907
- before?: string | string[]
908
- /**
909
- * Run this Canvas root after the referenced Canvas root id(s).
910
- */
911
- after?: string | string[]
912
- /**
913
- * Numeric root order. Lower values run first.
914
- */
915
- order?: number
916
- /**
917
- * Limit this Canvas's default render job (frames per second).
918
- */
919
- fps?: number
920
- }
921
-
922
- /**
923
- * Extended renderer configuration for multi-canvas support and color management.
924
- */
925
- interface RendererConfigExtended extends ColorManagementConfig {
926
- /** Share renderer from another canvas (WebGPU only) */
927
- primaryCanvas?: string
928
- /** Canvas-level scheduler options */
929
- scheduler?: CanvasSchedulerConfig
930
- }
931
-
932
- type RendererProps =
933
- | any // WebGPURenderer
934
- | ((defaultProps: DefaultRendererProps) => any)
935
- | ((defaultProps: DefaultRendererProps) => Promise<any>)
936
- | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
937
-
938
- //* Camera Props ==============================
939
-
940
- type CameraProps = (
941
- | THREE$1.Camera
942
- | Partial<
943
- ThreeElement<typeof THREE$1.Camera> &
944
- ThreeElement<typeof THREE$1.PerspectiveCamera> &
945
- ThreeElement<typeof THREE$1.OrthographicCamera>
946
- >
947
- ) & {
948
- /** Flags the camera as manual, putting projection into your own hands */
949
- manual?: boolean
950
- }
951
-
952
- //* Render Props ==============================
953
-
954
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
955
- /**
956
- * Unique identifier for multi-canvas renderer sharing.
957
- * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
958
- * Also sets the HTML `id` attribute on the canvas element.
959
- * @example <Canvas id="main-viewer">...</Canvas>
960
- */
961
- id?: string
962
- /**
963
- * Share the renderer from another canvas instead of creating a new one.
964
- * Pass the `id` of the primary canvas to share its WebGPURenderer.
965
- * Only available with WebGPU (not legacy WebGL).
966
- *
967
- * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
968
- * @internal
969
- */
970
- primaryCanvas?: string
971
- /**
972
- * Canvas-level scheduler options. Controls render timing relative to other canvases.
973
- *
974
- * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
975
- * @internal
976
- */
977
- scheduler?: CanvasSchedulerConfig
978
- /** A threejs renderer instance or props that go into the default renderer */
979
- gl?: GLProps
980
- /** A WebGPU renderer instance or props that go into the default renderer */
981
- renderer?: RendererProps
982
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
983
- size?: Size
984
- /**
985
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
986
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
987
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
988
- */
989
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
990
- /** Creates an orthographic camera */
991
- orthographic?: boolean
992
- /**
993
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
994
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
995
- */
996
- frameloop?: Frameloop
997
- /**
998
- * R3F performance options for adaptive performance.
999
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
1000
- */
1001
- performance?: Partial<Omit<Performance, 'regress'>>
1002
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
1003
- dpr?: Dpr
1004
- /**
1005
- * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
1006
- * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
1007
- */
1008
- raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
1009
- /** A `THREE.Scene` instance or props that go into the default scene */
1010
- scene?: THREE$1.Scene | Partial<THREE$1.Scene>
1011
- /** A `THREE.Camera` instance or props that go into the default camera */
1012
- camera?: CameraProps
1013
- /** An R3F event manager to manage elements' pointer events */
1014
- events?: (store: RootStore) => EventManager<Element>
1015
- /** Callback after the canvas has rendered (but not yet committed) */
1016
- onCreated?: (state: RootState) => void
1017
- /** Response for pointer clicks that have missed any target */
1018
- onPointerMissed?: (event: MouseEvent) => void
1019
- /** Response for dragover events that have missed any target */
1020
- onDragOverMissed?: (event: DragEvent) => void
1021
- /** Response for drop events that have missed any target */
1022
- onDropMissed?: (event: DragEvent) => void
1023
- /** Whether to automatically update the frustum each frame (default: true) */
1024
- autoUpdateFrustum?: boolean
1025
- /**
1026
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
1027
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
1028
- * Only works with WebGPU renderer - WebGL will log a warning.
1029
- */
1030
- occlusion?: boolean
1031
- /** Internal: stored size props from Canvas for reset functionality */
1032
- _sizeProps?: { width?: number; height?: number } | null
1033
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1034
- forceEven?: boolean
1035
- }
1036
-
1037
- //* Reconciler Root ==============================
1038
-
1039
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
1040
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
1041
- render: (element: ReactNode) => RootStore
1042
- unmount: () => void
1043
- }
1044
-
1045
- //* Inject State ==============================
1046
-
1047
- type InjectState = Partial<
1048
- Omit<RootState, 'events'> & {
1049
- events?: {
1050
- enabled?: boolean
1051
- priority?: number
1052
- compute?: ComputeFunction
1053
- connected?: any
1054
- }
1055
- /**
1056
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
1057
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
1058
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
1059
- */
1060
- injectScene?: boolean
1061
- }
1062
- >
1063
-
1064
- //* Reconciler Types ==============================
1065
-
1066
- // FiberRoot is an opaque internal React type - we define it locally
1067
- // to avoid bundling @types/react-reconciler which causes absolute path issues
1068
- type FiberRoot = any
1069
-
1070
- interface Root {
1071
- fiber: FiberRoot
1072
- store: RootStore
1073
- }
1074
-
1075
- type AttachFnType<O = any> = (parent: any, self: O) => () => void
1076
- type AttachType<O = any> = string | AttachFnType<O>
1077
-
1078
- type ConstructorRepresentation<T = any> = new (...args: any[]) => T
1079
-
1080
- interface Catalogue {
1081
- [name: string]: ConstructorRepresentation
1082
- }
1083
-
1084
- // TODO: handle constructor overloads
1085
- // https://github.com/pmndrs/react-three-fiber/pull/2931
1086
- // https://github.com/microsoft/TypeScript/issues/37079
1087
- type Args<T> = T extends ConstructorRepresentation
1088
- ? T extends typeof Color$2
1089
- ? [r: number, g: number, b: number] | [color: ColorRepresentation$1]
1090
- : ConstructorParameters<T>
1091
- : any[]
1092
-
1093
- type ArgsProp<P> = P extends ConstructorRepresentation
1094
- ? IsAllOptional<ConstructorParameters<P>> extends true
1095
- ? { args?: Args<P> }
1096
- : { args: Args<P> }
1097
- : { args: unknown[] }
1098
-
1099
- type InstanceProps<T = any, P = any> = ArgsProp<P> & {
1100
- object?: T
1101
- dispose?: null
1102
- attach?: AttachType<T>
1103
- }
1104
-
1105
- interface Instance<O = any> {
1106
- root: RootStore
1107
- type: string
1108
- parent: Instance | null
1109
- children: Instance[]
1110
- props: InstanceProps<O> & Record<string, unknown>
1111
- object: O & { __r3f?: Instance<O> }
1112
- eventCount: number
1113
- handlers: Partial<EventHandlers>
1114
- attach?: AttachType<O>
1115
- previousAttach?: any
1116
- isHidden: boolean
1117
- /** Set of props that have been applied via once() */
1118
- appliedOnce?: Set<string>
1119
- }
1120
-
1121
- interface HostConfig {
1122
- type: string
1123
- props: Instance['props']
1124
- container: RootStore
1125
- instance: Instance
1126
- textInstance: void
1127
- suspenseInstance: Instance
1128
- hydratableInstance: never
1129
- formInstance: never
1130
- publicInstance: Instance['object']
1131
- hostContext: {}
1132
- childSet: never
1133
- timeoutHandle: number | undefined
1134
- noTimeout: -1
1135
- TransitionStatus: null
1136
- }
1137
- declare global {
1138
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
1139
- }
1140
-
1141
- //* Loop Types ==============================
1142
-
1143
- type GlobalRenderCallback = (timestamp: number) => void
1144
-
1145
- type GlobalEffectType = 'before' | 'after' | 'tail'
1146
-
1147
- declare const presetsObj: {
1148
- apartment: string;
1149
- city: string;
1150
- dawn: string;
1151
- forest: string;
1152
- lobby: string;
1153
- night: string;
1154
- park: string;
1155
- studio: string;
1156
- sunset: string;
1157
- warehouse: string;
1158
- };
1159
- type PresetsType = keyof typeof presetsObj;
1160
-
1161
- //* Background Types ==============================
1162
-
1163
- /**
1164
- * Expanded object form for background configuration.
1165
- * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
1166
- */
1167
- interface BackgroundConfig {
1168
- /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
1169
- preset?: PresetsType
1170
- /** Files for cube texture (6 faces) or single HDR/EXR */
1171
- files?: string | string[]
1172
- /** Separate files for scene.background (visual backdrop) */
1173
- backgroundMap?: string | string[]
1174
- backgroundRotation?: Euler$2 | [number, number, number]
1175
- backgroundBlurriness?: number
1176
- backgroundIntensity?: number
1177
- /** Separate files for scene.environment (PBR lighting/reflections) */
1178
- envMap?: string | string[]
1179
- environmentRotation?: Euler$2 | [number, number, number]
1180
- environmentIntensity?: number
1181
- path?: string
1182
- extensions?: (loader: Loader) => void
1183
- }
1184
-
1185
- /**
1186
- * Background prop type for Canvas.
1187
- *
1188
- * String detection priority:
1189
- * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1190
- * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
1191
- * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
1192
- *
1193
- * @example Color
1194
- * ```tsx
1195
- * <Canvas background="red" />
1196
- * <Canvas background="#ff0000" />
1197
- * <Canvas background={0xff0000} />
1198
- * ```
1199
- *
1200
- * @example Preset
1201
- * ```tsx
1202
- * <Canvas background="city" />
1203
- * ```
1204
- *
1205
- * @example URL
1206
- * ```tsx
1207
- * <Canvas background="/path/to/env.hdr" />
1208
- * <Canvas background="./sky.jpg" />
1209
- * ```
1210
- *
1211
- * @example Object form
1212
- * ```tsx
1213
- * <Canvas background={{
1214
- * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1215
- * backgroundMap: 'path/to/sky.jpg',
1216
- * envMap: 'path/to/lighting.hdr',
1217
- * backgroundBlurriness: 0.5,
1218
- * }} />
1219
- * ```
1220
- */
1221
- type BackgroundProp =
1222
- | ColorRepresentation$1 // "red", "#ff0000", 0xff0000
1223
- | string // URL or preset
1224
- | BackgroundConfig // Expanded object form
1225
-
1226
- //* Canvas Types ==============================
1227
-
1228
- interface CanvasProps
1229
- extends
1230
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1231
- React$1.HTMLAttributes<HTMLDivElement> {
1232
- children?: React$1.ReactNode
1233
- ref?: React$1.Ref<HTMLCanvasElement>
1234
- /** Canvas fallback content, similar to img's alt prop */
1235
- fallback?: React$1.ReactNode
1236
- /**
1237
- * Options to pass to useMeasure.
1238
- * @see https://github.com/pmndrs/react-use-measure#api
1239
- */
1240
- resize?: Options
1241
- /** The target where events are being subscribed to, default: the div that wraps canvas */
1242
- eventSource?: Element | React$1.RefObject<Element | null>
1243
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1244
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1245
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1246
- hmr?: boolean
1247
- /** Canvas resolution width in pixels. If omitted, uses container width. */
1248
- width?: number
1249
- /** Canvas resolution height in pixels. If omitted, uses container height. */
1250
- height?: number
1251
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1252
- forceEven?: boolean
1253
- /**
1254
- * Scene background configuration.
1255
- * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1256
- * @see BackgroundProp for full documentation and examples
1257
- */
1258
- background?: BackgroundProp
1259
- }
1260
-
1261
- //* Loader Types ==============================
1262
-
1263
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1264
-
1265
- // Define a loader-like interface that matches THREE.Loader's load signature
1266
- // This works for both generic and non-generic THREE.Loader instances
1267
- interface LoaderLike {
1268
- load(
1269
- url: InputLike,
1270
- onLoad?: (result: any) => void,
1271
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
1272
- onError?: (error: unknown) => void,
1273
- ): any
1274
- }
1275
-
1276
- type GLTFLike = { scene: THREE$1.Object3D }
1277
-
1278
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1279
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1280
-
1281
- // Infer result type from the load method's callback parameter
1282
- type InferLoadResult<T> = T extends {
1283
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1284
- }
1285
- ? R
1286
- : T extends ConstructorRepresentation<any>
1287
- ? InstanceType<T> extends {
1288
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1289
- }
1290
- ? R
1291
- : any
1292
- : any
1293
-
1294
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1295
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1296
-
1297
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1298
- loader: LoaderInstance<T>,
1299
- ) => void
1300
-
1301
- //* Renderer Props ========================================
1302
-
1303
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1304
-
1305
- type WebGLProps =
1306
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1307
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1308
-
1309
- interface WebGLShadowConfig {
1310
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1311
- }
1312
-
1313
- //* Legacy-specific Types ========================================
1314
-
1315
- /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1316
- type LegacyRenderer = THREE$1.WebGLRenderer
1317
-
1318
- /** Legacy internal state with narrowed renderer type */
1319
- interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1320
- actualRenderer: THREE$1.WebGLRenderer
1321
- }
1322
-
1323
- /**
1324
- * Legacy-specific RootState with narrowed renderer type.
1325
- * Automatically used when importing from `@react-three/fiber/legacy`.
1326
- *
1327
- * @example
1328
- * ```tsx
1329
- * import { useThree } from '@react-three/fiber/legacy'
1330
- *
1331
- * function MyComponent() {
1332
- * const { renderer } = useThree()
1333
- * // renderer is typed as THREE.WebGLRenderer
1334
- * renderer.shadowMap.enabled = true
1335
- * }
1336
- * ```
1337
- */
1338
- interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1339
- /** The WebGL renderer instance */
1340
- renderer: THREE$1.WebGLRenderer
1341
- /** Internals with WebGL renderer */
1342
- internal: LegacyInternalState
1343
- }
1344
-
1345
- //* RenderTarget Types ==============================
1346
-
1347
-
1348
- type RenderTargetOptions = RenderTargetOptions$1
1349
-
1350
- //* Global TSL Types ==============================
1351
-
1352
- declare global {
1353
- /**
1354
- * Broad callable-node fallback for dynamic store readers.
1355
- * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1356
- */
1357
- type CallableTSLNode = ((...params: never[]) => unknown) & {
1358
- readonly shaderNode: unknown
1359
- readonly id: number
1360
- }
1361
-
1362
- /** Legacy structural node accepted when at least one historical marker exists. */
1363
- type LegacyTSLNodeLike = {
1364
- label?: ((label: string) => unknown) | string
1365
- setName?: (name: string) => unknown
1366
- } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1367
-
1368
- /** Node type accepted by broad dynamic node-store readers. */
1369
- type TSLNodeType = three_webgpu.Node | CallableTSLNode
1370
-
1371
- /**
1372
- * Derive Three's shader node type from an existing node or a supported raw input.
1373
- * Existing InputNode generics take precedence over structural value normalization.
1374
- * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1375
- * InputNode base with its concrete InputNode specialization.
1376
- */
1377
- type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1378
- ? TNodeType
1379
- : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1380
- ? TNodeType
1381
- : T extends number
1382
- ? 'float'
1383
- : T extends boolean
1384
- ? 'bool'
1385
- : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1386
- ? 'color'
1387
- : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1388
- ? 'vec4'
1389
- : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1390
- ? 'vec3'
1391
- : T extends three_webgpu.Vector2 | { x: number; y: number }
1392
- ? 'vec2'
1393
- : T extends three_webgpu.Matrix4
1394
- ? 'mat4'
1395
- : T extends three_webgpu.Matrix3
1396
- ? 'mat3'
1397
- : T extends three_webgpu.Matrix2
1398
- ? 'mat2'
1399
- : unknown
1400
-
1401
- /** Derive the normalized JavaScript value stored by a uniform node. */
1402
- type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1403
- ? TValue
1404
- : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1405
- ? TValue
1406
- : T extends string | { r: number; g: number; b: number }
1407
- ? three_webgpu.Color
1408
- : T extends { x: number; y: number; z: number; w: number }
1409
- ? three_webgpu.Vector4
1410
- : T extends { x: number; y: number; z: number }
1411
- ? three_webgpu.Vector3
1412
- : T extends { x: number; y: number }
1413
- ? three_webgpu.Vector2
1414
- : T extends number
1415
- ? number
1416
- : T extends boolean
1417
- ? boolean
1418
- : T
1419
-
1420
- /** Three's exact UniformNode with shader and value generics derived from an input. */
1421
- type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1422
-
1423
- /** Preserve every input key while mapping values to exact Three uniform nodes. */
1424
- type UniformNodesFor<T extends UniformInputRecord> = {
1425
- [K in keyof T]: UniformNodeFor<T[K]>
1426
- }
1427
-
1428
- /** Backward-compatible single-parameter uniform alias. */
1429
- type UniformNode<T = unknown> = UniformNodeFor<T>
1430
-
1431
- /** Flat record of uniform nodes (no nested scopes) */
1432
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1433
-
1434
- /**
1435
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
1436
- * Used by state.uniforms which has structure like:
1437
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1438
- */
1439
- type UniformStore = Record<string, UniformNode | UniformRecord>
1440
-
1441
- /**
1442
- * Helper to safely access a uniform node from the store.
1443
- * Use this when accessing state.uniforms to get proper typing.
1444
- * @example
1445
- * const uTime = uniforms.uTime as UniformNode<number>
1446
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1447
- */
1448
- type GetUniform<T = unknown> = UniformNode<T>
1449
-
1450
- /**
1451
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1452
- * Supports:
1453
- * - Primitives: number, string (color), boolean
1454
- * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1455
- * - Plain objects: { x, y, z, w } converted to vectors
1456
- * - TSL nodes: color(), vec3(), float() for type casting
1457
- * - UniformNode: existing uniforms (reused as-is)
1458
- */
1459
- type UniformValue =
1460
- | number
1461
- | string
1462
- | boolean
1463
- | three_webgpu.Color
1464
- | three_webgpu.Vector2
1465
- | three_webgpu.Vector3
1466
- | three_webgpu.Vector4
1467
- | three_webgpu.Matrix2
1468
- | three_webgpu.Matrix3
1469
- | three_webgpu.Matrix4
1470
- | { x: number; y: number }
1471
- | { x: number; y: number; z: number }
1472
- | { x: number; y: number; z: number; w: number }
1473
- | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1474
- | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1475
- | UniformNode
1476
-
1477
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1478
- type UniformInputRecord = Record<string, UniformValue>
1479
- }
1480
-
1481
- declare global {
1482
- /**
1483
- * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1484
- * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1485
- * is r185, so the new name is the only one.
1486
- */
1487
- type ThreeRenderPipeline = three_webgpu.RenderPipeline
1488
-
1489
- /**
1490
- * The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
1491
- * `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
1492
- * `getTextureNode`, `setMRT` and `dispose` track the installed version.
1493
- */
1494
- type ScenePassNode = three_webgpu.PassNode
1495
-
1496
- /**
1497
- * Pass record - stores TSL pass nodes for render pipeline.
1498
- *
1499
- * `scenePass` is the only key the library owns. It is optional here because this is also the
1500
- * shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
1501
- * or `clearPasses()`. Inside the callbacks it is always present; see
1502
- * {@link RenderPipelineCallbackState}.
1503
- *
1504
- * Every other key is user-registered, via a callback's return value. Those are TSL nodes of
1505
- * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1506
- * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1507
- * site when you need a member, e.g. `passes.velocity as TextureNode`.
1508
- *
1509
- * The index signature admits `undefined` because a key may simply not be registered, and
1510
- * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1511
- * optional property whose type excludes `undefined` from the index signature is an error
1512
- * (TS2411) for every consumer compiling these declarations.
1513
- */
1514
- interface PassRecord {
1515
- scenePass?: ScenePassNode
1516
- [key: string]: three_webgpu.Node | undefined
1517
- }
1518
-
1519
- /**
1520
- * State passed to pipeline callbacks after the active pipeline has been created.
1521
- *
1522
- * `passes.scenePass` is required here: the hook installs the default scene pass before either
1523
- * callback runs, so callbacks can use it without a guard or a cast.
1524
- *
1525
- * `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
1526
- * the legacy renderer before either callback can run, so a callback never sees WebGL.
1527
- */
1528
- type RenderPipelineCallbackState = RootState & {
1529
- renderPipeline: ThreeRenderPipeline
1530
- passes: PassRecord & { scenePass: ScenePassNode }
1531
- renderer: three_webgpu.WebGPURenderer
1532
- isLegacy: false
1533
- }
1534
-
1535
- /**
1536
- * What a callback may return to register entries into `state.passes`.
1537
- *
1538
- * `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
1539
- * created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
1540
- * store entry would leave the store pointing at a node the hook never disposes, and the hook
1541
- * disposing a pass nothing references. So returning it is a type error.
1542
- */
1543
- type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
1544
-
1545
- /** Setup callback - runs first to configure MRT, create additional passes */
1546
- type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1547
-
1548
- /** Main callback - runs second to configure outputNode, create effect passes */
1549
- type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
1550
-
1551
- /** The imperative half of useRenderPipeline's return value, present in every state */
1552
- interface UseRenderPipelineActions {
1553
- /** Current passes from state */
1554
- passes: PassRecord
1555
- /** Clear all passes from state */
1556
- clearPasses: () => void
1557
- /** Reset RenderPipeline entirely (clears PP + passes) */
1558
- reset: () => void
1559
- /** Re-run setup/main callbacks with current closure values */
1560
- rebuild: () => void
1561
- }
1562
-
1563
- /**
1564
- * Return type for useRenderPipeline hook, discriminated on `isReady`.
1565
- *
1566
- * `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
1567
- * callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
1568
- * `clearPasses()` empties the record while leaving the pipeline in place.
1569
- */
1570
- type UseRenderPipelineReturn = UseRenderPipelineActions &
1571
- (
1572
- | {
1573
- /** True when RenderPipeline is configured and ready */
1574
- isReady: true
1575
- /** RenderPipeline instance */
1576
- renderPipeline: ThreeRenderPipeline
1577
- }
1578
- | {
1579
- /** False until the pipeline has been created */
1580
- isReady: false
1581
- /** Not initialized yet, or torn down by reset() */
1582
- renderPipeline: null
1583
- }
1584
- )
1585
- }
1586
-
1587
- declare const context: React$1.Context<RootStore>;
1588
-
1589
- /**
1590
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1591
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1592
- */
1593
- declare function useStore(): RootStore;
1594
- /**
1595
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1596
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1597
- */
1598
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
5
+ import 'react';
6
+ import 'three';
7
+ import 'three/webgpu';
8
+ import 'zustand';
9
+ import 'zustand/traditional';
10
+ import 'three/tsl';
1599
11
 
1600
12
  /**
1601
13
  * Frame hook with phase-based ordering, priority, and FPS throttling.
@@ -1641,35 +53,4 @@ declare function useThree<T = RootState>(selector?: (state: RootState) => T, equ
1641
53
  */
1642
54
  declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
1643
55
 
1644
- interface RootExtension {
1645
- /** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
1646
- * set up are not set up a second time, but get the new entry's dispose and hmr. */
1647
- name: string;
1648
- /**
1649
- * Called once per root, after its renderer exists and before `onCreated` and the first frame.
1650
- * `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
1651
- * to the primary canvas. Return fields to merge into the root's state, or nothing.
1652
- */
1653
- setup?(store: RootStore): Partial<RootState> | void;
1654
- /** Called when a root this extension set up unmounts. */
1655
- dispose?(store: RootStore): void;
1656
- /** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
1657
- hmr?(store: RootStore): void;
1658
- }
1659
- /**
1660
- * Register an extension. It is set up on every live root immediately, and on every root created
1661
- * afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
1662
- * it already set up keep its state and still get its dispose when they unmount.
1663
- */
1664
- declare function registerRootExtension(extension: RootExtension): () => void;
1665
- /**
1666
- * Point a root's default render job at a different render function, or back at
1667
- * `renderer.render(scene, camera)` with `null`.
1668
- *
1669
- * The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
1670
- * boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
1671
- */
1672
- declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
1673
-
1674
- export { context, registerRootExtension, setRenderOverride, useFrame, useStore, useThree };
1675
- export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
56
+ export { FrameNextCallback, useFrame };