@react-three/fiber 10.0.0-canary.b0fafc8 → 10.0.0-canary.b86abaa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/chunks/webgl.cjs +27 -0
  2. package/dist/chunks/webgl.mjs +11 -0
  3. package/dist/chunks/webgpu.cjs +37 -0
  4. package/dist/chunks/webgpu.mjs +21 -0
  5. package/dist/extension.cjs +13 -0
  6. package/dist/extension.d.cts +19 -0
  7. package/dist/extension.d.mts +19 -0
  8. package/dist/extension.d.ts +19 -0
  9. package/dist/extension.mjs +1 -0
  10. package/dist/index.cjs +100 -15849
  11. package/dist/index.d.cts +124 -4234
  12. package/dist/index.d.mts +124 -4234
  13. package/dist/index.d.ts +124 -4234
  14. package/dist/index.mjs +11 -15747
  15. package/dist/legacy.cjs +100 -15814
  16. package/dist/legacy.d.cts +115 -4238
  17. package/dist/legacy.d.mts +115 -4238
  18. package/dist/legacy.d.ts +115 -4238
  19. package/dist/legacy.mjs +15 -15715
  20. package/dist/shared/fiber.B0oukOFO.mjs +364 -0
  21. package/dist/shared/fiber.BU0vBHc9.d.mts +48 -0
  22. package/dist/shared/fiber.BY6Yf1h-.d.cts +2791 -0
  23. package/dist/shared/fiber.Cu2hX1IM.d.mts +2791 -0
  24. package/dist/shared/fiber.Cx-UAmMb.d.ts +48 -0
  25. package/dist/shared/fiber.DAl4H27x.d.cts +48 -0
  26. package/dist/shared/fiber.DXw-SLsH.d.ts +2791 -0
  27. package/dist/shared/fiber.I5Q4dVvl.d.cts +778 -0
  28. package/dist/shared/fiber.I5Q4dVvl.d.mts +778 -0
  29. package/dist/shared/fiber.I5Q4dVvl.d.ts +778 -0
  30. package/dist/shared/fiber.khFlPHPf.cjs +397 -0
  31. package/dist/shared/fiber.oKEFddXj.cjs +16059 -0
  32. package/dist/shared/fiber.tsM9NKZ9.mjs +15961 -0
  33. package/dist/webgpu/index.cjs +104 -16524
  34. package/dist/webgpu/index.d.cts +144 -4511
  35. package/dist/webgpu/index.d.mts +144 -4511
  36. package/dist/webgpu/index.d.ts +144 -4511
  37. package/dist/webgpu/index.mjs +19 -16411
  38. package/package.json +16 -12
  39. package/readme.md +4 -5
  40. package/react-reconciler/constants.d.ts +0 -7
  41. package/react-reconciler/constants.js +0 -1
  42. package/react-reconciler/index.d.ts +0 -1044
  43. package/react-reconciler/index.js +0 -208
@@ -1,4474 +1,105 @@
1
- import * as three_webgpu from 'three/webgpu';
2
- import { RenderTarget, WebGPURenderer, CanvasTarget, Node, ShaderNodeObject, 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, 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, Object3D, Frustum, OrthographicCamera, WebGPURendererParameters } from 'three/webgpu';
3
- import { Inspector } from 'three/addons/inspector/Inspector.js';
4
- import * as THREE$1 from 'three';
5
- import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
- import * as React$1 from 'react';
7
- import { ReactNode, Component, RefObject, JSX } from 'react';
1
+ import * as ThreeWebGPU from 'three/webgpu';
2
+ import { WebGPURenderer, WebGPURendererParameters, RenderTarget } from 'three/webgpu';
3
+ import { M as MutableOrReadonlyParameters$1, a as MathRepresentation$1, V as VectorRepresentation$1, b as MathTypes$1, c as MathType$1, d as MathProps$1, e as Vector2$1, f as Vector3$1, g as Vector4$1, C as Color$1, L as Layers$1, Q as Quaternion$1, E as Euler$1, h as Matrix3$1, i as Matrix4$1, R as RaycastableRepresentation$1, j as EventProps$1, G as GeometryTransformProps$1, k as GeometryProps$1, T as TSLNodeInput$1, N as NodeProps$1, l as ReactProps$1, m as ElementProps$1, n as ThreeElement$1, o as ThreeToJSXElements$1, O as Object3DMethod$1, p as ThreeElementsOf$1, q as ElementOf$1, z as RendererFactory, B as BaseRendererProps, t as CanvasProps, s as ReconcilerRoot, r as RenderTargetOptions } from '../shared/fiber.Cu2hX1IM.mjs';
4
+ export { Z as BackgroundConfig, _ as BackgroundProp, aZ as Block, S as CameraProps, J as CanvasSchedulerConfig, D as ColorManagementConfig, F as DefaultGLProps, I as DefaultRendererProps, aD as DisposeOptions, an as Environment, al as EnvironmentCube, aG as EnvironmentLoaderProps, ak as EnvironmentMap, am as EnvironmentPortal, aj as EnvironmentProps, a_ as ErrorBoundary, a5 as Extensions, bs as FROM_REF, bt as FromRefMarker, H as GLProps, a1 as GLTFLike, Y as GlobalEffectType, X as GlobalRenderCallback, a3 as InferLoadResult, W as InjectState, $ as InputLike, aw as IsObject, aa as LegacyInternalState, a9 as LegacyRenderer, ab as LegacyRootState, a2 as LoaderInstance, a0 as LoaderLike, a4 as LoaderResult, ax as MappedTextureType, bw as ONCE, y as OffscreenCanvas, by as OnceValue, aT as Portal, ap as PresetsType, ac as PrimaryCanvasEntry, a$ as REACT_INTERNAL_PROPS, b7 as RESERVED_PROPS, U as RenderProps, A as Renderer, K as RendererConfigExtended, P as RendererProps, aA as Texture, aB as TextureInput, aC as TextureResult, ay as UseTextureOptions, aE as UseTexturesReturn, a6 as WebGLDefaultProps, a7 as WebGLProps, a8 as WebGLShadowConfig, aQ as _roots, aJ as addAfterEffect, aI as addEffect, aK as addTail, aM as advance, bc as applyProps, b9 as attach, b2 as buildGraph, bd as calculateDpr, as as createEvents, u as createPointerEvents, aS as createPortal, aV as createStore, ba as detach, bb as diffProps, b3 as dispose, u as events, aN as extend, b0 as findInitialRoot, aU as flushSync, bu as fromRef, b4 as getInstanceProps, ae as getPrimary, ai as getPrimaryIds, b1 as getRootState, v as getThree, be as getUuidPrefix, br as hasConstructor, ag as hasPrimary, w as hasThree, aL as invalidate, b6 as invalidateInstance, bh as is, bk as isColorRepresentation, bq as isCopyable, bv as isFromRef, bn as isLayers, bl as isObject3D, bz as isOnce, bi as isOrthographicCamera, bj as isRef, aP as isRenderer, bm as isTexture, bo as isUniform, bp as isVectorLike, bx as once, b5 as prepare, ao as presetsObj, aO as reconciler, ad as registerPrimary, ar as removeInteractivity, b8 as resolve, aq as swapInteractivity, aR as unmountComponentAtNode, ah as unregisterPrimary, bf as updateCamera, bg as updateFrustum, aY as useBridge, aH as useEnvironment, au as useGraph, at as useInstanceHandle, aW as useIsomorphicLayoutEffect, av as useLoader, aX as useMutableCallback, az as useTexture, aF as useTextures, af as waitForPrimary, x as whenThree } from '../shared/fiber.Cu2hX1IM.mjs';
5
+ import { C as ConstructorRepresentation, f as RootState, I as InternalState, J as Properties } from '../shared/fiber.I5Q4dVvl.mjs';
6
+ export { U as Act, y as Args, z as ArgsProp, A as AttachFnType, w as AttachType, W as Bridge, i as Camera, x as Catalogue, n as ComputeFunction, a0 as Disposable, k as DomEvent, D as Dpr, $ as EquConfig, l as EventHandlers, p as EventManager, E as Events, u as FiberRoot, m as FilterFunction, ae as ForRegisteredRenderer, a4 as FrameCallback, a3 as FrameNextCallback, a1 as FrameNextState, a2 as FrameState, F as Frameloop, H as HostConfig, G as Instance, B as InstanceProps, h as Intersection, j as IntersectionEvent, L as IsAllOptional, K as IsOptional, M as Mutable, N as NonFunctionKeys, _ as ObjectMap, a7 as OcclusionSupport, O as Overwrite, e as Performance, q as PointerCaptureTarget, P as PointerState, R as R3FRenderTarget, af as R3FRendererSupport, ac as Register, ad as RegisteredRenderer, d as RenderCallback, ab as RendererProvider, aa as RendererSupport, v as Root, a as RootExtension, g as RootStore, Y as SetBlock, c as Size, S as Subscription, Q as ThreeCamera, a6 as ThreeCore, T as ThreeEvent, a5 as ThreeNamespace, Z as UnblockProps, V as Viewport, t as VisibilityEntry, a8 as WebGLSupport, a9 as WebGPUSupport, X as XRManager, o as XRPointerConfig, ai as context, r as registerRootExtension, s as setRenderOverride, ag as useStore } from '../shared/fiber.I5Q4dVvl.mjs';
7
+ import { Texture } from 'three';
8
8
  import { StoreApi } from 'zustand';
9
- import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
10
- import { Options } from 'react-use-measure';
11
- import * as react_jsx_runtime from 'react/jsx-runtime';
12
- import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
13
- import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
14
-
15
- function _mergeNamespaces(n, m) {
16
- m.forEach(function (e) {
17
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
18
- if (k !== 'default' && !(k in n)) {
19
- var d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: function () { return e[k]; }
23
- });
24
- }
25
- });
26
- });
27
- return Object.freeze(n);
28
- }
29
-
30
- /**
31
- * @fileoverview Internal Three.js re-exports - WEBGPU ONLY ENTRY
32
- *
33
- * Pure WebGPU path - no WebGL legacy.
34
- * Use this for the explicit webgpu import path: @react-three/fiber/webgpu
35
- *
36
- * This is for apps that want ONLY WebGPU with no legacy fallback.
37
- * Attempting to use WebGLRenderer will cause type/runtime errors (intentional).
38
- */
39
- declare const R3F_BUILD_LEGACY = false;
40
- declare const R3F_BUILD_WEBGPU = true;
41
-
42
- declare const WebGLRenderer: {
43
- new (): {};
44
- };
45
- type WebGLRendererParameters = never;
46
- type WebGLShadowMap = never;
47
-
48
- declare const WebGLRenderTarget: any;
49
-
50
- var THREE = /*#__PURE__*/_mergeNamespaces({
51
- __proto__: null,
52
- Inspector: Inspector,
53
- R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
54
- R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
55
- RenderTargetCompat: RenderTarget,
56
- WebGLRenderTarget: WebGLRenderTarget,
57
- WebGLRenderer: WebGLRenderer,
58
- WebGLRendererParameters: WebGLRendererParameters,
59
- WebGLShadowMap: WebGLShadowMap
60
- }, [three_webgpu]);
61
-
62
- //* Utility Types ==============================
63
-
64
- type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
65
- type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
66
- type Properties<T> = Pick<T, NonFunctionKeys<T>>
67
- type Mutable<P> = { -readonly [K in keyof P]: P[K] }
68
- type IsOptional<T> = undefined extends T ? true : false
69
- type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
70
- ? IsOptional<First> extends true
71
- ? IsAllOptional<Rest>
72
- : false
73
- : true
74
-
75
- //* Camera Types ==============================
76
-
77
- type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
78
-
79
- //* Act Type ==============================
80
-
81
- type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
82
-
83
- //* Bridge & Block Types ==============================
84
-
85
- type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
86
-
87
- type SetBlock = false | Promise<null> | null
88
- type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
89
-
90
- //* Object Map Type ==============================
91
-
92
- /* Original version
93
- export interface ObjectMap {
94
- nodes: { [name: string]: THREE.Object3D }
95
- materials: { [name: string]: THREE.Material }
96
- meshes: { [name: string]: THREE.Mesh }
97
- }
98
- */
99
- /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
100
- It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
101
- I will keep the use here)
102
- https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
103
- His description is:
104
- The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
105
- */
106
- interface ObjectMap<
107
- T extends { nodes?: string; materials?: string; meshes?: string } = {
108
- nodes: string
109
- materials: string
110
- meshes: string
111
- },
112
- > {
113
- nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
114
- materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
115
- meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
116
- }
117
-
118
- //* Equality Config ==============================
119
-
120
- interface EquConfig {
121
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
122
- arrays?: 'reference' | 'shallow'
123
- /** Compare objects by reference equality a === b (default), or by shallow equality */
124
- objects?: 'reference' | 'shallow'
125
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
126
- strict?: boolean
127
- }
128
-
129
- //* Disposable Type ==============================
130
-
131
- interface Disposable {
132
- type?: string
133
- dispose?: () => void
134
- }
135
-
136
- //* Event-related Types =====================================
137
-
138
- interface Intersection extends THREE$1.Intersection {
139
- /** The event source (the object which registered the handler) */
140
- eventObject: THREE$1.Object3D
141
- }
142
-
143
- type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
144
-
145
- interface IntersectionEvent<TSourceEvent> extends Intersection {
146
- /** The event source (the object which registered the handler) */
147
- eventObject: THREE$1.Object3D
148
- /** An array of intersections */
149
- intersections: Intersection[]
150
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
151
- unprojectedPoint: THREE$1.Vector3
152
- /** Normalized event coordinates */
153
- pointer: THREE$1.Vector2
154
- /** Delta between first click and this event */
155
- delta: number
156
- /** The ray that pierced it */
157
- ray: THREE$1.Ray
158
- /** The camera that was used by the raycaster */
159
- camera: Camera
160
- /** stopPropagation will stop underlying handlers from firing */
161
- stopPropagation: () => void
162
- /** The original host event */
163
- nativeEvent: TSourceEvent
164
- /** If the event was stopped by calling stopPropagation */
165
- stopped: boolean
166
- }
167
-
168
- type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
169
- type DomEvent = PointerEvent | MouseEvent | WheelEvent
170
-
171
- /** DOM event handlers registered on the canvas element */
172
- interface Events {
173
- onClick: EventListener
174
- onContextMenu: EventListener
175
- onDoubleClick: EventListener
176
- onWheel: EventListener
177
- onPointerDown: EventListener
178
- onPointerUp: EventListener
179
- onPointerLeave: EventListener
180
- onPointerMove: EventListener
181
- onPointerCancel: EventListener
182
- onLostPointerCapture: EventListener
183
- onDragEnter: EventListener
184
- onDragLeave: EventListener
185
- onDragOver: EventListener
186
- onDrop: EventListener
187
- }
188
-
189
- /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
190
- interface EventHandlers {
191
- onClick?: (event: ThreeEvent<MouseEvent>) => void
192
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
193
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
194
- /** Fires continuously while dragging over the object */
195
- onDragOver?: (event: ThreeEvent<DragEvent>) => void
196
- /** Fires once when drag enters the object */
197
- onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
198
- /** Fires once when drag leaves the object */
199
- onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
200
- /** Fires when drag misses this object (for objects that have drag handlers) */
201
- onDragOverMissed?: (event: DragEvent) => void
202
- /** Fires when a drop occurs on this object */
203
- onDrop?: (event: ThreeEvent<DragEvent>) => void
204
- /** Fires when a drop misses this object (for objects that have drop handlers) */
205
- onDropMissed?: (event: DragEvent) => void
206
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
207
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
208
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
209
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
210
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
211
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
212
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
213
- onPointerMissed?: (event: MouseEvent) => void
214
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
215
- onWheel?: (event: ThreeEvent<WheelEvent>) => void
216
- onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
217
-
218
- //* Visibility Events --------------------------------
219
- /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
220
- onFramed?: (inView: boolean) => void
221
- /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
222
- onOccluded?: (occluded: boolean) => void
223
- /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
224
- onVisible?: (visible: boolean) => void
225
- }
226
-
227
- type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
228
- type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
229
-
230
- interface EventManager<TTarget> {
231
- /** Determines if the event layer is active */
232
- enabled: boolean
233
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
234
- priority: number
235
- /** The compute function needs to set up the raycaster and an xy- pointer */
236
- compute?: ComputeFunction
237
- /** The filter can re-order or re-structure the intersections */
238
- filter?: FilterFunction
239
- /** The target node the event layer is tied to */
240
- connected?: TTarget
241
- /** All the pointer event handlers through which the host forwards native events */
242
- handlers?: Events
243
- /** Allows re-connecting to another target */
244
- connect?: (target: TTarget) => void
245
- /** Removes all existing events handlers from the target */
246
- disconnect?: () => void
247
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
248
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
249
- */
250
- update?: () => void
251
- }
252
-
253
- interface PointerCaptureTarget {
254
- intersection: Intersection
255
- target: Element
256
- }
257
-
258
- //* Visibility System Types =====================================
259
-
260
- /** Entry in the visibility registry for tracking object visibility state */
261
- interface VisibilityEntry {
262
- object: THREE$1.Object3D
263
- handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
264
- lastFramedState: boolean | null
265
- lastOccludedState: boolean | null
266
- lastVisibleState: boolean | null
267
- }
268
-
269
- //* Scheduler Types (useFrame) ==============================
270
-
271
-
272
-
273
- // Public Options --------------------------------
274
-
275
- /**
276
- * Options for useFrame hook
277
- */
278
- interface UseFrameNextOptions {
279
- /** Optional stable id for the job. Auto-generated if not provided */
280
- id?: string
281
- /** Named phase to run in. Default: 'update' */
282
- phase?: string
283
- /** Run before this phase or job id */
284
- before?: string | string[]
285
- /** Run after this phase or job id */
286
- after?: string | string[]
287
- /** Priority within phase. Higher runs first. Default: 0 */
288
- priority?: number
289
- /** Max frames per second for this job */
290
- fps?: number
291
- /** If true, skip frames when behind. If false, try to catch up. Default: true */
292
- drop?: boolean
293
- /** Enable/disable without unregistering. Default: true */
294
- enabled?: boolean
295
- }
296
-
297
- /** Alias for UseFrameNextOptions */
298
- type UseFrameOptions = UseFrameNextOptions
299
-
300
- /**
301
- * Options for addPhase
302
- */
303
- interface AddPhaseOptions {
304
- /** Insert this phase before the specified phase */
305
- before?: string
306
- /** Insert this phase after the specified phase */
307
- after?: string
308
- }
309
-
310
- // Frame State --------------------------------
311
-
312
- /**
313
- * Timing-only state for independent/outside mode (no RootState)
314
- */
315
- interface FrameTimingState {
316
- /** High-resolution timestamp from RAF (ms) */
317
- time: number
318
- /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
319
- delta: number
320
- /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
321
- elapsed: number
322
- /** Incrementing frame counter */
323
- frame: number
324
- }
325
-
326
- /**
327
- * State passed to useFrame callbacks (extends RootState with timing)
328
- */
329
- interface FrameNextState extends RootState, FrameTimingState {}
330
-
331
- /** Alias for FrameNextState */
332
- type FrameState = FrameNextState
333
-
334
- // Root Options --------------------------------
335
-
336
- /**
337
- * Options for registerRoot
338
- */
339
- interface RootOptions {
340
- /** State provider for callbacks. Optional in independent mode. */
341
- getState?: () => any
342
- /** Error handler for job errors. Falls back to console.error if not provided. */
343
- onError?: (error: Error) => void
344
- }
345
-
346
- // Callback Types --------------------------------
347
-
348
- /**
349
- * Callback function for useFrame
350
- */
351
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
352
-
353
- /** Alias for FrameNextCallback */
354
- type FrameCallback = FrameNextCallback
355
-
356
- // Controls returned from useFrame --------------------------------
357
-
358
- /**
359
- * Controls object returned from useFrame hook
360
- */
361
- interface FrameNextControls {
362
- /** The job's unique ID */
363
- id: string
364
- /** Access to the global scheduler for frame loop control */
365
- scheduler: SchedulerApi
366
- /** Manually step this job only (bypasses FPS limiting) */
367
- step(timestamp?: number): void
368
- /** Manually step ALL jobs in the scheduler */
369
- stepAll(timestamp?: number): void
370
- /** Pause this job (set enabled=false) */
371
- pause(): void
372
- /** Resume this job (set enabled=true) */
373
- resume(): void
374
- /** Reactive paused state - automatically triggers re-render when changed */
375
- isPaused: boolean
376
- }
377
-
378
- /** Alias for FrameNextControls */
379
- type FrameControls = FrameNextControls
380
-
381
- // Scheduler Interface --------------------------------
382
-
383
- /**
384
- * Public interface for the global Scheduler
385
- */
386
- interface SchedulerApi {
387
- //* Phase Management --------------------------------
388
-
389
- /** Add a named phase to the scheduler */
390
- addPhase(name: string, options?: AddPhaseOptions): void
391
- /** Get the ordered list of phase names */
392
- readonly phases: string[]
393
- /** Check if a phase exists */
394
- hasPhase(name: string): boolean
395
-
396
- //* Root Management --------------------------------
397
-
398
- /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
399
- registerRoot(id: string, options?: RootOptions): () => void
400
- /** Unregister a root */
401
- unregisterRoot(id: string): void
402
- /** Generate a unique root ID */
403
- generateRootId(): string
404
- /** Get the number of registered roots */
405
- getRootCount(): number
406
- /** Check if any root is registered and ready */
407
- readonly isReady: boolean
408
- /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
409
- onRootReady(callback: () => void): () => void
410
-
411
- //* Job Registration --------------------------------
412
-
413
- /** Register a job with the scheduler (returns unsubscribe function) */
414
- register(
415
- callback: FrameNextCallback,
416
- options?: {
417
- id?: string
418
- rootId?: string
419
- phase?: string
420
- before?: string | string[]
421
- after?: string | string[]
422
- priority?: number
423
- fps?: number
424
- drop?: boolean
425
- enabled?: boolean
426
- },
427
- ): () => void
428
- /** Update a job's options */
429
- updateJob(
430
- id: string,
431
- options: {
432
- priority?: number
433
- fps?: number
434
- drop?: boolean
435
- enabled?: boolean
436
- phase?: string
437
- before?: string | string[]
438
- after?: string | string[]
439
- },
440
- ): void
441
- /** Unregister a job by ID */
442
- unregister(id: string, rootId?: string): void
443
- /** Get the number of registered jobs */
444
- getJobCount(): number
445
- /** Get all job IDs */
446
- getJobIds(): string[]
447
-
448
- //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
449
-
450
- /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
451
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
452
-
453
- //* Idle Callbacks (for legacy addTail) --------------------------------
454
-
455
- /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
456
- onIdle(callback: (timestamp: number) => void): () => void
457
-
458
- //* Frame Loop Control --------------------------------
459
-
460
- /** Start the scheduler loop */
461
- start(): void
462
- /** Stop the scheduler loop */
463
- stop(): void
464
- /** Check if the scheduler is running */
465
- readonly isRunning: boolean
466
- /** Get/set the frameloop mode ('always', 'demand', 'never') */
467
- frameloop: Frameloop
468
- /** Independent mode - runs without Canvas, callbacks receive timing-only state */
469
- independent: boolean
470
-
471
- //* Manual Stepping --------------------------------
472
-
473
- /** Manually step all jobs once (for frameloop='never' or testing) */
474
- step(timestamp?: number): void
475
- /** Manually step a single job by ID */
476
- stepJob(id: string, timestamp?: number): void
477
- /** Request frame(s) to be rendered (for frameloop='demand') */
478
- invalidate(frames?: number): void
479
-
480
- //* Per-Job Control --------------------------------
481
-
482
- /** Check if a job is paused */
483
- isJobPaused(id: string): boolean
484
- /** Pause a job */
485
- pauseJob(id: string): void
486
- /** Resume a job */
487
- resumeJob(id: string): void
488
- /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
489
- subscribeJobState(id: string, listener: () => void): () => void
490
- }
491
-
492
- //* Renderer Types ========================================
493
-
494
- /** Default renderer type - union of WebGL and WebGPU renderers */
495
- type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
496
-
497
- //* Core Store Types ========================================
498
-
499
- type Subscription = {
500
- ref: React$1.RefObject<RenderCallback>
501
- priority: number
502
- store: RootStore
503
- }
504
-
505
- type Dpr = number | [min: number, max: number]
506
-
507
- interface Size {
508
- width: number
509
- height: number
510
- top: number
511
- left: number
512
- }
513
-
514
- type Frameloop = 'always' | 'demand' | 'never'
515
-
516
- interface Viewport extends Size {
517
- /** The initial pixel ratio */
518
- initialDpr: number
519
- /** Current pixel ratio */
520
- dpr: number
521
- /** size.width / viewport.width */
522
- factor: number
523
- /** Camera distance */
524
- distance: number
525
- /** Camera aspect ratio: width / height */
526
- aspect: number
527
- }
528
-
529
- type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
530
-
531
- interface Performance {
532
- /** Current performance normal, between min and max */
533
- current: number
534
- /** How low the performance can go, between 0 and max */
535
- min: number
536
- /** How high the performance can go, between min and max */
537
- max: number
538
- /** Time until current returns to max in ms */
539
- debounce: number
540
- /** Sets current to min, puts the system in regression */
541
- regress: () => void
542
- }
543
-
544
- interface InternalState {
545
- interaction: THREE$1.Object3D[]
546
- hovered: Map<string, ThreeEvent<DomEvent>>
547
- subscribers: Subscription[]
548
- capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
549
- initialClick: [x: number, y: number]
550
- initialHits: THREE$1.Object3D[]
551
- lastEvent: React$1.RefObject<DomEvent | null>
552
- /** Visibility event registry (onFramed, onOccluded, onVisible) */
553
- visibilityRegistry: Map<string, VisibilityEntry>
554
- /** Whether occlusion queries are enabled (WebGPU only) */
555
- occlusionEnabled: boolean
556
- /** Reference to the invisible occlusion observer mesh */
557
- occlusionObserver: THREE$1.Mesh | null
558
- /** Cached occlusion results from render pass - keyed by Object3D */
559
- occlusionCache: Map<THREE$1.Object3D, boolean | null>
560
- /** Internal helper group for R3F system objects (occlusion observer, etc.) */
561
- helperGroup: THREE$1.Group | null
562
- active: boolean
563
- priority: number
564
- frames: number
565
- subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
566
- /** Internal renderer storage - use state.renderer or state.gl to access */
567
- actualRenderer: R3FRenderer
568
- /** Global scheduler reference (for useFrame hook) */
569
- scheduler: SchedulerApi | null
570
- /** This root's unique ID in the global scheduler */
571
- rootId?: string
572
- /** Function to unregister this root from the global scheduler */
573
- unregisterRoot?: () => void
574
- /** Container for child attachment (scene for root, original container for portals) */
575
- container?: THREE$1.Object3D
576
- /**
577
- * CanvasTarget for multi-canvas WebGPU rendering.
578
- * Created for all WebGPU canvases to support renderer sharing.
579
- * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
580
- */
581
- canvasTarget?: CanvasTarget
582
- /**
583
- * Whether multi-canvas rendering is active.
584
- * True when any canvas uses `target` prop to share a renderer.
585
- * When true, setCanvasTarget is called before each render.
586
- */
587
- isMultiCanvas?: boolean
588
- /**
589
- * Whether this canvas is a secondary canvas sharing another's renderer.
590
- * True when `target` prop is used.
591
- */
592
- isSecondary?: boolean
593
- /**
594
- * The id of the primary canvas this secondary canvas targets.
595
- * Only set when isSecondary is true.
596
- */
597
- targetId?: string
598
- /**
599
- * Function to unregister this primary canvas from the registry.
600
- * Only set when this canvas has an `id` prop.
601
- */
602
- unregisterPrimary?: () => void
603
- /** Whether canvas dimensions are forced to even numbers */
604
- forceEven?: boolean
605
- }
606
-
607
- interface XRManager {
608
- connect: () => void
609
- disconnect: () => void
610
- }
611
-
612
- //* Root State Interface ====================================
613
-
614
- interface RootState {
615
- /** Set current state */
616
- set: StoreApi<RootState>['setState']
617
- /** Get current state */
618
- get: StoreApi<RootState>['getState']
619
- /**
620
- * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
621
- * - For primary/independent canvases: points to its own store (self-reference)
622
- * - For secondary canvases: points to the primary canvas's store
623
- *
624
- * Hooks like useNodes/useUniforms should read from primaryStore to ensure
625
- * consistent shared state across all canvases sharing a renderer.
626
- */
627
- primaryStore: RootStore
628
- /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
629
- gl: THREE$1.WebGLRenderer
630
- /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
631
- renderer: R3FRenderer
632
- /** Inspector of the webGPU Renderer. Init in the canvas */
633
- inspector: any // Inspector type from three/webgpu
634
-
635
- /** Default camera */
636
- camera: ThreeCamera
637
- /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
638
- frustum: THREE$1.Frustum
639
- /** Whether to automatically update the frustum each frame (default: true) */
640
- autoUpdateFrustum: boolean
641
- /** Default scene (may be overridden in portals to point to the portal container) */
642
- scene: THREE$1.Scene
643
- /** The actual root THREE.Scene - always points to the true scene, even inside portals */
644
- rootScene: THREE$1.Scene
645
- /** Default raycaster */
646
- raycaster: THREE$1.Raycaster
647
- /** Event layer interface, contains the event handler and the node they're connected to */
648
- events: EventManager<any>
649
- /** XR interface */
650
- xr: XRManager
651
- /** Currently used controls */
652
- controls: THREE$1.EventDispatcher | null
653
- /** Normalized event coordinates */
654
- pointer: THREE$1.Vector2
655
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
656
- mouse: THREE$1.Vector2
657
- /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
658
- textureColorSpace: THREE$1.ColorSpace
659
- /** Render loop flags */
660
- frameloop: Frameloop
661
- performance: Performance
662
- /** Reactive pixel-size of the canvas */
663
- size: Size
664
- /** Reactive size of the viewport in threejs units */
665
- viewport: Viewport & {
666
- getCurrentViewport: (
667
- camera?: ThreeCamera,
668
- target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
669
- size?: Size,
670
- ) => Omit<Viewport, 'dpr' | 'initialDpr'>
671
- }
672
- /** Flags the canvas for render, but doesn't render in itself */
673
- invalidate: (frames?: number, stackFrames?: boolean) => void
674
- /** Advance (render) one step */
675
- advance: (timestamp: number, runGlobalEffects?: boolean) => void
676
- /** Shortcut to setting the event layer */
677
- setEvents: (events: Partial<EventManager<any>>) => void
678
- /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
679
- setSize: (width?: number, height?: number, top?: number, left?: number) => void
680
- /** Shortcut to manual setting the pixel ratio */
681
- setDpr: (dpr: Dpr) => void
682
- /** Shortcut to setting frameloop flags */
683
- setFrameloop: (frameloop: Frameloop) => void
684
- /** Set error state to propagate to error boundary */
685
- setError: (error: Error | null) => void
686
- /** Current error state (null when no error) */
687
- error: Error | null
688
- /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
689
- uniforms: UniformStore
690
- /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
691
- nodes: Record<string, any>
692
- /** Global TSL texture nodes - use useTextures() hook for operations */
693
- textures: Map<string, any>
694
- /** WebGPU PostProcessing instance - use usePostProcessing() hook */
695
- postProcessing: any | null // THREE.PostProcessing when available
696
- /** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
697
- passes: Record<string, any>
698
- /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
699
- _hmrVersion: number
700
- /** Internal: whether setSize() has taken ownership of canvas dimensions */
701
- _sizeImperative: boolean
702
- /** Internal: stored size props from Canvas for reset functionality */
703
- _sizeProps: { width?: number; height?: number } | null
704
- /** When the canvas was clicked but nothing was hit */
705
- onPointerMissed?: (event: MouseEvent) => void
706
- /** When a dragover event has missed any target */
707
- onDragOverMissed?: (event: DragEvent) => void
708
- /** When a drop event has missed any target */
709
- onDropMissed?: (event: DragEvent) => void
710
- /** If this state model is layered (via createPortal) then this contains the previous layer */
711
- previousRoot?: RootStore
712
- /** Internals */
713
- internal: InternalState
714
- // flags for triggers
715
- // if we are using the webGl renderer, this will be true
716
- isLegacy: boolean
717
- // regardless of renderer, if the system supports webGpu, this will be true
718
- webGPUSupported: boolean
719
- //if we are on native
720
- isNative: boolean
721
- }
722
-
723
- type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
724
-
725
- //* Base Renderer Types =====================================
726
-
727
- // Shim for OffscreenCanvas since it was removed from DOM types
728
- interface OffscreenCanvas$1 extends EventTarget {}
729
-
730
- interface BaseRendererProps {
731
- canvas: HTMLCanvasElement | OffscreenCanvas$1
732
- powerPreference?: 'high-performance' | 'low-power' | 'default'
733
- antialias?: boolean
734
- alpha?: boolean
735
- }
736
-
737
- type RendererFactory<TRenderer, TParams> =
738
- | TRenderer
739
- | ((defaultProps: TParams) => TRenderer)
740
- | ((defaultProps: TParams) => Promise<TRenderer>)
741
-
742
- interface Renderer {
743
- render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
744
- }
745
-
746
- //* WebGL Renderer Props ==============================
747
-
748
- type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
749
- canvas: HTMLCanvasElement | OffscreenCanvas$1
750
- }
751
-
752
- type GLProps =
753
- | Renderer
754
- | ((defaultProps: DefaultGLProps) => Renderer)
755
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
756
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
757
-
758
- //* WebGPU Renderer Props ==============================
759
-
760
- type DefaultRendererProps = {
761
- canvas: HTMLCanvasElement | OffscreenCanvas$1
762
- [key: string]: any
763
- }
764
-
765
- /**
766
- * Canvas-level scheduler configuration.
767
- * Controls render timing relative to other canvases.
768
- */
769
- interface CanvasSchedulerConfig {
770
- /**
771
- * Render this canvas after another canvas completes.
772
- * Pass the `id` of another canvas.
773
- */
774
- after?: string
775
- /**
776
- * Limit this canvas's render rate (frames per second).
777
- */
778
- fps?: number
779
- }
780
-
781
- /**
782
- * Extended renderer configuration for multi-canvas support.
783
- */
784
- interface RendererConfigExtended {
785
- /** Share renderer from another canvas (WebGPU only) */
786
- primaryCanvas?: string
787
- /** Canvas-level scheduler options */
788
- scheduler?: CanvasSchedulerConfig
789
- }
790
-
791
- type RendererProps =
792
- | any // WebGPURenderer
793
- | ((defaultProps: DefaultRendererProps) => any)
794
- | ((defaultProps: DefaultRendererProps) => Promise<any>)
795
- | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
796
-
797
- //* Camera Props ==============================
798
-
799
- type CameraProps = (
800
- | THREE$1.Camera
801
- | Partial<
802
- ThreeElement<typeof THREE$1.Camera> &
803
- ThreeElement<typeof THREE$1.PerspectiveCamera> &
804
- ThreeElement<typeof THREE$1.OrthographicCamera>
805
- >
806
- ) & {
807
- /** Flags the camera as manual, putting projection into your own hands */
808
- manual?: boolean
809
- }
810
-
811
- //* Render Props ==============================
812
-
813
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
814
- /**
815
- * Unique identifier for multi-canvas renderer sharing.
816
- * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
817
- * Also sets the HTML `id` attribute on the canvas element.
818
- * @example <Canvas id="main-viewer">...</Canvas>
819
- */
820
- id?: string
821
- /**
822
- * Share the renderer from another canvas instead of creating a new one.
823
- * Pass the `id` of the primary canvas to share its WebGPURenderer.
824
- * Only available with WebGPU (not legacy WebGL).
825
- *
826
- * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
827
- * @internal
828
- */
829
- primaryCanvas?: string
830
- /**
831
- * Canvas-level scheduler options. Controls render timing relative to other canvases.
832
- *
833
- * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
834
- * @internal
835
- */
836
- scheduler?: CanvasSchedulerConfig
837
- /** A threejs renderer instance or props that go into the default renderer */
838
- gl?: GLProps
839
- /** A WebGPU renderer instance or props that go into the default renderer */
840
- renderer?: RendererProps
841
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
842
- size?: Size
843
- /**
844
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
845
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
846
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
847
- */
848
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
849
- /** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
850
- textureColorSpace?: THREE$1.ColorSpace
851
- /** Creates an orthographic camera */
852
- orthographic?: boolean
853
- /**
854
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
855
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
856
- */
857
- frameloop?: Frameloop
858
- /**
859
- * R3F performance options for adaptive performance.
860
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
861
- */
862
- performance?: Partial<Omit<Performance, 'regress'>>
863
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
864
- dpr?: Dpr
865
- /** Props that go into the default raycaster */
866
- raycaster?: Partial<THREE$1.Raycaster>
867
- /** A `THREE.Scene` instance or props that go into the default scene */
868
- scene?: THREE$1.Scene | Partial<THREE$1.Scene>
869
- /** A `THREE.Camera` instance or props that go into the default camera */
870
- camera?: CameraProps
871
- /** An R3F event manager to manage elements' pointer events */
872
- events?: (store: RootStore) => EventManager<HTMLElement>
873
- /** Callback after the canvas has rendered (but not yet committed) */
874
- onCreated?: (state: RootState) => void
875
- /** Response for pointer clicks that have missed any target */
876
- onPointerMissed?: (event: MouseEvent) => void
877
- /** Response for dragover events that have missed any target */
878
- onDragOverMissed?: (event: DragEvent) => void
879
- /** Response for drop events that have missed any target */
880
- onDropMissed?: (event: DragEvent) => void
881
- /** Whether to automatically update the frustum each frame (default: true) */
882
- autoUpdateFrustum?: boolean
883
- /**
884
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
885
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
886
- * Only works with WebGPU renderer - WebGL will log a warning.
887
- */
888
- occlusion?: boolean
889
- /** Internal: stored size props from Canvas for reset functionality */
890
- _sizeProps?: { width?: number; height?: number } | null
891
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
892
- forceEven?: boolean
893
- }
894
-
895
- //* Reconciler Root ==============================
896
-
897
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
898
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
899
- render: (element: ReactNode) => RootStore
900
- unmount: () => void
901
- }
902
-
903
- //* Inject State ==============================
904
-
905
- type InjectState = Partial<
906
- Omit<RootState, 'events'> & {
907
- events?: {
908
- enabled?: boolean
909
- priority?: number
910
- compute?: ComputeFunction
911
- connected?: any
912
- }
913
- /**
914
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
915
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
916
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
917
- */
918
- injectScene?: boolean
919
- }
920
- >
921
-
922
- //* Reconciler Types ==============================
923
-
924
- // FiberRoot is an opaque internal React type - we define it locally
925
- // to avoid bundling @types/react-reconciler which causes absolute path issues
926
- type FiberRoot = any
927
-
928
- interface Root {
929
- fiber: FiberRoot
930
- store: RootStore
931
- }
932
-
933
- type AttachFnType<O = any> = (parent: any, self: O) => () => void
934
- type AttachType<O = any> = string | AttachFnType<O>
935
-
936
- type ConstructorRepresentation<T = any> = new (...args: any[]) => T
937
-
938
- interface Catalogue {
939
- [name: string]: ConstructorRepresentation
940
- }
941
-
942
- // TODO: handle constructor overloads
943
- // https://github.com/pmndrs/react-three-fiber/pull/2931
944
- // https://github.com/microsoft/TypeScript/issues/37079
945
- type Args<T> = T extends ConstructorRepresentation
946
- ? T extends typeof Color$1
947
- ? [r: number, g: number, b: number] | [color: ColorRepresentation]
948
- : ConstructorParameters<T>
949
- : any[]
950
-
951
- type ArgsProp<P> = P extends ConstructorRepresentation
952
- ? IsAllOptional<ConstructorParameters<P>> extends true
953
- ? { args?: Args<P> }
954
- : { args: Args<P> }
955
- : { args: unknown[] }
956
-
957
- type InstanceProps<T = any, P = any> = ArgsProp<P> & {
958
- object?: T
959
- dispose?: null
960
- attach?: AttachType<T>
961
- onUpdate?: (self: T) => void
962
- }
963
-
964
- interface Instance<O = any> {
965
- root: RootStore
966
- type: string
967
- parent: Instance | null
968
- children: Instance[]
969
- props: InstanceProps<O> & Record<string, unknown>
970
- object: O & { __r3f?: Instance<O> }
971
- eventCount: number
972
- handlers: Partial<EventHandlers>
973
- attach?: AttachType<O>
974
- previousAttach?: any
975
- isHidden: boolean
976
- /** Deferred ref props to apply in commitMount */
977
- deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
978
- /** Set of props that have been applied via once() */
979
- appliedOnce?: Set<string>
980
- }
981
-
982
- interface HostConfig {
983
- type: string
984
- props: Instance['props']
985
- container: RootStore
986
- instance: Instance
987
- textInstance: void
988
- suspenseInstance: Instance
989
- hydratableInstance: never
990
- formInstance: never
991
- publicInstance: Instance['object']
992
- hostContext: {}
993
- childSet: never
994
- timeoutHandle: number | undefined
995
- noTimeout: -1
996
- TransitionStatus: null
997
- }
998
- declare global {
999
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
1000
- }
1001
-
1002
- //* Loop Types ==============================
1003
-
1004
- type GlobalRenderCallback = (timestamp: number) => void
1005
-
1006
- type GlobalEffectType = 'before' | 'after' | 'tail'
1007
-
1008
- declare const presetsObj: {
1009
- apartment: string;
1010
- city: string;
1011
- dawn: string;
1012
- forest: string;
1013
- lobby: string;
1014
- night: string;
1015
- park: string;
1016
- studio: string;
1017
- sunset: string;
1018
- warehouse: string;
1019
- };
1020
- type PresetsType = keyof typeof presetsObj;
1021
-
1022
- //* Background Types ==============================
1023
-
1024
- /**
1025
- * Expanded object form for background configuration.
1026
- * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
1027
- */
1028
- interface BackgroundConfig {
1029
- /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
1030
- preset?: PresetsType
1031
- /** Files for cube texture (6 faces) or single HDR/EXR */
1032
- files?: string | string[]
1033
- /** Separate files for scene.background (visual backdrop) */
1034
- backgroundMap?: string | string[]
1035
- backgroundRotation?: Euler$1 | [number, number, number]
1036
- backgroundBlurriness?: number
1037
- backgroundIntensity?: number
1038
- /** Separate files for scene.environment (PBR lighting/reflections) */
1039
- envMap?: string | string[]
1040
- environmentRotation?: Euler$1 | [number, number, number]
1041
- environmentIntensity?: number
1042
- path?: string
1043
- extensions?: (loader: Loader) => void
1044
- }
1045
-
1046
- /**
1047
- * Background prop type for Canvas.
1048
- *
1049
- * String detection priority:
1050
- * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1051
- * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
1052
- * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
1053
- *
1054
- * @example Color
1055
- * ```tsx
1056
- * <Canvas background="red" />
1057
- * <Canvas background="#ff0000" />
1058
- * <Canvas background={0xff0000} />
1059
- * ```
1060
- *
1061
- * @example Preset
1062
- * ```tsx
1063
- * <Canvas background="city" />
1064
- * ```
1065
- *
1066
- * @example URL
1067
- * ```tsx
1068
- * <Canvas background="/path/to/env.hdr" />
1069
- * <Canvas background="./sky.jpg" />
1070
- * ```
1071
- *
1072
- * @example Object form
1073
- * ```tsx
1074
- * <Canvas background={{
1075
- * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1076
- * backgroundMap: 'path/to/sky.jpg',
1077
- * envMap: 'path/to/lighting.hdr',
1078
- * backgroundBlurriness: 0.5,
1079
- * }} />
1080
- * ```
1081
- */
1082
- type BackgroundProp =
1083
- | ColorRepresentation // "red", "#ff0000", 0xff0000
1084
- | string // URL or preset
1085
- | BackgroundConfig // Expanded object form
1086
-
1087
- //* Canvas Types ==============================
1088
-
1089
- interface CanvasProps
1090
- extends
1091
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1092
- React$1.HTMLAttributes<HTMLDivElement> {
1093
- children?: React$1.ReactNode
1094
- ref?: React$1.Ref<HTMLCanvasElement>
1095
- /** Canvas fallback content, similar to img's alt prop */
1096
- fallback?: React$1.ReactNode
1097
- /**
1098
- * Options to pass to useMeasure.
1099
- * @see https://github.com/pmndrs/react-use-measure#api
1100
- */
1101
- resize?: Options
1102
- /** The target where events are being subscribed to, default: the div that wraps canvas */
1103
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
1104
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1105
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1106
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1107
- hmr?: boolean
1108
- /** Canvas resolution width in pixels. If omitted, uses container width. */
1109
- width?: number
1110
- /** Canvas resolution height in pixels. If omitted, uses container height. */
1111
- height?: number
1112
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1113
- forceEven?: boolean
1114
- /**
1115
- * Scene background configuration.
1116
- * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1117
- * @see BackgroundProp for full documentation and examples
1118
- */
1119
- background?: BackgroundProp
1120
- }
1121
-
1122
- //* Loader Types ==============================
1123
-
1124
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1125
-
1126
- // Define a loader-like interface that matches THREE.Loader's load signature
1127
- // This works for both generic and non-generic THREE.Loader instances
1128
- interface LoaderLike {
1129
- load(
1130
- url: InputLike,
1131
- onLoad?: (result: any) => void,
1132
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
1133
- onError?: (error: unknown) => void,
1134
- ): any
1135
- }
1136
-
1137
- type GLTFLike = { scene: THREE$1.Object3D }
1138
-
1139
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1140
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1141
-
1142
- // Infer result type from the load method's callback parameter
1143
- type InferLoadResult<T> = T extends {
1144
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1145
- }
1146
- ? R
1147
- : T extends ConstructorRepresentation<any>
1148
- ? InstanceType<T> extends {
1149
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1150
- }
1151
- ? R
1152
- : any
1153
- : any
1154
-
1155
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1156
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1157
-
1158
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1159
- loader: LoaderInstance<T>,
1160
- ) => void
1161
-
1162
- //* Renderer Props ========================================
1163
-
1164
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1165
-
1166
- type WebGLProps =
1167
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1168
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1169
-
1170
- interface WebGLShadowConfig {
1171
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1172
- }
1173
-
1174
- //* Legacy-specific Types ========================================
1175
-
1176
- /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1177
- type LegacyRenderer = THREE$1.WebGLRenderer
1178
-
1179
- /** Legacy internal state with narrowed renderer type */
1180
- interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1181
- actualRenderer: THREE$1.WebGLRenderer
1182
- }
1183
-
1184
- /**
1185
- * Legacy-specific RootState with narrowed renderer type.
1186
- * Automatically used when importing from `@react-three/fiber/legacy`.
1187
- *
1188
- * @example
1189
- * ```tsx
1190
- * import { useThree } from '@react-three/fiber/legacy'
1191
- *
1192
- * function MyComponent() {
1193
- * const { renderer } = useThree()
1194
- * // renderer is typed as THREE.WebGLRenderer
1195
- * renderer.shadowMap.enabled = true
1196
- * }
1197
- * ```
1198
- */
1199
- interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1200
- /** The WebGL renderer instance */
1201
- renderer: THREE$1.WebGLRenderer
1202
- /** Internals with WebGL renderer */
1203
- internal: LegacyInternalState
1204
- }
1205
-
1206
- //* RenderTarget Types ==============================
1207
-
1208
-
1209
- type RenderTargetOptions = RenderTargetOptions$1
1210
-
1211
- //* Global Types ==============================
1212
-
1213
- declare global {
1214
- /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
1215
- interface UniformNode<T = unknown> extends Node {
1216
- value: T
1217
- }
1218
-
1219
- /**
1220
- * ShaderCallable - the return type of Fn()
1221
- * A callable shader function node that can be invoked with parameters.
1222
- * The function returns a ShaderNodeObject when called.
1223
- *
1224
- * @example
1225
- * ```tsx
1226
- * // Define a shader function
1227
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1228
- * return mix(color1, color2, factor)
1229
- * })
1230
- *
1231
- * // Type when retrieving from nodes store
1232
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1233
- *
1234
- * // Or with specific return type
1235
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1236
- * ```
1237
- */
1238
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1239
-
1240
- /**
1241
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1242
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1243
- *
1244
- * @example
1245
- * ```tsx
1246
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1247
- * ```
1248
- */
1249
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1250
-
1251
- /**
1252
- * TSLNodeType - Union of all common TSL node types
1253
- * Used by ScopedStore to properly type node access from the store.
1254
- *
1255
- * Includes:
1256
- * - Node: base Three.js node type
1257
- * - ShaderCallable: function nodes created with Fn()
1258
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1259
- *
1260
- * @example
1261
- * ```tsx
1262
- * // In useLocalNodes, nodes are typed as TSLNodeType
1263
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1264
- * positionNode: nodes.myPosition, // Works - Node is in union
1265
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1266
- * }))
1267
- *
1268
- * // Can narrow with type guard or assertion when needed
1269
- * if (typeof blendColorFn === 'function') {
1270
- * blendColorFn(someColor, 0.5)
1271
- * }
1272
- * ```
1273
- */
1274
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1275
-
1276
- /** Flat record of uniform nodes (no nested scopes) */
1277
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1278
-
1279
- /**
1280
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
1281
- * Used by state.uniforms which has structure like:
1282
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1283
- */
1284
- type UniformStore = Record<string, UniformNode | UniformRecord>
1285
-
1286
- /**
1287
- * Helper to safely access a uniform node from the store.
1288
- * Use this when accessing state.uniforms to get proper typing.
1289
- * @example
1290
- * const uTime = uniforms.uTime as UniformNode<number>
1291
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1292
- */
1293
- type GetUniform<T = unknown> = UniformNode<T>
1294
-
1295
- /**
1296
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1297
- * Supports:
1298
- * - Primitives: number, string (color), boolean
1299
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1300
- * - Plain objects: { x, y, z, w } converted to vectors
1301
- * - TSL nodes: color(), vec3(), float() for type casting
1302
- * - UniformNode: existing uniforms (reused as-is)
1303
- */
1304
- type UniformValue =
1305
- | number
1306
- | string
1307
- | boolean
1308
- | three_webgpu.Color
1309
- | three_webgpu.Vector2
1310
- | three_webgpu.Vector3
1311
- | three_webgpu.Vector4
1312
- | three_webgpu.Matrix3
1313
- | three_webgpu.Matrix4
1314
- | three_webgpu.Euler
1315
- | three_webgpu.Quaternion
1316
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1317
- | Node // TSL nodes like color(), vec3(), float() for type casting
1318
- | UniformNode
1319
-
1320
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1321
- type UniformInputRecord = Record<string, UniformValue>
1322
- }
1323
-
1324
- //* Module Augmentation ==============================
1325
-
1326
- declare module 'three/tsl' {
1327
- /**
1328
- * Fn with array parameter destructuring
1329
- * @example Fn(([uv, skew]) => { ... })
1330
- */
1331
- export function Fn<R extends Node = Node>(
1332
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1333
- ): ShaderCallable<R>
1334
-
1335
- /**
1336
- * Fn with object parameter destructuring
1337
- * @example Fn(({ color, intensity }) => { ... })
1338
- */
1339
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1340
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1341
- ): ShaderCallable<R>
1342
-
1343
- /**
1344
- * Fn with array params + layout
1345
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1346
- */
1347
- export function Fn<R extends Node = Node>(
1348
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1349
- layout: { layout?: unknown },
1350
- ): ShaderCallable<R>
1351
-
1352
- /**
1353
- * Fn with object params + layout
1354
- */
1355
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1356
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1357
- layout: { layout?: unknown },
1358
- ): ShaderCallable<R>
1359
- }
1360
-
1361
- /**
1362
- * PostProcessing Types for usePostProcessing hook (WebGPU only)
1363
- */
1364
-
1365
-
1366
-
1367
- declare global {
1368
- /** Pass record - stores TSL pass nodes for post-processing */
1369
- type PassRecord = Record<string, any>
1370
-
1371
- /** Setup callback - runs first to configure MRT, create additional passes */
1372
- type PostProcessingSetupCallback = (state: RootState) => PassRecord | void
1373
-
1374
- /** Main callback - runs second to configure outputNode, create effect passes */
1375
- type PostProcessingMainCallback = (state: RootState) => PassRecord | void
1376
-
1377
- /** Return type for usePostProcessing hook */
1378
- interface UsePostProcessingReturn {
1379
- /** Current passes from state */
1380
- passes: PassRecord
1381
- /** PostProcessing instance (null if not initialized) */
1382
- postProcessing: any | null // THREE.PostProcessing
1383
- /** Clear all passes from state */
1384
- clearPasses: () => void
1385
- /** Reset PostProcessing entirely (clears PP + passes) */
1386
- reset: () => void
1387
- /** Re-run setup/main callbacks with current closure values */
1388
- rebuild: () => void
1389
- /** True when PostProcessing is configured and ready */
1390
- isReady: boolean
1391
- }
1392
- }
1393
-
1394
- //* useFrameNext Types ==============================
1395
-
1396
-
1397
-
1398
- //* Global Type Declarations ==============================
1399
-
1400
- declare global {
1401
- // Job --------------------------------
1402
-
1403
- /**
1404
- * Internal job representation in the scheduler
1405
- */
1406
- interface Job {
1407
- /** Unique identifier */
1408
- id: string
1409
- /** The callback to execute */
1410
- callback: FrameNextCallback
1411
- /** Phase this job belongs to */
1412
- phase: string
1413
- /** Run before these phases/job ids */
1414
- before: Set<string>
1415
- /** Run after these phases/job ids */
1416
- after: Set<string>
1417
- /** Priority within phase (higher first) */
1418
- priority: number
1419
- /** Insertion order for deterministic tie-breaking */
1420
- index: number
1421
- /** Max FPS for this job (undefined = no limit) */
1422
- fps?: number
1423
- /** Drop frames when behind (true) or catch up (false) */
1424
- drop: boolean
1425
- /** Last run timestamp (ms) */
1426
- lastRun?: number
1427
- /** Whether job is enabled */
1428
- enabled: boolean
1429
- /** Internal flag: system jobs (like default render) don't block user render takeover */
1430
- system?: boolean
1431
- }
1432
-
1433
- // Phase Graph --------------------------------
1434
-
1435
- /**
1436
- * A node in the phase graph
1437
- */
1438
- interface PhaseNode {
1439
- /** Phase name */
1440
- name: string
1441
- /** Whether this was auto-generated from a before/after constraint */
1442
- isAutoGenerated: boolean
1443
- }
1444
-
1445
- /**
1446
- * Options for creating a job from hook options
1447
- */
1448
- interface JobOptions {
1449
- id?: string
1450
- phase?: string
1451
- before?: string | string[]
1452
- after?: string | string[]
1453
- priority?: number
1454
- fps?: number
1455
- drop?: boolean
1456
- enabled?: boolean
1457
- }
1458
-
1459
- // Frame Loop State --------------------------------
1460
-
1461
- /**
1462
- * Internal frame loop state
1463
- */
1464
- interface FrameLoopState {
1465
- /** Whether the loop is running */
1466
- running: boolean
1467
- /** Current RAF handle */
1468
- rafHandle: number | null
1469
- /** Last frame timestamp in ms (null = uninitialized) */
1470
- lastTime: number | null
1471
- /** Frame counter */
1472
- frameCount: number
1473
- /** Elapsed time since first frame in ms */
1474
- elapsedTime: number
1475
- /** createdAt timestamp in ms */
1476
- createdAt: number
1477
- }
1478
-
1479
- // Root Entry --------------------------------
1480
-
1481
- /**
1482
- * Internal representation of a registered root (Canvas).
1483
- * Tracks jobs and manages rebuild state for this root.
1484
- * @internal
1485
- */
1486
- interface RootEntry {
1487
- /** Unique identifier for this root */
1488
- id: string
1489
- /** Function to get the root's current state. Returns any to support independent mode. */
1490
- getState: () => any
1491
- /** Map of job IDs to Job objects */
1492
- jobs: Map<string, Job>
1493
- /** Cached sorted job list for execution order */
1494
- sortedJobs: Job[]
1495
- /** Whether sortedJobs needs rebuilding */
1496
- needsRebuild: boolean
1497
- }
1498
-
1499
- /**
1500
- * Internal representation of a global job (deprecated API).
1501
- * Global jobs run once per frame, not per-root.
1502
- * Used by legacy addEffect/addAfterEffect APIs.
1503
- * @internal
1504
- * @deprecated Use useFrame with phases instead
1505
- */
1506
- interface GlobalJob {
1507
- /** Unique identifier for this global job */
1508
- id: string
1509
- /** Callback invoked with RAF timestamp in ms */
1510
- callback: (timestamp: number) => void
1511
- }
1512
-
1513
- // HMR Support --------------------------------
1514
-
1515
- /**
1516
- * Hot Module Replacement data structure for preserving scheduler state
1517
- * @internal
1518
- */
1519
- interface HMRData {
1520
- /** Shared data object for storing values across reloads */
1521
- data: Record<string, any>
1522
- /** Optional function to accept HMR updates */
1523
- accept?: () => void
1524
- }
1525
-
1526
- // Default Phases --------------------------------
1527
-
1528
- /**
1529
- * Default phase names for the scheduler
1530
- */
1531
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1532
- }
1533
-
1534
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1535
-
1536
- interface MathRepresentation {
1537
- set(...args: number[]): any
1538
- }
1539
- interface VectorRepresentation extends MathRepresentation {
1540
- setScalar(value: number): any
1541
- }
1542
- type MathTypes = MathRepresentation | Euler$2 | Color$2
1543
-
1544
- type MathType<T extends MathTypes> = T extends Color$2
1545
- ? Args<typeof Color$2> | ColorRepresentation$1
1546
- : T extends VectorRepresentation | Layers$1 | Euler$2
1547
- ? T | MutableOrReadonlyParameters<T['set']> | number
1548
- : T | MutableOrReadonlyParameters<T['set']>
1549
-
1550
- type MathProps<P> = {
1551
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1552
- }
1553
-
1554
- type Vector2 = MathType<Vector2$1>
1555
- type Vector3 = MathType<Vector3$1>
1556
- type Vector4 = MathType<Vector4$1>
1557
- type Color = MathType<Color$2>
1558
- type Layers = MathType<Layers$1>
1559
- type Quaternion = MathType<Quaternion$1>
1560
- type Euler = MathType<Euler$2>
1561
- type Matrix3 = MathType<Matrix3$1>
1562
- type Matrix4 = MathType<Matrix4$1>
1563
-
1564
- interface RaycastableRepresentation {
1565
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1566
- }
1567
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1568
-
1569
- /**
1570
- * Props for geometry transform methods that can be called with `once()`.
1571
- * These methods modify the geometry in-place and only make sense to call once on mount.
1572
- *
1573
- * @example
1574
- * import { once } from '@react-three/fiber'
1575
- *
1576
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1577
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1578
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1579
- */
1580
- interface GeometryTransformProps {
1581
- /** Rotate the geometry about the X axis (radians). Use with once(). */
1582
- rotateX?: number
1583
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
1584
- rotateY?: number
1585
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
1586
- rotateZ?: number
1587
- /** Translate the geometry (x, y, z). Use with once(). */
1588
- translate?: [x: number, y: number, z: number]
1589
- /** Scale the geometry (x, y, z). Use with once(). */
1590
- scale?: [x: number, y: number, z: number]
1591
- /** Center the geometry based on bounding box. Use with once(). */
1592
- center?: true
1593
- /** Apply a Matrix4 transformation. Use with once(). */
1594
- applyMatrix4?: Matrix4$1
1595
- /** Apply a Quaternion rotation. Use with once(). */
1596
- applyQuaternion?: Quaternion$1
1597
- }
1598
-
1599
- type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
1600
-
1601
- /**
1602
- * Workaround for @types/three TSL node type issues.
1603
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1604
- * This transforms `Node | null` properties to accept any object with node-like shape.
1605
- */
1606
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1607
-
1608
- /**
1609
- * For node material properties (colorNode, positionNode, etc.), accept broader types
1610
- * since @types/three has broken inheritance for TSL node subclasses.
1611
- */
1612
- type NodeProps<P> = {
1613
- [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1614
- }
1615
-
1616
- interface ReactProps<P> {
1617
- children?: React.ReactNode
1618
- ref?: React.Ref<P>
1619
- key?: React.Key
1620
- }
1621
-
1622
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1623
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1624
- >
1625
-
1626
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1627
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1628
- >
1629
-
1630
- type ThreeToJSXElements<T extends Record<string, any>> = {
1631
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1632
- }
1633
-
1634
- type ThreeExports = typeof THREE
1635
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1636
-
1637
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1638
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1639
- // Conflicts with DOM types can be accessed through a three* prefix
1640
- threeAudio: ThreeElementsImpl['audio']
1641
- threeSource: ThreeElementsImpl['source']
1642
- threeLine: ThreeElementsImpl['line']
1643
- threePath: ThreeElementsImpl['path']
1644
- }
1645
-
1646
- declare module 'react' {
1647
- namespace JSX {
1648
- interface IntrinsicElements extends ThreeElements {}
1649
- }
1650
- }
1651
-
1652
- declare module 'react/jsx-runtime' {
1653
- namespace JSX {
1654
- interface IntrinsicElements extends ThreeElements {}
1655
- }
1656
- }
1657
-
1658
- declare module 'react/jsx-dev-runtime' {
1659
- namespace JSX {
1660
- interface IntrinsicElements extends ThreeElements {}
1661
- }
1662
- }
1663
-
1664
- type three_d_Color = Color;
1665
- type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1666
- type three_d_Euler = Euler;
1667
- type three_d_EventProps<P> = EventProps<P>;
1668
- type three_d_GeometryProps<P> = GeometryProps<P>;
1669
- type three_d_GeometryTransformProps = GeometryTransformProps;
1670
- type three_d_Layers = Layers;
1671
- type three_d_MathProps<P> = MathProps<P>;
1672
- type three_d_MathRepresentation = MathRepresentation;
1673
- type three_d_MathType<T extends MathTypes> = MathType<T>;
1674
- type three_d_MathTypes = MathTypes;
1675
- type three_d_Matrix3 = Matrix3;
1676
- type three_d_Matrix4 = Matrix4;
1677
- type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1678
- type three_d_NodeProps<P> = NodeProps<P>;
1679
- type three_d_Quaternion = Quaternion;
1680
- type three_d_RaycastableRepresentation = RaycastableRepresentation;
1681
- type three_d_ReactProps<P> = ReactProps<P>;
1682
- type three_d_TSLNodeInput = TSLNodeInput;
1683
- type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1684
- type three_d_ThreeElements = ThreeElements;
1685
- type three_d_ThreeElementsImpl = ThreeElementsImpl;
1686
- type three_d_ThreeExports = ThreeExports;
1687
- type three_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
1688
- type three_d_Vector2 = Vector2;
1689
- type three_d_Vector3 = Vector3;
1690
- type three_d_Vector4 = Vector4;
1691
- type three_d_VectorRepresentation = VectorRepresentation;
1692
- declare namespace three_d {
1693
- 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_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 };
1694
- }
1695
-
1696
- /**
1697
- * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1698
- *
1699
- * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1700
- * a single WebGPURenderer using Three.js CanvasTarget API.
1701
- *
1702
- * Primary canvas: Has `id` prop, creates its own renderer, registers here
1703
- * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1704
- */
1705
-
1706
- interface PrimaryCanvasEntry {
1707
- /** The WebGPURenderer instance owned by this primary canvas */
1708
- renderer: WebGPURenderer;
1709
- /** The zustand store for this canvas */
1710
- store: RootStore;
1711
- }
1712
- /**
1713
- * Register a primary canvas that can be targeted by secondary canvases.
1714
- *
1715
- * @param id - Unique identifier for this primary canvas
1716
- * @param renderer - The WebGPURenderer owned by this canvas
1717
- * @param store - The zustand store for this canvas
1718
- * @returns Cleanup function to unregister on unmount
1719
- */
1720
- declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1721
- /**
1722
- * Get a registered primary canvas by id.
1723
- *
1724
- * @param id - The id of the primary canvas to look up
1725
- * @returns The primary canvas entry or undefined if not found
1726
- */
1727
- declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1728
- /**
1729
- * Wait for a primary canvas to be registered.
1730
- * Returns immediately if already registered, otherwise waits.
1731
- *
1732
- * @param id - The id of the primary canvas to wait for
1733
- * @param timeout - Optional timeout in ms (default: 5000)
1734
- * @returns Promise that resolves with the primary canvas entry
1735
- */
1736
- declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1737
- /**
1738
- * Check if a primary canvas with the given id exists.
1739
- *
1740
- * @param id - The id to check
1741
- * @returns True if a primary canvas with this id is registered
1742
- */
1743
- declare function hasPrimary(id: string): boolean;
1744
- /**
1745
- * Unregister a primary canvas. Called on unmount.
1746
- *
1747
- * @param id - The id of the primary canvas to unregister
1748
- */
1749
- declare function unregisterPrimary(id: string): void;
1750
- /**
1751
- * Get all registered primary canvas ids. Useful for debugging.
1752
- */
1753
- declare function getPrimaryIds(): string[];
1754
-
1755
- type EnvironmentLoaderProps = {
1756
- files?: string | string[];
1757
- path?: string;
1758
- preset?: PresetsType;
1759
- extensions?: (loader: Loader$1) => void;
1760
- colorSpace?: ColorSpace;
1761
- };
1762
- /**
1763
- * Loads environment textures for reflections and lighting.
1764
- * Supports HDR files, presets, and cubemaps.
1765
- *
1766
- * @example Basic usage
1767
- * ```jsx
1768
- * const texture = useEnvironment({ preset: 'sunset' })
1769
- * ```
1770
- */
1771
- declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1772
- declare namespace useEnvironment {
1773
- var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1774
- var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1775
- }
1776
- type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1777
- type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1778
-
1779
- /**
1780
- * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1781
- *
1782
- * @property children - React children to render into custom environment portal
1783
- * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1784
- * @property near - Near clipping plane for cube camera (default: 0.1)
1785
- * @property far - Far clipping plane for cube camera (default: 1000)
1786
- * @property resolution - Resolution of the cube render target (default: 256)
1787
- * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1788
- *
1789
- * @property blur - @deprecated Use backgroundBlurriness instead
1790
- * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1791
- * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1792
- * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1793
- * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1794
- * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1795
- *
1796
- * @property map - Pre-existing texture to use as environment map
1797
- * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1798
- * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1799
- * @property ground - Ground projection settings. Use true for defaults or object with:
1800
- * - height: Height of camera used to create env map (default: 15)
1801
- * - radius: Radius of the world (default: 60)
1802
- * - scale: Scale of backside projected sphere (default: 1000)
1803
- *
1804
- * Additional loader props:
1805
- * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1806
- * @property path - Base path for file loading
1807
- * @property extensions - Texture extensions override
1808
- */
1809
- type EnvironmentProps = {
1810
- children?: React$1.ReactNode;
1811
- frames?: number;
1812
- near?: number;
1813
- far?: number;
1814
- resolution?: number;
1815
- background?: boolean | 'only';
1816
- /** deprecated, use backgroundBlurriness */
1817
- blur?: number;
1818
- backgroundBlurriness?: number;
1819
- backgroundIntensity?: number;
1820
- backgroundRotation?: Euler$3;
1821
- environmentIntensity?: number;
1822
- environmentRotation?: Euler$3;
1823
- map?: Texture$1;
1824
- preset?: PresetsType;
1825
- scene?: Scene | React$1.RefObject<Scene>;
1826
- ground?: boolean | {
1827
- radius?: number;
1828
- height?: number;
1829
- scale?: number;
1830
- };
1831
- /** Solid color for background (alternative to files/preset) */
1832
- color?: ColorRepresentation$1;
1833
- /** Separate files for background (when different from environment files) */
1834
- backgroundFiles?: string | string[];
1835
- } & EnvironmentLoaderProps;
1836
- /**
1837
- * Internal component that applies a pre-existing texture as environment map.
1838
- * Sets scene.environment and optionally scene.background.
1839
- *
1840
- * @example
1841
- * ```jsx
1842
- * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1843
- * ```
1844
- */
1845
- declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1846
- /**
1847
- * Internal component that loads environment textures from files or presets.
1848
- * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1849
- * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1850
- *
1851
- * @example With preset
1852
- * ```jsx
1853
- * <EnvironmentCube preset="sunset" />
1854
- * ```
1855
- *
1856
- * @example From HDR file
1857
- * ```jsx
1858
- * <EnvironmentCube files="environment.hdr" />
1859
- * ```
1860
- *
1861
- * @example From gainmap (smallest footprint)
1862
- * ```jsx
1863
- * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1864
- * ```
1865
- *
1866
- * @example From cube faces
1867
- * ```jsx
1868
- * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1869
- * ```
1870
- */
1871
- declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1872
- /**
1873
- * Internal component that renders custom environment using a portal and cube camera.
1874
- * Renders children into an off-buffer and films with a cube camera to create environment map.
1875
- * Can be static (frames=1) or animated (frames=Infinity).
1876
- *
1877
- * @example Custom environment with sphere
1878
- * ```jsx
1879
- * <EnvironmentPortal background near={1} far={1000} resolution={256}>
1880
- * <mesh scale={100}>
1881
- * <sphereGeometry args={[1, 64, 64]} />
1882
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1883
- * </mesh>
1884
- * </EnvironmentPortal>
1885
- * ```
1886
- *
1887
- * @example Animated environment
1888
- * ```jsx
1889
- * <EnvironmentPortal frames={Infinity} resolution={256}>
1890
- * <Float>
1891
- * <mesh />
1892
- * </Float>
1893
- * </EnvironmentPortal>
1894
- * ```
1895
- *
1896
- * @example Mixed with preset
1897
- * ```jsx
1898
- * <EnvironmentPortal preset="warehouse">
1899
- * <mesh />
1900
- * </EnvironmentPortal>
1901
- * ```
1902
- */
1903
- 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;
1904
- declare module '@react-three/fiber' {
1905
- interface ThreeElements {
1906
- groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
1907
- }
1908
- }
1909
- /**
1910
- * Sets up a global environment map for PBR materials and backgrounds.
1911
- * Affects scene.environment and optionally scene.background unless a custom scene is passed.
1912
- *
1913
- * Supports multiple input methods:
1914
- * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1915
- * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
1916
- * - **Texture**: Pre-existing cube texture via `map` prop
1917
- * - **Custom Scene**: Render children into environment using portal and cube camera
1918
- * - **Ground Projection**: Project environment onto ground plane
1919
- *
1920
- * @remarks
1921
- * - Preset property is NOT meant for production and may fail (relies on CDNs)
1922
- * - Gainmap format has the smallest file footprint
1923
- * - Use `frames={Infinity}` for animated environments with low resolution for performance
1924
- * - Ground projection places models on the "ground" within the environment map
1925
- * - Supports self-hosting with @pmndrs/assets using dynamic imports
1926
- *
1927
- * @example Basic preset usage
1928
- * ```jsx
1929
- * <Environment preset="sunset" />
1930
- * ```
1931
- *
1932
- * @example From HDR file
1933
- * ```jsx
1934
- * <Environment files="/hdr/environment.hdr" />
1935
- * ```
1936
- *
1937
- * @example From gainmap (smallest footprint)
1938
- * ```jsx
1939
- * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1940
- * ```
1941
- *
1942
- * @example With self-hosted assets
1943
- * ```jsx
1944
- * import { suspend } from 'suspend-react'
1945
- * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
1946
- *
1947
- * <Environment files={suspend(city)} />
1948
- * ```
1949
- *
1950
- * @example From existing texture
1951
- * ```jsx
1952
- * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
1953
- * ```
1954
- *
1955
- * @example Custom environment scene
1956
- * ```jsx
1957
- * <Environment background near={1} far={1000} resolution={256}>
1958
- * <mesh scale={100}>
1959
- * <sphereGeometry args={[1, 64, 64]} />
1960
- * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1961
- * </mesh>
1962
- * </Environment>
1963
- * ```
1964
- *
1965
- * @example Animated environment
1966
- * ```jsx
1967
- * <Environment frames={Infinity} resolution={256}>
1968
- * <Float>
1969
- * <mesh />
1970
- * </Float>
1971
- * </Environment>
1972
- * ```
1973
- *
1974
- * @example Mixed custom scene with preset
1975
- * ```jsx
1976
- * <Environment background preset="warehouse">
1977
- * <mesh />
1978
- * </Environment>
1979
- * ```
1980
- *
1981
- * @example With ground projection
1982
- * ```jsx
1983
- * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
1984
- * ```
1985
- *
1986
- * @example As background only
1987
- * ```jsx
1988
- * <Environment background="only" preset="sunset" />
1989
- * ```
1990
- *
1991
- * @example With rotation and intensity
1992
- * ```jsx
1993
- * <Environment
1994
- * background
1995
- * backgroundBlurriness={0.5}
1996
- * backgroundIntensity={0.8}
1997
- * backgroundRotation={[0, Math.PI / 2, 0]}
1998
- * environmentIntensity={1.2}
1999
- * environmentRotation={[0, Math.PI / 4, 0]}
2000
- * preset="studio"
2001
- * />
2002
- * ```
2003
- */
2004
- declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
2005
-
2006
- declare function removeInteractivity(store: RootStore, object: Object3D): void;
2007
- declare function createEvents(store: RootStore): {
2008
- handlePointer: (name: string) => (event: DomEvent) => void;
2009
- };
2010
- /** Default R3F event manager for web */
2011
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
2012
-
2013
- /**
2014
- * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
2015
- * This allows external code to access loader methods like abort().
2016
- */
2017
- declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
2018
- /**
2019
- * Synchronously loads and caches assets with a three loader.
2020
- *
2021
- * Note: this hook's caller must be wrapped with `React.Suspense`
2022
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
2023
- */
2024
- declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
2025
- declare namespace useLoader {
2026
- var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
2027
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
2028
- var loader: typeof getLoader;
2029
- }
2030
-
2031
- /**
2032
- * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
2033
- *
2034
- * Features:
2035
- * - Single RAF loop for entire application
2036
- * - Root registration (multiple Canvas support)
2037
- * - Global phases for addEffect/addAfterEffect (deprecated)
2038
- * - Per-root job management with phases, priorities, FPS throttling
2039
- * - onIdle callbacks for addTail (deprecated)
2040
- * - Demand mode support via invalidate()
2041
- */
2042
- declare class Scheduler {
2043
- private static readonly INSTANCE_KEY;
2044
- private static get instance();
2045
- private static set instance(value);
2046
- /**
2047
- * Get the global scheduler instance (creates if doesn't exist).
2048
- * Uses HMR data to preserve instance across hot reloads.
2049
- * @returns {Scheduler} The singleton scheduler instance
2050
- */
2051
- static get(): Scheduler;
2052
- /**
2053
- * Reset the singleton instance. Stops the loop and clears all state.
2054
- * Primarily used for testing to ensure clean state between tests.
2055
- * @returns {void}
2056
- */
2057
- static reset(): void;
2058
- private roots;
2059
- private phaseGraph;
2060
- private loopState;
2061
- private stoppedTime;
2062
- private nextRootIndex;
2063
- private globalBeforeJobs;
2064
- private globalAfterJobs;
2065
- private nextGlobalIndex;
2066
- private idleCallbacks;
2067
- private nextJobIndex;
2068
- private jobStateListeners;
2069
- private pendingFrames;
2070
- private _frameloop;
2071
- private _independent;
2072
- private errorHandler;
2073
- private rootReadyCallbacks;
2074
- get phases(): string[];
2075
- get frameloop(): Frameloop;
2076
- set frameloop(mode: Frameloop);
2077
- get isRunning(): boolean;
2078
- get isReady(): boolean;
2079
- get independent(): boolean;
2080
- set independent(value: boolean);
2081
- constructor();
2082
- /**
2083
- * Register a root (Canvas) with the scheduler.
2084
- * The first root to register starts the RAF loop (if frameloop='always').
2085
- * @param {string} id - Unique identifier for this root
2086
- * @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
2087
- * @returns {() => void} Unsubscribe function to remove this root
2088
- */
2089
- registerRoot(id: string, options?: RootOptions): () => void;
2090
- /**
2091
- * Unregister a root from the scheduler.
2092
- * Cleans up all job state listeners for this root's jobs.
2093
- * The last root to unregister stops the RAF loop.
2094
- * @param {string} id - The root ID to unregister
2095
- * @returns {void}
2096
- */
2097
- unregisterRoot(id: string): void;
2098
- /**
2099
- * Subscribe to be notified when a root becomes available.
2100
- * Fires immediately if a root already exists.
2101
- * @param {() => void} callback - Function called when first root registers
2102
- * @returns {() => void} Unsubscribe function
2103
- */
2104
- onRootReady(callback: () => void): () => void;
2105
- /**
2106
- * Notify all registered root-ready callbacks.
2107
- * Called when the first root registers.
2108
- * @returns {void}
2109
- * @private
2110
- */
2111
- private notifyRootReady;
2112
- /**
2113
- * Ensure a default root exists for independent mode.
2114
- * Creates a minimal root with no state provider.
2115
- * @returns {void}
2116
- * @private
2117
- */
2118
- private ensureDefaultRoot;
2119
- /**
2120
- * Trigger error handling for job errors.
2121
- * Uses the bound error handler if available, otherwise logs to console.
2122
- * @param {Error} error - The error to handle
2123
- * @returns {void}
2124
- */
2125
- triggerError(error: Error): void;
2126
- /**
2127
- * Add a named phase to the scheduler's execution order.
2128
- * Marks all roots for rebuild to incorporate the new phase.
2129
- * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
2130
- * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
2131
- * @returns {void}
2132
- * @example
2133
- * scheduler.addPhase('physics', { before: 'update' });
2134
- * scheduler.addPhase('postprocess', { after: 'render' });
2135
- */
2136
- addPhase(name: string, options?: AddPhaseOptions): void;
2137
- /**
2138
- * Check if a phase exists in the scheduler.
2139
- * @param {string} name - The phase name to check
2140
- * @returns {boolean} True if the phase exists
2141
- */
2142
- hasPhase(name: string): boolean;
2143
- /**
2144
- * Register a global job that runs once per frame (not per-root).
2145
- * Used internally by deprecated addEffect/addAfterEffect APIs.
2146
- * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
2147
- * @param {string} id - Unique identifier for this global job
2148
- * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
2149
- * @returns {() => void} Unsubscribe function to remove this global job
2150
- * @deprecated Use useFrame with phases instead
2151
- */
2152
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
2153
- /**
2154
- * Register an idle callback that fires when the loop stops.
2155
- * Used internally by deprecated addTail API.
2156
- * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
2157
- * @returns {() => void} Unsubscribe function to remove this idle callback
2158
- * @deprecated Use demand mode with invalidate() instead
2159
- */
2160
- onIdle(callback: (timestamp: number) => void): () => void;
2161
- /**
2162
- * Notify all registered idle callbacks.
2163
- * Called when the loop stops in demand mode.
2164
- * @param {number} timestamp - The RAF timestamp when idle occurred
2165
- * @returns {void}
2166
- * @private
2167
- */
2168
- private notifyIdle;
2169
- /**
2170
- * Register a job (frame callback) with a specific root.
2171
- * This is the core registration method used by useFrame internally.
2172
- * @param {FrameNextCallback} callback - The function to call each frame
2173
- * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
2174
- * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
2175
- * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
2176
- * @param {string} [options.phase] - Execution phase (defaults to 'update')
2177
- * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
2178
- * @param {number} [options.fps] - FPS throttle limit
2179
- * @param {boolean} [options.drop] - Drop frames when behind (default true)
2180
- * @param {boolean} [options.enabled] - Whether job is active (default true)
2181
- * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
2182
- * @returns {() => void} Unsubscribe function to remove this job
2183
- */
2184
- register(callback: FrameNextCallback, options?: JobOptions & {
2185
- rootId?: string;
2186
- system?: boolean;
2187
- }): () => void;
2188
- /**
2189
- * Unregister a job by its ID.
2190
- * Searches all roots if rootId is not provided.
2191
- * @param {string} id - The job ID to unregister
2192
- * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
2193
- * @returns {void}
2194
- */
2195
- unregister(id: string, rootId?: string): void;
2196
- /**
2197
- * Update a job's options dynamically.
2198
- * Searches all roots to find the job by ID.
2199
- * Phase/constraint changes trigger a rebuild of the sorted job list.
2200
- * @param {string} id - The job ID to update
2201
- * @param {Partial<JobOptions>} options - The options to update
2202
- * @returns {void}
2203
- */
2204
- updateJob(id: string, options: Partial<JobOptions>): void;
2205
- /**
2206
- * Check if a job is currently paused (disabled).
2207
- * @param {string} id - The job ID to check
2208
- * @returns {boolean} True if the job exists and is paused
2209
- */
2210
- isJobPaused(id: string): boolean;
2211
- /**
2212
- * Subscribe to state changes for a specific job.
2213
- * Listener is called when job is paused or resumed.
2214
- * @param {string} id - The job ID to subscribe to
2215
- * @param {() => void} listener - Callback invoked on state changes
2216
- * @returns {() => void} Unsubscribe function
2217
- */
2218
- subscribeJobState(id: string, listener: () => void): () => void;
2219
- /**
2220
- * Notify all listeners that a job's state has changed.
2221
- * @param {string} id - The job ID that changed
2222
- * @returns {void}
2223
- * @private
2224
- */
2225
- private notifyJobStateChange;
2226
- /**
2227
- * Pause a job by ID (sets enabled=false).
2228
- * Notifies any subscribed state listeners.
2229
- * @param {string} id - The job ID to pause
2230
- * @returns {void}
2231
- */
2232
- pauseJob(id: string): void;
2233
- /**
2234
- * Resume a paused job by ID (sets enabled=true).
2235
- * Resets job timing to prevent frame accumulation.
2236
- * Notifies any subscribed state listeners.
2237
- * @param {string} id - The job ID to resume
2238
- * @returns {void}
2239
- */
2240
- resumeJob(id: string): void;
2241
- /**
2242
- * Start the requestAnimationFrame loop.
2243
- * Resets timing state (elapsedTime, frameCount) on start.
2244
- * No-op if already running.
2245
- * @returns {void}
2246
- */
2247
- start(): void;
2248
- /**
2249
- * Stop the requestAnimationFrame loop.
2250
- * Cancels any pending RAF callback.
2251
- * No-op if not running.
2252
- * @returns {void}
2253
- */
2254
- stop(): void;
2255
- /**
2256
- * Request frames to be rendered in demand mode.
2257
- * Accumulates pending frames (capped at 60) and starts the loop if not running.
2258
- * No-op if frameloop is not 'demand'.
2259
- * @param {number} [frames=1] - Number of frames to request
2260
- * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
2261
- * - `false` (default): Sets pending frames to the specified value (replaces existing count)
2262
- * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
2263
- * @returns {void}
2264
- * @example
2265
- * // Request a single frame render
2266
- * scheduler.invalidate();
2267
- *
2268
- * @example
2269
- * // Request 5 frames (e.g., for animations)
2270
- * scheduler.invalidate(5);
2271
- *
2272
- * @example
2273
- * // Set pending frames to exactly 3 (don't stack with existing)
2274
- * scheduler.invalidate(3, false);
2275
- *
2276
- * @example
2277
- * // Add 2 more frames to existing pending count
2278
- * scheduler.invalidate(2, true);
2279
- */
2280
- invalidate(frames?: number, stackFrames?: boolean): void;
2281
- /**
2282
- * Reset timing state for deterministic testing.
2283
- * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
2284
- * @returns {void}
2285
- */
2286
- resetTiming(): void;
2287
- /**
2288
- * Manually execute a single frame for all roots.
2289
- * Useful for frameloop='never' mode or testing scenarios.
2290
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2291
- * @returns {void}
2292
- * @example
2293
- * // Manual control mode
2294
- * scheduler.frameloop = 'never';
2295
- * scheduler.step(); // Execute one frame
2296
- */
2297
- step(timestamp?: number): void;
2298
- /**
2299
- * Manually execute a single job by its ID.
2300
- * Useful for testing individual job callbacks in isolation.
2301
- * @param {string} id - The job ID to step
2302
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
2303
- * @returns {void}
2304
- */
2305
- stepJob(id: string, timestamp?: number): void;
2306
- /**
2307
- * Main RAF loop callback.
2308
- * Executes frame, handles demand mode, and schedules next frame.
2309
- * @param {number} timestamp - RAF timestamp in milliseconds
2310
- * @returns {void}
2311
- * @private
2312
- */
2313
- private loop;
2314
- /**
2315
- * Execute a single frame across all roots.
2316
- * Order: globalBefore → each root's jobs → globalAfter
2317
- * @param {number} timestamp - RAF timestamp in milliseconds
2318
- * @returns {void}
2319
- * @private
2320
- */
2321
- private executeFrame;
2322
- /**
2323
- * Run all global jobs from a job map.
2324
- * Catches and logs errors without stopping execution.
2325
- * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
2326
- * @param {number} timestamp - RAF timestamp in milliseconds
2327
- * @returns {void}
2328
- * @private
2329
- */
2330
- private runGlobalJobs;
2331
- /**
2332
- * Execute all jobs for a single root in sorted order.
2333
- * Rebuilds sorted job list if needed, then dispatches each job.
2334
- * Errors are caught and propagated via triggerError.
2335
- * @param {RootEntry} root - The root entry to tick
2336
- * @param {number} timestamp - RAF timestamp in milliseconds
2337
- * @param {number} delta - Time since last frame in seconds
2338
- * @returns {void}
2339
- * @private
2340
- */
2341
- private tickRoot;
2342
- /**
2343
- * Get the total number of registered jobs across all roots.
2344
- * Includes both per-root jobs and global before/after jobs.
2345
- * @returns {number} Total job count
2346
- */
2347
- getJobCount(): number;
2348
- /**
2349
- * Get all registered job IDs across all roots.
2350
- * Includes both per-root jobs and global before/after jobs.
2351
- * @returns {string[]} Array of all job IDs
2352
- */
2353
- getJobIds(): string[];
2354
- /**
2355
- * Get the number of registered roots (Canvas instances).
2356
- * @returns {number} Number of registered roots
2357
- */
2358
- getRootCount(): number;
2359
- /**
2360
- * Check if any user (non-system) jobs are registered in a specific phase.
2361
- * Used by the default render job to know if a user has taken over rendering.
2362
- *
2363
- * @param phase The phase to check
2364
- * @param rootId Optional root ID to check (checks all roots if not provided)
2365
- * @returns true if any user jobs exist in the phase
2366
- */
2367
- hasUserJobsInPhase(phase: string, rootId?: string): boolean;
2368
- /**
2369
- * Generate a unique root ID for automatic root registration.
2370
- * @returns {string} A unique root ID in the format 'root_N'
2371
- */
2372
- generateRootId(): string;
2373
- /**
2374
- * Generate a unique job ID.
2375
- * @returns {string} A unique job ID in the format 'job_N'
2376
- * @private
2377
- */
2378
- private generateJobId;
2379
- /**
2380
- * Normalize before/after constraints to a Set.
2381
- * Handles undefined, single string, or array inputs.
2382
- * @param {string | string[] | undefined} value - The constraint value(s)
2383
- * @returns {Set<string>} Normalized Set of constraint strings
2384
- * @private
2385
- */
2386
- private normalizeConstraints;
2387
- }
2388
- /**
2389
- * Get the global scheduler instance.
2390
- * Creates one if it doesn't exist.
2391
- */
2392
- declare const getScheduler: () => Scheduler;
2393
-
2394
- /**
2395
- * Frame hook with phase-based ordering, priority, and FPS throttling.
2396
- *
2397
- * Works both inside and outside Canvas context:
2398
- * - Inside Canvas: Full RootState (gl, scene, camera, etc.)
2399
- * - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
2400
- * - Outside Canvas (independent mode): Fires immediately with timing-only state
2401
- *
2402
- * Returns a controls object for manual stepping, pausing, and resuming.
2403
- *
2404
- * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
2405
- * @param priorityOrOptions - Either a priority number (backwards compat) or options object
2406
- * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
2407
- *
2408
- * @example
2409
- * // Simple priority (backwards compat)
2410
- * useFrame((state, delta) => { ... }, 5)
2411
- *
2412
- * @example
2413
- * // With phase-based ordering
2414
- * useFrame((state, delta) => { ... }, { phase: 'physics' })
2415
- *
2416
- * @example
2417
- * // Outside Canvas - waits for Canvas to mount
2418
- * function UI() {
2419
- * useFrame((state, delta) => { syncUI(state.camera) });
2420
- * return <button>...</button>;
2421
- * }
2422
- *
2423
- * @example
2424
- * // Independent mode - no Canvas needed
2425
- * getScheduler().independent = true;
2426
- * useFrame((state, delta) => { updateGame(delta) });
2427
- *
2428
- * @example
2429
- * // Scheduler-only access (no callback)
2430
- * const { scheduler } = useFrame()
2431
- * scheduler.pauseJob('some-job-id')
2432
- *
2433
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
2434
- */
2435
- declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
2436
-
2437
- declare const IsObject: (url: unknown) => url is Record<string, string>;
2438
- type TextureArray<T> = T extends string[] ? Texture$1[] : never;
2439
- type TextureRecord<T> = T extends Record<string, string> ? {
2440
- [key in keyof T]: Texture$1;
2441
- } : never;
2442
- type SingleTexture<T> = T extends string ? Texture$1 : never;
2443
- type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
2444
- /** Options for useTexture hook */
2445
- type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
2446
- /** Callback when texture(s) finish loading */
2447
- onLoad?: (texture: MappedTextureType<Url>) => void;
2448
- /**
2449
- * Cache the texture in R3F's global state for access via useTextures().
2450
- * When true:
2451
- * - Textures persist until explicitly disposed
2452
- * - Returns existing cached textures if available (preserving modifications like colorSpace)
2453
- * @default false
2454
- */
2455
- cache?: boolean;
2456
- };
2457
- /**
2458
- * Load texture(s) using Three's TextureLoader with Suspense support.
2459
- *
2460
- * @param input - URL string, array of URLs, or object mapping keys to URLs
2461
- * @param optionsOrOnLoad - Options object or legacy onLoad callback
2462
- *
2463
- * @example
2464
- * ```tsx
2465
- * // Single texture
2466
- * const diffuse = useTexture('/textures/diffuse.png')
2467
- *
2468
- * // Multiple textures (array)
2469
- * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
2470
- *
2471
- * // Named textures (object)
2472
- * const { diffuse, normal } = useTexture({
2473
- * diffuse: '/diffuse.png',
2474
- * normal: '/normal.png'
2475
- * })
2476
- *
2477
- * // With caching - returns same texture object across components
2478
- * // Modifications (colorSpace, wrapS, etc.) are preserved
2479
- * const diffuse = useTexture('/diffuse.png', { cache: true })
2480
- * diffuse.colorSpace = THREE.SRGBColorSpace
2481
- *
2482
- * // Another component gets the SAME texture with colorSpace already set
2483
- * const sameDiffuse = useTexture('/diffuse.png', { cache: true })
2484
- *
2485
- * // Access cache directly
2486
- * const { get } = useTextures()
2487
- * const cached = get('/diffuse.png')
2488
- * ```
2489
- */
2490
- declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
2491
- declare namespace useTexture {
2492
- var preload: (url: string | string[]) => void;
2493
- var clear: (input: string | string[]) => void;
2494
- }
2495
- declare const Texture: ({ children, input, onLoad, cache, }: {
2496
- children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
2497
- input: Parameters<typeof useTexture>[0];
2498
- onLoad?: Parameters<typeof useTexture>[1];
2499
- cache?: boolean;
2500
- }) => react_jsx_runtime.JSX.Element;
2501
-
2502
- type TextureEntry = Texture$1 | {
2503
- value: Texture$1;
2504
- [key: string]: any;
2505
- };
2506
- interface UseTexturesReturn {
2507
- /** Map of all textures currently in cache */
2508
- textures: Map<string, TextureEntry>;
2509
- /** Get a specific texture by key (usually URL) */
2510
- get: (key: string) => TextureEntry | undefined;
2511
- /** Check if a texture exists in cache */
2512
- has: (key: string) => boolean;
2513
- /** Add a texture to the cache */
2514
- add: (key: string, value: TextureEntry) => void;
2515
- /** Add multiple textures to the cache */
2516
- addMultiple: (items: Map<string, TextureEntry> | Record<string, TextureEntry>) => void;
2517
- /** Remove a texture from cache (does NOT dispose GPU resources) */
2518
- remove: (key: string) => void;
2519
- /** Remove multiple textures from cache */
2520
- removeMultiple: (keys: string[]) => void;
2521
- /** Dispose a texture's GPU resources and remove from cache */
2522
- dispose: (key: string) => void;
2523
- /** Dispose multiple textures */
2524
- disposeMultiple: (keys: string[]) => void;
2525
- /** Dispose ALL cached textures - use with caution */
2526
- disposeAll: () => void;
2527
- }
2528
- /**
2529
- * Hook for managing the global texture cache in R3F state.
2530
- *
2531
- * Textures are stored in a Map with URL/path keys for efficient lookup.
2532
- * Useful for sharing texture references across materials and components.
2533
- *
2534
- * @example
2535
- * ```tsx
2536
- * const { textures, add, get, remove, has, dispose } = useTextures()
2537
- *
2538
- * // Check if texture is already cached
2539
- * if (!has('/textures/diffuse.png')) {
2540
- * // Load with useTexture and cache: true, or manually add
2541
- * const tex = useTexture('/textures/diffuse.png', { cache: true })
2542
- * }
2543
- *
2544
- * // Access cached texture from anywhere
2545
- * const diffuse = get('/textures/diffuse.png')
2546
- * if (diffuse) material.map = diffuse
2547
- *
2548
- * // Remove from cache only (texture still in GPU memory)
2549
- * remove('/textures/old.png')
2550
- *
2551
- * // Fully dispose (frees GPU memory + removes from cache)
2552
- * dispose('/textures/unused.png')
2553
- *
2554
- * // Nuclear option - dispose everything
2555
- * disposeAll()
2556
- * ```
2557
- */
2558
- declare function useTextures(): UseTexturesReturn;
2559
-
2560
- /**
2561
- * Creates a render target compatible with the current renderer.
2562
- *
2563
- * - Legacy build: Returns WebGLRenderTarget
2564
- * - WebGPU build: Returns RenderTarget
2565
- * - Default build: Returns whichever matches the active renderer
2566
- *
2567
- * @example
2568
- * ```tsx
2569
- * // Use canvas size
2570
- * const fbo = useRenderTarget()
2571
- *
2572
- * // Use canvas size with options
2573
- * const fbo = useRenderTarget({ samples: 4 })
2574
- *
2575
- * // Square render target
2576
- * const fbo = useRenderTarget(512)
2577
- *
2578
- * // Square render target with options
2579
- * const fbo = useRenderTarget(512, { depthBuffer: true })
2580
- *
2581
- * // Explicit dimensions
2582
- * const fbo = useRenderTarget(512, 256)
2583
- *
2584
- * // Explicit dimensions with options
2585
- * const fbo = useRenderTarget(512, 256, { samples: 4 })
2586
- * ```
2587
- */
2588
- declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
2589
- declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
2590
- declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
2591
-
2592
- /**
2593
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
2594
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
2595
- */
2596
- declare function useStore(): RootStore;
2597
- /**
2598
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
2599
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
2600
- */
2601
- declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
2602
- /**
2603
- * Exposes an object's {@link Instance}.
2604
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
2605
- *
2606
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
2607
- */
2608
- declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
2609
- /**
2610
- * Returns a node graph of an object with named nodes & materials.
2611
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
2612
- */
2613
- declare function useGraph(object: Object3D): ObjectMap;
2614
-
2615
- /**
2616
- * Adds a global render callback which is called each frame BEFORE rendering.
2617
- *
2618
- * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
2619
- * This function will be removed in a future version.
2620
- *
2621
- * @param callback - Function called each frame with timestamp
2622
- * @returns Unsubscribe function
2623
- *
2624
- * @example
2625
- * // OLD (deprecated)
2626
- * const unsub = addEffect((timestamp) => { ... })
2627
- *
2628
- * // NEW
2629
- * useFrame((state, delta) => { ... }, { phase: 'start' })
2630
- *
2631
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
2632
- */
2633
- declare function addEffect(callback: GlobalRenderCallback): () => void;
2634
- /**
2635
- * Adds a global after-render callback which is called each frame AFTER rendering.
2636
- *
2637
- * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
2638
- * This function will be removed in a future version.
2639
- *
2640
- * @param callback - Function called each frame with timestamp
2641
- * @returns Unsubscribe function
2642
- *
2643
- * @example
2644
- * // OLD (deprecated)
2645
- * const unsub = addAfterEffect((timestamp) => { ... })
2646
- *
2647
- * // NEW
2648
- * useFrame((state, delta) => { ... }, { phase: 'finish' })
2649
- *
2650
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
2651
- */
2652
- declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
2653
- /**
2654
- * Adds a global callback which is called when rendering stops.
2655
- *
2656
- * @deprecated Use `scheduler.onIdle(callback)` instead.
2657
- * This function will be removed in a future version.
2658
- *
2659
- * @param callback - Function called when rendering stops
2660
- * @returns Unsubscribe function
2661
- *
2662
- * @example
2663
- * // OLD (deprecated)
2664
- * const unsub = addTail((timestamp) => { ... })
2665
- *
2666
- * // NEW
2667
- * const { scheduler } = useFrame()
2668
- * const unsub = scheduler.onIdle((timestamp) => { ... })
2669
- *
2670
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
2671
- */
2672
- declare function addTail(callback: GlobalRenderCallback): () => void;
2673
- /**
2674
- * Invalidates the view, requesting a frame to be rendered.
2675
- * In demand mode, this triggers the scheduler to run frames.
2676
- *
2677
- * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
2678
- * @param frames - Number of frames to request (default: 1)
2679
- * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
2680
- *
2681
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
2682
- */
2683
- declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
2684
- /**
2685
- * Advances the frameloop and runs render effects.
2686
- * Useful for when manually rendering via `frameloop="never"`.
2687
- *
2688
- * @param timestamp - The timestamp to use for this frame
2689
- * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
2690
- * @param state - Ignored (kept for backwards compat)
2691
- * @param frame - Ignored (kept for backwards compat)
2692
- *
2693
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2694
- */
2695
- declare function advance(timestamp: number): void;
2696
-
2697
- /* eslint-disable @definitelytyped/no-unnecessary-generics */
2698
- declare function ReactReconciler<
2699
- Type,
2700
- Props,
2701
- Container,
2702
- Instance,
2703
- TextInstance,
2704
- SuspenseInstance,
2705
- HydratableInstance,
2706
- FormInstance,
2707
- PublicInstance,
2708
- HostContext,
2709
- ChildSet,
2710
- TimeoutHandle,
2711
- NoTimeout,
2712
- TransitionStatus,
2713
- >(
2714
- /* eslint-enable @definitelytyped/no-unnecessary-generics */
2715
- config: ReactReconciler.HostConfig<
2716
- Type,
2717
- Props,
2718
- Container,
2719
- Instance,
2720
- TextInstance,
2721
- SuspenseInstance,
2722
- HydratableInstance,
2723
- FormInstance,
2724
- PublicInstance,
2725
- HostContext,
2726
- ChildSet,
2727
- TimeoutHandle,
2728
- NoTimeout,
2729
- TransitionStatus
2730
- >,
2731
- ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
2732
-
2733
- declare namespace ReactReconciler {
2734
- interface HostConfig<
2735
- Type,
2736
- Props,
2737
- Container,
2738
- Instance,
2739
- TextInstance,
2740
- SuspenseInstance,
2741
- HydratableInstance,
2742
- FormInstance,
2743
- PublicInstance,
2744
- HostContext,
2745
- ChildSet,
2746
- TimeoutHandle,
2747
- NoTimeout,
2748
- TransitionStatus,
2749
- > {
2750
- // -------------------
2751
- // Modes
2752
- // -------------------
2753
- /**
2754
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2755
- *
2756
- * 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.
2757
- *
2758
- * ```js
2759
- * const HostConfig = {
2760
- * // ...
2761
- * supportsMutation: true,
2762
- * // ...
2763
- * }
2764
- * ```
2765
- *
2766
- * Depending on the mode, the reconciler will call different methods on your host config.
2767
- *
2768
- * If you're not sure which one you want, you likely need the mutation mode.
2769
- */
2770
- supportsMutation: boolean;
2771
-
2772
- /**
2773
- * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
2774
- *
2775
- * 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".
2776
- *
2777
- * ```js
2778
- * const HostConfig = {
2779
- * // ...
2780
- * supportsPersistence: true,
2781
- * // ...
2782
- * }
2783
- * ```
2784
- *
2785
- * Depending on the mode, the reconciler will call different methods on your host config.
2786
- *
2787
- * If you're not sure which one you want, you likely need the mutation mode.
2788
- */
2789
- supportsPersistence: boolean;
2790
-
2791
- // -------------------
2792
- // Core Methods
2793
- // -------------------
2794
-
2795
- /**
2796
- * 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`.
2797
- *
2798
- * 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.
2799
- *
2800
- * 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.
2801
- *
2802
- * 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.
2803
- *
2804
- * 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.
2805
- */
2806
- createInstance(
2807
- type: Type,
2808
- props: Props,
2809
- rootContainer: Container,
2810
- hostContext: HostContext,
2811
- internalHandle: OpaqueHandle,
2812
- ): Instance;
2813
-
2814
- /**
2815
- * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
2816
- */
2817
- createTextInstance(
2818
- text: string,
2819
- rootContainer: Container,
2820
- hostContext: HostContext,
2821
- internalHandle: OpaqueHandle,
2822
- ): TextInstance;
2823
-
2824
- /**
2825
- * 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.
2826
- *
2827
- * 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.
2828
- */
2829
- appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
2830
-
2831
- /**
2832
- * 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.
2833
- *
2834
- * 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.
2835
- *
2836
- * 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.
2837
- *
2838
- * If you don't want to do anything here, you should return `false`.
2839
- */
2840
- finalizeInitialChildren(
2841
- instance: Instance,
2842
- type: Type,
2843
- props: Props,
2844
- rootContainer: Container,
2845
- hostContext: HostContext,
2846
- ): boolean;
2847
-
2848
- /**
2849
- * 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.
2850
- *
2851
- * 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.
2852
- *
2853
- * If you don't want to do anything here, you should return `false`.
2854
- *
2855
- * This method happens **in the render phase**. Do not mutate the tree from it.
2856
- */
2857
- shouldSetTextContent(type: Type, props: Props): boolean;
2858
-
2859
- /**
2860
- * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
2861
- *
2862
- * If you don't intend to use host context, you can return `null`.
2863
- *
2864
- * This method happens **in the render phase**. Do not mutate the tree from it.
2865
- */
2866
- getRootHostContext(rootContainer: Container): HostContext | null;
2867
-
2868
- /**
2869
- * 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.
2870
- *
2871
- * 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.
2872
- *
2873
- * If you don't want to do anything here, return `parentHostContext`.
2874
- *
2875
- * This method happens **in the render phase**. Do not mutate the tree from it.
2876
- */
2877
- getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
2878
-
2879
- /**
2880
- * 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.
2881
- *
2882
- * If you don't want to do anything here, return `instance`.
2883
- */
2884
- getPublicInstance(instance: Instance | TextInstance): PublicInstance;
2885
-
2886
- /**
2887
- * 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`.
2888
- *
2889
- * Even if you don't want to do anything here, you need to return `null` from it.
2890
- */
2891
- prepareForCommit(containerInfo: Container): Record<string, any> | null;
2892
-
2893
- /**
2894
- * 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.
2895
- *
2896
- * You can leave it empty.
2897
- */
2898
- resetAfterCommit(containerInfo: Container): void;
2899
-
2900
- /**
2901
- * This method is called for a container that's used as a portal target. Usually you can leave it empty.
2902
- */
2903
- preparePortalMount(containerInfo: Container): void;
2904
-
2905
- /**
2906
- * You can proxy this to `setTimeout` or its equivalent in your environment.
2907
- */
2908
- scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
2909
-
2910
- /**
2911
- * You can proxy this to `clearTimeout` or its equivalent in your environment.
2912
- */
2913
- cancelTimeout(id: TimeoutHandle): void;
2914
-
2915
- /**
2916
- * 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`.
2917
- */
2918
- noTimeout: NoTimeout;
2919
-
2920
- /**
2921
- * 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.
2922
- */
2923
- supportsMicrotasks?: boolean;
2924
-
2925
- /**
2926
- * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
2927
- */
2928
- scheduleMicrotask?(fn: () => unknown): void;
2929
-
2930
- /**
2931
- * 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`.
2932
- */
2933
- isPrimaryRenderer: boolean;
2934
-
2935
- /**
2936
- * Whether the renderer shouldn't trigger missing `act()` warnings
2937
- */
2938
- warnsIfNotActing?: boolean;
2939
-
2940
- getInstanceFromNode(node: any): Fiber | null | undefined;
2941
-
2942
- beforeActiveInstanceBlur(): void;
2943
-
2944
- afterActiveInstanceBlur(): void;
2945
-
2946
- prepareScopeUpdate(scopeInstance: any, instance: any): void;
2947
-
2948
- getInstanceFromScope(scopeInstance: any): null | Instance;
2949
-
2950
- detachDeletedInstance(node: Instance): void;
2951
-
2952
- // -------------------
2953
- // Mutation Methods
2954
- // (optional)
2955
- // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
2956
- // -------------------
2957
-
2958
- /**
2959
- * 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.
2960
- *
2961
- * 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`.
2962
- */
2963
- appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
2964
-
2965
- /**
2966
- * 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.
2967
- */
2968
- appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
2969
-
2970
- /**
2971
- * 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.
2972
- *
2973
- * 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.
2974
- */
2975
- insertBefore?(
2976
- parentInstance: Instance,
2977
- child: Instance | TextInstance,
2978
- beforeChild: Instance | TextInstance | SuspenseInstance,
2979
- ): void;
2980
-
2981
- /**
2982
- * 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.
2983
- */
2984
- insertInContainerBefore?(
2985
- container: Container,
2986
- child: Instance | TextInstance,
2987
- beforeChild: Instance | TextInstance | SuspenseInstance,
2988
- ): void;
2989
-
2990
- /**
2991
- * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
2992
- *
2993
- * 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.
2994
- */
2995
- removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
2996
-
2997
- /**
2998
- * 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.
2999
- */
3000
- removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
3001
-
3002
- /**
3003
- * 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 = ''`.
3004
- *
3005
- * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
3006
- */
3007
- resetTextContent?(instance: Instance): void;
3008
-
3009
- /**
3010
- * This method should mutate the `textInstance` and update its text content to `nextText`.
3011
- *
3012
- * Here, `textInstance` is a node created by `createTextInstance`.
3013
- */
3014
- commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
3015
-
3016
- /**
3017
- * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
3018
- *
3019
- * 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.
3020
- *
3021
- * 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.
3022
- *
3023
- * 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.
3024
- *
3025
- * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
3026
- */
3027
- commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
3028
-
3029
- /**
3030
- * This method should mutate the instance to match nextProps.
3031
- *
3032
- * 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.
3033
- */
3034
- commitUpdate?(
3035
- instance: Instance,
3036
- type: Type,
3037
- prevProps: Props,
3038
- nextProps: Props,
3039
- internalHandle: OpaqueHandle,
3040
- ): void;
3041
-
3042
- /**
3043
- * 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.
3044
- */
3045
- hideInstance?(instance: Instance): void;
3046
-
3047
- /**
3048
- * Same as `hideInstance`, but for nodes created by `createTextInstance`.
3049
- */
3050
- hideTextInstance?(textInstance: TextInstance): void;
3051
-
3052
- /**
3053
- * This method should make the `instance` visible, undoing what `hideInstance` did.
3054
- */
3055
- unhideInstance?(instance: Instance, props: Props): void;
3056
-
3057
- /**
3058
- * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
3059
- */
3060
- unhideTextInstance?(textInstance: TextInstance, text: string): void;
3061
-
3062
- /**
3063
- * This method should mutate the `container` root node and remove all children from it.
3064
- */
3065
- clearContainer?(container: Container): void;
3066
-
3067
- // -------------------
3068
- // Persistence Methods
3069
- // (optional)
3070
- // 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.
3071
- // -------------------
3072
- cloneInstance?(
3073
- instance: Instance,
3074
- type: Type,
3075
- oldProps: Props,
3076
- newProps: Props,
3077
- keepChildren: boolean,
3078
- recyclableInstance: null | Instance,
3079
- ): Instance;
3080
- createContainerChildSet?(container: Container): ChildSet;
3081
- appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
3082
- finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
3083
- replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
3084
- cloneHiddenInstance?(
3085
- instance: Instance,
3086
- type: Type,
3087
- props: Props,
3088
- internalInstanceHandle: OpaqueHandle,
3089
- ): Instance;
3090
- cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
3091
-
3092
- // -------------------
3093
- // Hydration Methods
3094
- // (optional)
3095
- // 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.
3096
- //
3097
- // 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.
3098
- // -------------------
3099
- supportsHydration: boolean;
3100
-
3101
- canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
3102
-
3103
- canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
3104
-
3105
- canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
3106
-
3107
- isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
3108
-
3109
- isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
3110
-
3111
- registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
3112
-
3113
- getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
3114
-
3115
- getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
3116
-
3117
- hydrateInstance?(
3118
- instance: Instance,
3119
- type: Type,
3120
- props: Props,
3121
- rootContainerInstance: Container,
3122
- hostContext: HostContext,
3123
- internalInstanceHandle: any,
3124
- ): null | any[];
3125
-
3126
- hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
3127
-
3128
- hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
3129
-
3130
- getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
3131
-
3132
- // Returns the SuspenseInstance if this node is a direct child of a
3133
- // SuspenseInstance. I.e. if its previous sibling is a Comment with
3134
- // SUSPENSE_x_START_DATA. Otherwise, null.
3135
- getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
3136
-
3137
- commitHydratedContainer?(container: Container): void;
3138
-
3139
- commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
3140
-
3141
- didNotMatchHydratedContainerTextInstance?(
3142
- parentContainer: Container,
3143
- textInstance: TextInstance,
3144
- text: string,
3145
- ): void;
3146
-
3147
- didNotMatchHydratedTextInstance?(
3148
- parentType: Type,
3149
- parentProps: Props,
3150
- parentInstance: Instance,
3151
- textInstance: TextInstance,
3152
- text: string,
3153
- ): void;
3154
-
3155
- didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
3156
-
3157
- didNotHydrateInstance?(
3158
- parentType: Type,
3159
- parentProps: Props,
3160
- parentInstance: Instance,
3161
- instance: HydratableInstance,
3162
- ): void;
3163
-
3164
- didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
3165
-
3166
- didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
3167
-
3168
- didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
3169
-
3170
- didNotFindHydratableInstance?(
3171
- parentType: Type,
3172
- parentProps: Props,
3173
- parentInstance: Instance,
3174
- type: Type,
3175
- props: Props,
3176
- ): void;
3177
-
3178
- didNotFindHydratableTextInstance?(
3179
- parentType: Type,
3180
- parentProps: Props,
3181
- parentInstance: Instance,
3182
- text: string,
3183
- ): void;
3184
-
3185
- didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
3186
-
3187
- errorHydratingContainer?(parentContainer: Container): void;
3188
-
3189
- // Undocumented
3190
- // https://github.com/facebook/react/pull/26722
3191
- NotPendingTransition: TransitionStatus | null;
3192
- HostTransitionContext: ReactContext<TransitionStatus>;
3193
-
3194
- // https://github.com/facebook/react/pull/28751
3195
- setCurrentUpdatePriority(newPriority: EventPriority): void;
3196
- getCurrentUpdatePriority(): EventPriority;
3197
- resolveUpdatePriority(): EventPriority;
3198
-
3199
- // https://github.com/facebook/react/pull/28804
3200
- resetFormInstance(form: FormInstance): void;
3201
-
3202
- // https://github.com/facebook/react/pull/25105
3203
- requestPostPaintCallback(callback: (time: number) => void): void;
3204
-
3205
- // https://github.com/facebook/react/pull/26025
3206
- shouldAttemptEagerTransition(): boolean;
3207
-
3208
- // https://github.com/facebook/react/pull/31528
3209
- trackSchedulerEvent(): void;
3210
-
3211
- // https://github.com/facebook/react/pull/31008
3212
- resolveEventType(): null | string;
3213
- resolveEventTimeStamp(): number;
3214
-
3215
- /**
3216
- * 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.
3217
- */
3218
- maySuspendCommit(type: Type, props: Props): boolean;
3219
-
3220
- /**
3221
- * 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.
3222
- */
3223
- preloadInstance(type: Type, props: Props): boolean;
3224
-
3225
- /**
3226
- * 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.
3227
- */
3228
- startSuspendingCommit(): void;
3229
-
3230
- /**
3231
- * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
3232
- */
3233
- suspendInstance(type: Type, props: Props): void;
3234
-
3235
- /**
3236
- * This method is called after all `suspendInstance` calls are complete.
3237
- *
3238
- * Return `null` if the commit can happen immediately.
3239
- *
3240
- * 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.
3241
- */
3242
- waitForCommitToBeReady():
3243
- | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
3244
- | null;
3245
- }
3246
-
3247
- interface Thenable<T> {
3248
- then(resolve: () => T, reject?: () => T): T;
3249
- }
3250
-
3251
- type RootTag = 0 | 1 | 2;
3252
-
3253
- type WorkTag =
3254
- | 0
3255
- | 1
3256
- | 2
3257
- | 3
3258
- | 4
3259
- | 5
3260
- | 6
3261
- | 7
3262
- | 8
3263
- | 9
3264
- | 10
3265
- | 11
3266
- | 12
3267
- | 13
3268
- | 14
3269
- | 15
3270
- | 16
3271
- | 17
3272
- | 18
3273
- | 19
3274
- | 20
3275
- | 21
3276
- | 22
3277
- | 23
3278
- | 24;
3279
-
3280
- type HookType =
3281
- | "useState"
3282
- | "useReducer"
3283
- | "useContext"
3284
- | "useRef"
3285
- | "useEffect"
3286
- | "useLayoutEffect"
3287
- | "useCallback"
3288
- | "useMemo"
3289
- | "useImperativeHandle"
3290
- | "useDebugValue"
3291
- | "useDeferredValue"
3292
- | "useTransition"
3293
- | "useMutableSource"
3294
- | "useOpaqueIdentifier"
3295
- | "useCacheRefresh";
3296
-
3297
- interface Source {
3298
- fileName: string;
3299
- lineNumber: number;
3300
- }
3301
-
3302
- // TODO: Ideally these types would be opaque but that doesn't work well with
3303
- // our reconciler fork infra, since these leak into non-reconciler packages.
3304
- type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
3305
-
3306
- type Lanes = number;
3307
- type Lane = number;
3308
-
3309
- type Flags = number;
3310
-
3311
- type TypeOfMode = number;
3312
-
3313
- type EventPriority = number;
3314
-
3315
- interface ReactProvider<T> {
3316
- $$typeof: symbol | number;
3317
- type: ReactProviderType<T>;
3318
- key: null | string;
3319
- ref: null;
3320
- props: {
3321
- value: T;
3322
- children?: ReactNode;
3323
- };
3324
- }
3325
-
3326
- interface ReactProviderType<T> {
3327
- $$typeof: symbol | number;
3328
- _context: ReactContext<T>;
3329
- }
3330
-
3331
- interface ReactConsumer<T> {
3332
- $$typeof: symbol | number;
3333
- type: ReactContext<T>;
3334
- key: null | string;
3335
- ref: null;
3336
- props: {
3337
- children: (value: T) => ReactNode;
3338
- unstable_observedBits?: number;
3339
- };
3340
- }
3341
-
3342
- interface ReactContext<T> {
3343
- $$typeof: symbol | number;
3344
- Consumer: ReactContext<T>;
3345
- Provider: ReactProviderType<T>;
3346
- _currentValue: T;
3347
- _currentValue2: T;
3348
- _threadCount: number;
3349
- // DEV only
3350
- _currentRenderer?: {
3351
- [key: string]: any;
3352
- } | null;
3353
- _currentRenderer2?: {
3354
- [key: string]: any;
3355
- } | null;
3356
- // This value may be added by application code
3357
- // to improve DEV tooling display names
3358
- displayName?: string;
3359
- }
3360
-
3361
- interface ReactPortal {
3362
- $$typeof: symbol | number;
3363
- key: null | string;
3364
- containerInfo: any;
3365
- children: ReactNode;
3366
- // TODO: figure out the API for cross-renderer implementation.
3367
- implementation: any;
3368
- }
3369
-
3370
- interface RefObject {
3371
- current: any;
3372
- }
3373
-
3374
- interface ContextDependency<T> {
3375
- context: ReactContext<T>;
3376
- observedBits: number;
3377
- next: ContextDependency<unknown> | null;
3378
- }
3379
-
3380
- interface Dependencies {
3381
- lanes: Lanes;
3382
- firstContext: ContextDependency<unknown> | null;
3383
- }
3384
-
3385
- interface Fiber {
3386
- // These first fields are conceptually members of an Instance. This used to
3387
- // be split into a separate type and intersected with the other Fiber fields,
3388
- // but until Flow fixes its intersection bugs, we've merged them into a
3389
- // single type.
3390
-
3391
- // An Instance is shared between all versions of a component. We can easily
3392
- // break this out into a separate object to avoid copying so much to the
3393
- // alternate versions of the tree. We put this on a single object for now to
3394
- // minimize the number of objects created during the initial render.
3395
-
3396
- // Tag identifying the type of fiber.
3397
- tag: WorkTag;
3398
-
3399
- // Unique identifier of this child.
3400
- key: null | string;
3401
-
3402
- // The value of element.type which is used to preserve the identity during
3403
- // reconciliation of this child.
3404
- elementType: any;
3405
-
3406
- // The resolved function/class/ associated with this fiber.
3407
- type: any;
3408
-
3409
- // The local state associated with this fiber.
3410
- stateNode: any;
3411
-
3412
- // Conceptual aliases
3413
- // parent : Instance -> return The parent happens to be the same as the
3414
- // return fiber since we've merged the fiber and instance.
3415
-
3416
- // Remaining fields belong to Fiber
3417
-
3418
- // The Fiber to return to after finishing processing this one.
3419
- // This is effectively the parent, but there can be multiple parents (two)
3420
- // so this is only the parent of the thing we're currently processing.
3421
- // It is conceptually the same as the return address of a stack frame.
3422
- return: Fiber | null;
3423
-
3424
- // Singly Linked List Tree Structure.
3425
- child: Fiber | null;
3426
- sibling: Fiber | null;
3427
- index: number;
3428
-
3429
- // The ref last used to attach this node.
3430
- // I'll avoid adding an owner field for prod and model that as functions.
3431
- ref:
3432
- | null
3433
- | (((handle: unknown) => void) & {
3434
- _stringRef?: string | null;
3435
- })
3436
- | RefObject;
3437
-
3438
- // Input is the data coming into process this fiber. Arguments. Props.
3439
- pendingProps: any; // This type will be more specific once we overload the tag.
3440
- memoizedProps: any; // The props used to create the output.
3441
-
3442
- // A queue of state updates and callbacks.
3443
- updateQueue: unknown;
3444
-
3445
- // The state used to create the output
3446
- memoizedState: any;
3447
-
3448
- // Dependencies (contexts, events) for this fiber, if it has any
3449
- dependencies: Dependencies | null;
3450
-
3451
- // Bitfield that describes properties about the fiber and its subtree. E.g.
3452
- // the ConcurrentMode flag indicates whether the subtree should be async-by-
3453
- // default. When a fiber is created, it inherits the mode of its
3454
- // parent. Additional flags can be set at creation time, but after that the
3455
- // value should remain unchanged throughout the fiber's lifetime, particularly
3456
- // before its child fibers are created.
3457
- mode: TypeOfMode;
3458
-
3459
- // Effect
3460
- flags: Flags;
3461
- subtreeFlags: Flags;
3462
- deletions: Fiber[] | null;
3463
-
3464
- // Singly linked list fast path to the next fiber with side-effects.
3465
- nextEffect: Fiber | null;
3466
-
3467
- // The first and last fiber with side-effect within this subtree. This allows
3468
- // us to reuse a slice of the linked list when we reuse the work done within
3469
- // this fiber.
3470
- firstEffect: Fiber | null;
3471
- lastEffect: Fiber | null;
3472
-
3473
- lanes: Lanes;
3474
- childLanes: Lanes;
3475
-
3476
- // This is a pooled version of a Fiber. Every fiber that gets updated will
3477
- // eventually have a pair. There are cases when we can clean up pairs to save
3478
- // memory if we need to.
3479
- alternate: Fiber | null;
3480
-
3481
- // Time spent rendering this Fiber and its descendants for the current update.
3482
- // This tells us how well the tree makes use of sCU for memoization.
3483
- // It is reset to 0 each time we render and only updated when we don't bailout.
3484
- // This field is only set when the enableProfilerTimer flag is enabled.
3485
- actualDuration?: number;
3486
-
3487
- // If the Fiber is currently active in the "render" phase,
3488
- // This marks the time at which the work began.
3489
- // This field is only set when the enableProfilerTimer flag is enabled.
3490
- actualStartTime?: number;
3491
-
3492
- // Duration of the most recent render time for this Fiber.
3493
- // This value is not updated when we bailout for memoization purposes.
3494
- // This field is only set when the enableProfilerTimer flag is enabled.
3495
- selfBaseDuration?: number;
3496
-
3497
- // Sum of base times for all descendants of this Fiber.
3498
- // This value bubbles up during the "complete" phase.
3499
- // This field is only set when the enableProfilerTimer flag is enabled.
3500
- treeBaseDuration?: number;
3501
-
3502
- // Conceptual aliases
3503
- // workInProgress : Fiber -> alternate The alternate used for reuse happens
3504
- // to be the same as work in progress.
3505
- // __DEV__ only
3506
- _debugID?: number;
3507
- _debugSource?: Source | null;
3508
- _debugOwner?: Fiber | null;
3509
- _debugIsCurrentlyTiming?: boolean;
3510
- _debugNeedsRemount?: boolean;
3511
-
3512
- // Used to verify that the order of hooks does not change between renders.
3513
- _debugHookTypes?: HookType[] | null;
3514
- }
3515
-
3516
- type FiberRoot = any;
3517
-
3518
- // Concurrent related struct
3519
- type MutableSource = any;
3520
-
3521
- type OpaqueHandle = any;
3522
- type OpaqueRoot = any;
3523
-
3524
- // 0 is PROD, 1 is DEV.
3525
- // Might add PROFILE later.
3526
- type BundleType = 0 | 1;
3527
-
3528
- interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
3529
- bundleType: BundleType;
3530
- version: string;
3531
- rendererPackageName: string;
3532
- // Note: this actually *does* depend on Fiber internal fields.
3533
- // Used by "inspect clicked DOM element" in React DevTools.
3534
- findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
3535
- rendererConfig?: RendererInspectionConfig;
3536
- }
3537
-
3538
- interface SuspenseHydrationCallbacks<SuspenseInstance> {
3539
- onHydrated?: (suspenseInstance: SuspenseInstance) => void;
3540
- onDeleted?: (suspenseInstance: SuspenseInstance) => void;
3541
- }
3542
-
3543
- interface TransitionTracingCallbacks {
3544
- onTransitionStart?: (transitionName: string, startTime: number) => void;
3545
- onTransitionProgress?: (
3546
- transitionName: string,
3547
- startTime: number,
3548
- currentTime: number,
3549
- pending: Array<{ name: null | string }>,
3550
- ) => void;
3551
- onTransitionIncomplete?: (
3552
- transitionName: string,
3553
- startTime: number,
3554
- deletions: Array<{
3555
- type: string;
3556
- name?: string;
3557
- newName?: string;
3558
- endTime: number;
3559
- }>,
3560
- ) => void;
3561
- onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
3562
- onMarkerProgress?: (
3563
- transitionName: string,
3564
- marker: string,
3565
- startTime: number,
3566
- currentTime: number,
3567
- pending: Array<{ name: null | string }>,
3568
- ) => void;
3569
- onMarkerIncomplete?: (
3570
- transitionName: string,
3571
- marker: string,
3572
- startTime: number,
3573
- deletions: Array<{
3574
- type: string;
3575
- name?: string;
3576
- newName?: string;
3577
- endTime: number;
3578
- }>,
3579
- ) => void;
3580
- onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
3581
- }
3582
-
3583
- interface ComponentSelector {
3584
- $$typeof: symbol | number;
3585
- value: React$AbstractComponent<never, unknown>;
3586
- }
3587
-
3588
- interface HasPseudoClassSelector {
3589
- $$typeof: symbol | number;
3590
- value: Selector[];
3591
- }
3592
-
3593
- interface RoleSelector {
3594
- $$typeof: symbol | number;
3595
- value: string;
3596
- }
3597
-
3598
- interface TextSelector {
3599
- $$typeof: symbol | number;
3600
- value: string;
3601
- }
3602
-
3603
- interface TestNameSelector {
3604
- $$typeof: symbol | number;
3605
- value: string;
3606
- }
3607
-
3608
- type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
3609
-
3610
- // TODO can not find React$AbstractComponent def
3611
- type React$AbstractComponent<Config, Instance = any> = any;
3612
-
3613
- interface BoundingRect {
3614
- x: number;
3615
- y: number;
3616
- width: number;
3617
- height: number;
3618
- }
3619
-
3620
- type IntersectionObserverOptions = any;
3621
-
3622
- interface BaseErrorInfo {
3623
- componentStack?: string;
3624
- }
3625
-
3626
- interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
3627
- createContainer(
3628
- containerInfo: Container,
3629
- tag: RootTag,
3630
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3631
- isStrictMode: boolean,
3632
- concurrentUpdatesByDefaultOverride: null | boolean,
3633
- identifierPrefix: string,
3634
- onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
3635
- onCaughtError: (error: Error, info: BaseErrorInfo) => void,
3636
- onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
3637
- onDefaultTransitionIndicator: () => void,
3638
- transitionCallbacks: null | TransitionTracingCallbacks,
3639
- ): OpaqueRoot;
3640
-
3641
- createPortal(
3642
- children: ReactNode,
3643
- containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
3644
- implementation: any,
3645
- key?: string | null,
3646
- ): ReactPortal;
3647
-
3648
- registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
3649
-
3650
- createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
3651
-
3652
- createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
3653
-
3654
- createRoleSelector(role: string): RoleSelector;
3655
-
3656
- createTextSelector(text: string): TextSelector;
3657
-
3658
- createTestNameSelector(id: string): TestNameSelector;
3659
-
3660
- getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
3661
-
3662
- findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
3663
-
3664
- findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
3665
-
3666
- focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
3667
-
3668
- observeVisibleRects(
3669
- hostRoot: Instance,
3670
- selectors: Selector[],
3671
- callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
3672
- options?: IntersectionObserverOptions,
3673
- ): { disconnect: () => void };
3674
-
3675
- createHydrationContainer(
3676
- initialChildren: ReactNode,
3677
- callback: (() => void) | null | undefined,
3678
- containerInfo: Container,
3679
- tag: RootTag,
3680
- hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
3681
- isStrictMode: boolean,
3682
- concurrentUpdatesByDefaultOverride: null | boolean,
3683
- identifierPrefix: string,
3684
- onRecoverableError: (error: Error) => void,
3685
- transitionCallbacks: null | TransitionTracingCallbacks,
3686
- ): OpaqueRoot;
3687
-
3688
- updateContainer(
3689
- element: ReactNode,
3690
- container: OpaqueRoot,
3691
- parentComponent?: Component<any, any> | null,
3692
- callback?: (() => void) | null,
3693
- ): Lane;
3694
-
3695
- batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
3696
-
3697
- deferredUpdates<A>(fn: () => A): A;
3698
-
3699
- 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;
3700
-
3701
- flushControlled(fn: () => any): void;
3702
-
3703
- flushSync(): void;
3704
- flushSync<R>(fn: () => R): R;
3705
-
3706
- isAlreadyRendering(): boolean;
3707
-
3708
- flushPassiveEffects(): boolean;
3709
-
3710
- getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
3711
-
3712
- attemptSynchronousHydration(fiber: Fiber): void;
3713
-
3714
- attemptDiscreteHydration(fiber: Fiber): void;
3715
-
3716
- attemptContinuousHydration(fiber: Fiber): void;
3717
-
3718
- attemptHydrationAtCurrentPriority(fiber: Fiber): void;
3719
-
3720
- getCurrentUpdatePriority(): LanePriority;
3721
-
3722
- runWithPriority<T>(priority: LanePriority, fn: () => T): T;
3723
-
3724
- findHostInstance(component: any): PublicInstance | null;
3725
-
3726
- findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
3727
-
3728
- findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
3729
-
3730
- shouldError(fiber: Fiber): boolean | undefined;
3731
-
3732
- shouldSuspend(fiber: Fiber): boolean;
3733
-
3734
- injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
3735
- }
3736
- }
3737
-
3738
- declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3739
- declare function extend<T extends Catalogue>(objects: T): void;
3740
- declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3741
-
3742
- declare const isRenderer: (def: any) => boolean;
3743
- interface OffscreenCanvas extends EventTarget {
3744
- }
3745
- declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3746
- declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3747
- declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3748
- declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3749
- interface PortalProps {
3750
- children: ReactNode;
3751
- state?: InjectState;
3752
- container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3753
- }
3754
- declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3755
- /**
3756
- * Force React to flush any updates inside the provided callback synchronously and immediately.
3757
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
3758
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
3759
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
3760
- */
3761
- declare function flushSync<R>(fn: () => R): R;
3762
-
3763
- declare const context: React$1.Context<RootStore>;
3764
- declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3765
-
3766
- /**
3767
- * Safely flush async effects when testing, simulating a legacy root.
3768
- * @deprecated Import from React instead. import { act } from 'react'
3769
- */
3770
- declare const act: typeof React$1.act;
3771
- /**
3772
- * An SSR-friendly useLayoutEffect.
3773
- *
3774
- * React currently throws a warning when using useLayoutEffect on the server.
3775
- * To get around it, we can conditionally useEffect on the server (no-op) and
3776
- * useLayoutEffect elsewhere.
3777
- *
3778
- * @see https://github.com/facebook/react/issues/14927
3779
- */
3780
- declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
3781
- /**
3782
- * Creates a stable ref that always contains the latest callback.
3783
- * Useful for avoiding dependency arrays while ensuring the latest closure is called.
3784
- *
3785
- * @param fn - The callback function to wrap
3786
- * @returns A ref containing the current callback
3787
- */
3788
- declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
3789
- /**
3790
- * Bridges renderer Context and StrictMode from a primary renderer.
3791
- * Used to maintain React context when rendering into portals or secondary canvases.
3792
- *
3793
- * @returns A Bridge component that wraps children with the parent renderer's context
3794
- */
3795
- declare function useBridge(): Bridge;
3796
- /**
3797
- * Internal component that blocks rendering until a promise resolves.
3798
- * Used for suspense-like blocking behavior.
3799
- *
3800
- * @param set - Function to set the blocking promise
3801
- */
3802
- declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
3803
- /**
3804
- * Error boundary component for catching and handling errors in the React tree.
3805
- * Forwards errors to a state setter for external handling.
3806
- *
3807
- * NOTE: static members get down-level transpiled to mutations which break tree-shaking
3808
- */
3809
- declare const ErrorBoundary: {
3810
- new (props: {
3811
- set: React$1.Dispatch<Error | undefined>;
3812
- children: React$1.ReactNode;
3813
- }): {
3814
- state: {
3815
- error: boolean;
3816
- };
3817
- componentDidCatch(err: Error): void;
3818
- render(): React$1.ReactNode;
3819
- context: unknown;
3820
- setState<K extends "error">(state: {
3821
- error: boolean;
3822
- } | ((prevState: Readonly<{
3823
- error: boolean;
3824
- }>, props: Readonly<{
3825
- set: React$1.Dispatch<Error | undefined>;
3826
- children: React$1.ReactNode;
3827
- }>) => {
3828
- error: boolean;
3829
- } | Pick<{
3830
- error: boolean;
3831
- }, K> | null) | Pick<{
3832
- error: boolean;
3833
- }, K> | null, callback?: (() => void) | undefined): void;
3834
- forceUpdate(callback?: (() => void) | undefined): void;
3835
- readonly props: Readonly<{
3836
- set: React$1.Dispatch<Error | undefined>;
3837
- children: React$1.ReactNode;
3838
- }>;
3839
- componentDidMount?(): void;
3840
- shouldComponentUpdate?(nextProps: Readonly<{
3841
- set: React$1.Dispatch<Error | undefined>;
3842
- children: React$1.ReactNode;
3843
- }>, nextState: Readonly<{
3844
- error: boolean;
3845
- }>, nextContext: any): boolean;
3846
- componentWillUnmount?(): void;
3847
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3848
- set: React$1.Dispatch<Error | undefined>;
3849
- children: React$1.ReactNode;
3850
- }>, prevState: Readonly<{
3851
- error: boolean;
3852
- }>): any;
3853
- componentDidUpdate?(prevProps: Readonly<{
3854
- set: React$1.Dispatch<Error | undefined>;
3855
- children: React$1.ReactNode;
3856
- }>, prevState: Readonly<{
3857
- error: boolean;
3858
- }>, snapshot?: any): void;
3859
- componentWillMount?(): void;
3860
- UNSAFE_componentWillMount?(): void;
3861
- componentWillReceiveProps?(nextProps: Readonly<{
3862
- set: React$1.Dispatch<Error | undefined>;
3863
- children: React$1.ReactNode;
3864
- }>, nextContext: any): void;
3865
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3866
- set: React$1.Dispatch<Error | undefined>;
3867
- children: React$1.ReactNode;
3868
- }>, nextContext: any): void;
3869
- componentWillUpdate?(nextProps: Readonly<{
3870
- set: React$1.Dispatch<Error | undefined>;
3871
- children: React$1.ReactNode;
3872
- }>, nextState: Readonly<{
3873
- error: boolean;
3874
- }>, nextContext: any): void;
3875
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3876
- set: React$1.Dispatch<Error | undefined>;
3877
- children: React$1.ReactNode;
3878
- }>, nextState: Readonly<{
3879
- error: boolean;
3880
- }>, nextContext: any): void;
3881
- };
3882
- new (props: {
3883
- set: React$1.Dispatch<Error | undefined>;
3884
- children: React$1.ReactNode;
3885
- }, context: any): {
3886
- state: {
3887
- error: boolean;
3888
- };
3889
- componentDidCatch(err: Error): void;
3890
- render(): React$1.ReactNode;
3891
- context: unknown;
3892
- setState<K extends "error">(state: {
3893
- error: boolean;
3894
- } | ((prevState: Readonly<{
3895
- error: boolean;
3896
- }>, props: Readonly<{
3897
- set: React$1.Dispatch<Error | undefined>;
3898
- children: React$1.ReactNode;
3899
- }>) => {
3900
- error: boolean;
3901
- } | Pick<{
3902
- error: boolean;
3903
- }, K> | null) | Pick<{
3904
- error: boolean;
3905
- }, K> | null, callback?: (() => void) | undefined): void;
3906
- forceUpdate(callback?: (() => void) | undefined): void;
3907
- readonly props: Readonly<{
3908
- set: React$1.Dispatch<Error | undefined>;
3909
- children: React$1.ReactNode;
3910
- }>;
3911
- componentDidMount?(): void;
3912
- shouldComponentUpdate?(nextProps: Readonly<{
3913
- set: React$1.Dispatch<Error | undefined>;
3914
- children: React$1.ReactNode;
3915
- }>, nextState: Readonly<{
3916
- error: boolean;
3917
- }>, nextContext: any): boolean;
3918
- componentWillUnmount?(): void;
3919
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
3920
- set: React$1.Dispatch<Error | undefined>;
3921
- children: React$1.ReactNode;
3922
- }>, prevState: Readonly<{
3923
- error: boolean;
3924
- }>): any;
3925
- componentDidUpdate?(prevProps: Readonly<{
3926
- set: React$1.Dispatch<Error | undefined>;
3927
- children: React$1.ReactNode;
3928
- }>, prevState: Readonly<{
3929
- error: boolean;
3930
- }>, snapshot?: any): void;
3931
- componentWillMount?(): void;
3932
- UNSAFE_componentWillMount?(): void;
3933
- componentWillReceiveProps?(nextProps: Readonly<{
3934
- set: React$1.Dispatch<Error | undefined>;
3935
- children: React$1.ReactNode;
3936
- }>, nextContext: any): void;
3937
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3938
- set: React$1.Dispatch<Error | undefined>;
3939
- children: React$1.ReactNode;
3940
- }>, nextContext: any): void;
3941
- componentWillUpdate?(nextProps: Readonly<{
3942
- set: React$1.Dispatch<Error | undefined>;
3943
- children: React$1.ReactNode;
3944
- }>, nextState: Readonly<{
3945
- error: boolean;
3946
- }>, nextContext: any): void;
3947
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3948
- set: React$1.Dispatch<Error | undefined>;
3949
- children: React$1.ReactNode;
3950
- }>, nextState: Readonly<{
3951
- error: boolean;
3952
- }>, nextContext: any): void;
3953
- };
3954
- getDerivedStateFromError: () => {
3955
- error: boolean;
3956
- };
3957
- contextType?: React$1.Context<any> | undefined;
3958
- propTypes?: any;
3959
- };
3960
-
3961
- /**
3962
- * React internal props that should not be passed to Three.js objects.
3963
- */
3964
- declare const REACT_INTERNAL_PROPS: string[];
3965
- /**
3966
- * Returns the instance's initial (outermost) root.
3967
- * Traverses through previousRoot links to find the original root store.
3968
- *
3969
- * @param instance - R3F instance to find root for
3970
- * @returns The outermost root store
3971
- */
3972
- declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
3973
- /**
3974
- * Returns instance root state.
3975
- * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
3976
- * traverses ancestors to find the nearest managed parent.
3977
- *
3978
- * @param obj - Three.js object to get root state for
3979
- * @returns Root state if found, undefined otherwise
3980
- */
3981
- declare function getRootState<T extends Object3D = Object3D>(obj: T): RootState | undefined;
3982
- /**
3983
- * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
3984
- * Handles duplicate material names by appending UUID prefixes.
3985
- *
3986
- * @param object - Root object to traverse
3987
- * @returns ObjectMap containing named nodes, materials, and meshes
3988
- *
3989
- * @example
3990
- * const { nodes, materials, meshes } = buildGraph(gltf.scene)
3991
- * // Access by name: nodes.Head, materials.Metal, meshes.Body
3992
- */
3993
- declare function buildGraph(object: Object3D): ObjectMap;
3994
- /**
3995
- * Disposes an object and all its disposable properties.
3996
- * Skips Scene objects as they should not be disposed automatically.
3997
- *
3998
- * @param obj - Object to dispose
3999
- */
4000
- declare function dispose<T extends Disposable>(obj: T): void;
4001
- /**
4002
- * Extracts instance props from React reconciler fiber props.
4003
- * Filters out React-internal props (children, key, ref).
4004
- *
4005
- * @param queue - Pending props from reconciler fiber
4006
- * @returns Props object without React-internal keys
4007
- */
4008
- declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
4009
- /**
4010
- * Creates or retrieves an R3F instance descriptor for a Three.js object.
4011
- * Each object in the scene carries a LocalState descriptor (__r3f).
4012
- *
4013
- * @param target - Target object to prepare
4014
- * @param root - Root store for this instance
4015
- * @param type - String identifier for the object type
4016
- * @param props - Initial props for the instance
4017
- * @returns Instance descriptor
4018
- */
4019
- declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
4020
- /**
4021
- * Triggers an update for an instance.
4022
- * Calls onUpdate callback and invalidates the frame if necessary.
4023
- *
4024
- * @param instance - Instance to invalidate
4025
- */
4026
- declare function invalidateInstance(instance: Instance): void;
4027
-
4028
- /**
4029
- * Reserved prop names that should not be applied to Three.js objects.
4030
- */
4031
- declare const RESERVED_PROPS: string[];
4032
- /**
4033
- * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
4034
- * First tries the entire key as a single property, then attempts piercing.
4035
- *
4036
- * @param root - Root object to resolve from
4037
- * @param key - Property key (may contain dashes for piercing)
4038
- * @returns Object containing root, key, and target value
4039
- *
4040
- * @example
4041
- * resolve(mesh, 'material-color')
4042
- * // => { root: mesh.material, key: 'color', target: mesh.material.color }
4043
- */
4044
- declare function resolve(root: any, key: string): {
4045
- root: any;
4046
- key: string;
4047
- target: any;
4048
- };
4049
- /**
4050
- * Attaches a child instance to a parent instance.
4051
- * Handles both string-based attachment (e.g., 'geometry', 'material-map')
4052
- * and function-based attachment for custom logic.
4053
- *
4054
- * @param parent - Parent instance
4055
- * @param child - Child instance to attach
4056
- *
4057
- * @example
4058
- * // String attachment
4059
- * <bufferGeometry attach="geometry" />
4060
- * // Array attachment
4061
- * <light attach="lights-0" />
4062
- * // Function attachment
4063
- * <thing attach={(parent, self) => { parent.customProp = self }} />
4064
- */
4065
- declare function attach(parent: Instance, child: Instance): void;
4066
- /**
4067
- * Detaches a child instance from a parent instance.
4068
- * Restores the previous value or deletes the property if it was never set.
4069
- *
4070
- * @param parent - Parent instance
4071
- * @param child - Child instance to detach
4072
- */
4073
- declare function detach(parent: Instance, child: Instance): void;
4074
- /**
4075
- * Compares old and new props to determine which properties have changed.
4076
- * Also handles resetting removed props for HMR/fast-refresh.
4077
- *
4078
- * @param instance - Instance to diff props for
4079
- * @param newProps - New props to compare against
4080
- * @returns Object containing only changed props
4081
- *
4082
- * @example
4083
- * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
4084
- * // => { position: [1, 2, 3] } (only if position changed)
4085
- */
4086
- declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
4087
- /**
4088
- * Applies a set of props to a Three.js object.
4089
- * Handles special cases like colors, vectors, textures, events, and pierced props.
4090
- *
4091
- * @param object - Three.js object to apply props to
4092
- * @param props - Props to apply
4093
- * @returns The object with props applied
4094
- *
4095
- * @example
4096
- * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
4097
- */
4098
- declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
4099
-
4100
- /**
4101
- * Calculates the device pixel ratio for rendering.
4102
- * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
4103
- *
4104
- * @param dpr - Target DPR value or [min, max] range
4105
- * @returns Calculated DPR value
4106
- *
4107
- * @example
4108
- * calculateDpr(2) // => 2
4109
- * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
4110
- */
4111
- declare function calculateDpr(dpr: Dpr): number;
4112
- /**
4113
- * Extracts the first segment of a UUID string (before the first hyphen).
4114
- * Used for creating unique material names when duplicates exist.
4115
- *
4116
- * @param uuid - UUID string to extract prefix from
4117
- * @returns First segment of the UUID
4118
- *
4119
- * @example
4120
- * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
4121
- */
4122
- declare function getUuidPrefix(uuid: string): string;
4123
- /**
4124
- * Updates camera projection based on viewport size.
4125
- * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
4126
- * Respects camera.manual flag - manual cameras are not modified.
4127
- *
4128
- * @param camera - Camera to update
4129
- * @param size - Current viewport size
4130
- */
4131
- declare function updateCamera(camera: ThreeCamera, size: Size): void;
4132
- /**
4133
- * Updates a frustum from a camera's projection and world matrices.
4134
- * If no target frustum is provided, creates and returns a new one.
4135
- *
4136
- * @param camera - Camera to extract frustum from
4137
- * @param frustum - Optional existing frustum to update (creates new if not provided)
4138
- * @returns The updated or newly created frustum
4139
- *
4140
- * @example
4141
- * // Create new frustum
4142
- * const frustum = updateFrustum(camera)
4143
- *
4144
- * // Update existing frustum (no allocation)
4145
- * updateFrustum(camera, existingFrustum)
4146
- *
4147
- * // Use for visibility checks
4148
- * if (frustum.containsPoint(point)) { ... }
4149
- * if (frustum.intersectsObject(mesh)) { ... }
4150
- */
4151
- declare function updateFrustum(camera: ThreeCamera, frustum?: Frustum): Frustum;
4152
-
4153
- declare const is: {
4154
- obj: (a: any) => boolean;
4155
- fun: (a: any) => a is Function;
4156
- str: (a: any) => a is string;
4157
- num: (a: any) => a is number;
4158
- boo: (a: any) => a is boolean;
4159
- und: (a: any) => boolean;
4160
- nul: (a: any) => boolean;
4161
- arr: (a: any) => a is any[];
4162
- equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
4163
- };
4164
- declare const isOrthographicCamera: (def: ThreeCamera) => def is OrthographicCamera;
4165
- declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
4166
- declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation$1;
4167
- declare const isObject3D: (object: any) => object is Object3D;
4168
- declare const isTexture: (value: unknown) => value is Texture$1;
4169
- type VectorLike = {
4170
- set: (...args: any[]) => void;
4171
- constructor?: Function;
4172
- };
4173
- declare const isVectorLike: (object: unknown) => object is VectorLike;
4174
- type Copyable = {
4175
- copy: (...args: any[]) => void;
4176
- constructor?: Function;
4177
- };
4178
- declare const isCopyable: (object: unknown) => object is Copyable;
4179
- declare const hasConstructor: (object: unknown) => object is {
4180
- constructor?: Function;
4181
- };
4182
-
4183
- /**
4184
- * Symbol marker for deferred ref resolution.
4185
- * Used to identify values that should be resolved from refs after mount.
4186
- */
4187
- declare const FROM_REF: unique symbol;
4188
- /**
4189
- * Defers prop application until the referenced object is available.
4190
- * Useful for props like `target` that need sibling refs to be populated.
4191
- *
4192
- * @param ref - React ref object to resolve at mount time
4193
- * @returns A marker value that applyProps will resolve after mount
4194
- *
4195
- * @example
4196
- * const targetRef = useRef<THREE.Object3D>(null)
4197
- *
4198
- * <group ref={targetRef} position={[-3, -2, -15]} />
4199
- * <spotLight target={fromRef(targetRef)} intensity={100} />
4200
- */
4201
- declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
4202
- /**
4203
- * Type guard to check if a value is a fromRef marker.
4204
- *
4205
- * @param value - Value to check
4206
- * @returns True if value is a fromRef marker
4207
- */
4208
- declare function isFromRef(value: unknown): value is {
4209
- [FROM_REF]: React$1.RefObject<any>;
4210
- };
4211
-
4212
- /**
4213
- * Symbol marker for mount-only method calls.
4214
- * Used to identify methods that should only be called once on initial mount.
4215
- */
4216
- declare const ONCE: unique symbol;
4217
- /**
4218
- * Marks a method call to be executed only on initial mount.
4219
- * Useful for geometry transforms that should not be reapplied on every render.
4220
- *
4221
- * When `args` prop changes (triggering reconstruction), the method will be
4222
- * called again on the new instance since appliedOnce is not carried over.
4223
- *
4224
- * @param args - Arguments to pass to the method
4225
- * @returns A marker value that applyProps will execute once
4226
- *
4227
- * @example
4228
- * // Rotate geometry on mount
4229
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
4230
- *
4231
- * // Multiple arguments
4232
- * <bufferGeometry applyMatrix4={once(matrix)} />
4233
- *
4234
- * // No arguments
4235
- * <geometry center={once()} />
4236
- */
4237
- declare function once<T>(...args: T[]): T;
4238
- /**
4239
- * Type guard to check if a value is a once marker.
4240
- *
4241
- * @param value - Value to check
4242
- * @returns True if value is a once marker
4243
- */
4244
- declare function isOnce(value: unknown): value is {
4245
- [ONCE]: any[] | true;
4246
- };
4247
-
4248
- /**
4249
- * A DOM canvas which accepts threejs elements as children.
4250
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
4251
- */
4252
- declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
4253
-
4254
- /**
4255
- * ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
4256
- *
4257
- * Provides TypeScript-friendly access to uniform/node stores where the runtime
4258
- * structure is `Record<string, T | Record<string, T>>` (leaf nodes or nested scopes).
4259
- *
4260
- * The wrapper uses a Proxy to:
4261
- * 1. Return `T` for property access (type assumption: assumes leaf node)
4262
- * 2. Provide `.scope(key)` method for explicit nested access
4263
- * 3. Support iteration methods: has(), keys(), Object.keys(), for...in
4264
- *
4265
- * @example
4266
- * ```tsx
4267
- * useLocalNodes(({ uniforms }) => ({
4268
- * wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
4269
- * playerHealth: uniforms.scope('player').uHealth // Explicit scope access
4270
- * }))
4271
- * ```
4272
- */
4273
-
4274
- /** Keys reserved for methods (excluded from index signature) */
4275
- type MethodKeys = 'scope' | 'has' | 'keys';
4276
- /**
4277
- * Type-safe wrapper interface for accessing nested store data.
4278
- * Property access returns `T` (assumes leaf node).
4279
- * Use `.scope(key)` for nested object access.
4280
- *
4281
- * Uses mapped type with key filtering to exclude method names from index signature,
4282
- * allowing methods to have their correct return types.
4283
- */
4284
- type ScopedStoreType<T> = {
4285
- /** Direct property access returns the leaf type T (method keys excluded) */
4286
- readonly [K in string as K extends MethodKeys ? never : K]: T;
4287
- } & {
4288
- /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
4289
- scope(key: string): ScopedStoreType<T>;
4290
- /** Check if a key exists in the store */
4291
- has(key: string): boolean;
4292
- /** Get all keys in the store */
4293
- keys(): string[];
4294
- };
4295
- /**
4296
- * Create a type-safe ScopedStore wrapper around store data.
4297
- * @param data - The raw store data (uniforms or nodes from RootState)
4298
- * @returns A ScopedStoreType wrapper with type-safe access
4299
- */
4300
- declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
4301
- /**
4302
- * State type passed to creator functions with ScopedStore wrappers.
4303
- * Provides type-safe access to uniforms and nodes without manual casting.
4304
- */
4305
- type CreatorState = Omit<RootState, 'uniforms' | 'nodes'> & {
4306
- /** Type-safe uniform access - property access returns UniformNode */
4307
- uniforms: ScopedStoreType<UniformNode>;
4308
- /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
4309
- nodes: ScopedStoreType<TSLNodeType>;
4310
- };
4311
-
4312
- /** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
4313
- type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: CreatorState) => T;
4314
- /** Function signature for removeUniforms util */
4315
- type RemoveUniformsFn = (names: string | string[], scope?: string) => void;
4316
- /** Function signature for clearUniforms util */
4317
- type ClearUniformsFn = (scope?: string) => void;
4318
- /** Function signature for rebuildUniforms util */
4319
- type RebuildUniformsFn = (scope?: string) => void;
4320
- /** Return type with utils included */
4321
- type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
4322
- removeUniforms: RemoveUniformsFn;
4323
- clearUniforms: ClearUniformsFn;
4324
- rebuildUniforms: RebuildUniformsFn;
4325
- };
4326
- declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
4327
- declare function useUniforms(scope: string): UniformsWithUtils;
4328
- declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformRecord<UniformNode>>;
4329
- declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4330
- declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
4331
- declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4332
- /**
4333
- * Global rebuildUniforms function for HMR integration.
4334
- * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
4335
- * Call this when HMR is detected to refresh all uniform creators.
4336
- *
4337
- * @param store - The R3F store (from useStore or context)
4338
- * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4339
- */
4340
- declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?: string): void;
4341
- /**
4342
- * Remove uniforms by name from root level or a scope
4343
- * @deprecated Use `const { removeUniforms } = useUniforms()` instead
4344
- */
4345
- declare function removeUniforms(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
4346
- /**
4347
- * Clear all uniforms from a scope (removes the entire scope object)
4348
- * @deprecated Use `const { clearUniforms } = useUniforms()` instead
4349
- */
4350
- declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
4351
- /**
4352
- * Clear all root-level uniforms (preserves scopes)
4353
- * @deprecated Use `const { clearUniforms } = useUniforms()` with `clearUniforms('root')` instead
4354
- */
4355
- declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
4356
-
4357
- /**
4358
- * Supported uniform value types:
4359
- * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
4360
- * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
4361
- * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
4362
- * - UniformNode: existing uniforms (reused as-is)
4363
- */
4364
- type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
4365
- /**
4366
- * Widen literal types to their base types:
4367
- * - 0 → number
4368
- * - true → boolean
4369
- * - '#ff0000' → Color (string colors are converted to Color objects)
4370
- * - Node → Node (TSL nodes passed through for uniform type casting)
4371
- */
4372
- type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
4373
- declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
4374
- declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
4375
-
4376
- /**
4377
- * Minimal interface for TSL nodes.
4378
- * Used instead of Three.js's Node type because the @types/three definitions
4379
- * have inconsistencies where OperatorNode, ConstNode, etc. don't properly
4380
- * extend Node with all required properties.
4381
- */
4382
- interface TSLNodeLike {
4383
- uuid?: string;
4384
- nodeType?: string | null;
4385
- /** label method for chaining - sets the node's label and returns self */
4386
- label?: ((label: string) => TSLNodeLike) | string;
4387
- setName?: (name: string) => this;
4388
- }
4389
- /** TSL node type - alias for compatibility */
4390
- type TSLNode = TSLNodeLike;
4391
- /**
4392
- * A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
4393
- * Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
4394
- */
4395
- type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
4396
- /**
4397
- * Creator function that returns a record of nodes.
4398
- * Uses TSLNodeLike constraint to allow mixed node types
4399
- * (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
4400
- */
4401
- type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
4402
- /** Function signature for removeNodes util */
4403
- type RemoveNodesFn = (names: string | string[], scope?: string) => void;
4404
- /** Function signature for clearNodes util */
4405
- type ClearNodesFn = (scope?: string) => void;
4406
- /** Function signature for rebuildNodes util */
4407
- type RebuildNodesFn = (scope?: string) => void;
4408
- /** Return type with utils included */
4409
- type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
4410
- removeNodes: RemoveNodesFn;
4411
- clearNodes: ClearNodesFn;
4412
- rebuildNodes: RebuildNodesFn;
4413
- };
4414
- declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
4415
- declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
4416
- declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
4417
- declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
4418
- /**
4419
- * Global rebuildNodes function for HMR integration.
4420
- * Clears cached nodes and increments _hmrVersion to trigger re-creation.
4421
- * Call this when HMR is detected to refresh all node creators.
4422
- *
4423
- * @param store - The R3F store (from useStore or context)
4424
- * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4425
- */
4426
- declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: string): void;
4427
- /**
4428
- * Remove nodes by name from root level or a scope
4429
- * @deprecated Use `const { removeNodes } = useNodes()` instead
4430
- */
4431
- declare function removeNodes(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
4432
- /**
4433
- * Clear all nodes from a scope (removes the entire scope object)
4434
- * @deprecated Use `const { clearNodes } = useNodes()` instead
4435
- */
4436
- declare function clearNodeScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
4437
- /**
4438
- * Clear all root-level nodes (preserves scopes)
4439
- * @deprecated Use `const { clearNodes } = useNodes()` with `clearNodes('root')` instead
4440
- */
4441
- declare function clearRootNodes(set: ReturnType<typeof useStore>['setState']): void;
4442
-
4443
- /** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
4444
- type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
4445
- /**
4446
- * Creates local values that rebuild when uniforms, nodes, or textures change.
4447
- *
4448
- * Unlike `useNodes`, this does NOT register to the global store.
4449
- * Use for component-specific nodes/values that depend on shared resources.
4450
- *
4451
- * @example
4452
- * ```tsx
4453
- * // Destructure what you need from state
4454
- * const { wobble, uTime } = useLocalNodes(({ uniforms, nodes }) => ({
4455
- * wobble: sin(uniforms.uTime.mul(2)),
4456
- * uTime: uniforms.uTime, // can return uniforms too
4457
- * }))
4458
- *
4459
- * // Or access anything else from RootState
4460
- * const { scaled } = useLocalNodes(({ camera, nodes }) => ({
4461
- * scaled: nodes.basePos.mul(camera.zoom),
4462
- * }))
4463
- *
4464
- * // Type-safe uniform access
4465
- * const { colorNode } = useLocalNodes(({ uniforms }) => {
4466
- * const uValue = uniforms.myUniform as UniformNode<number>
4467
- * return { colorNode: mix(colorA, colorB, uValue) }
4468
- * })
4469
- * ```
4470
- */
4471
- declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
9
+ import { FrameCallback, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
10
+ export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
11
+ import { JSX } from 'react';
12
+ import 'react-use-measure';
13
+ import 'zustand/traditional';
14
+ import 'three/tsl';
15
+
16
+ /**
17
+ * The `ReactThreeFiber` namespace of the WebGPU 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 webgpu_d_Color = Color;
54
+ type webgpu_d_ElementOf<E, K extends string> = ElementOf<E, K>;
55
+ type webgpu_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
56
+ type webgpu_d_Euler = Euler;
57
+ type webgpu_d_EventProps<P> = EventProps<P>;
58
+ type webgpu_d_GeometryProps<P> = GeometryProps<P>;
59
+ type webgpu_d_GeometryTransformProps = GeometryTransformProps;
60
+ type webgpu_d_Layers = Layers;
61
+ type webgpu_d_MathProps<P> = MathProps<P>;
62
+ type webgpu_d_MathRepresentation = MathRepresentation;
63
+ type webgpu_d_MathType<T extends MathTypes$1> = MathType<T>;
64
+ type webgpu_d_MathTypes = MathTypes;
65
+ type webgpu_d_Matrix3 = Matrix3;
66
+ type webgpu_d_Matrix4 = Matrix4;
67
+ type webgpu_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
68
+ type webgpu_d_NodeProps<P> = NodeProps<P>;
69
+ type webgpu_d_Object3DMethod = Object3DMethod;
70
+ type webgpu_d_Quaternion = Quaternion;
71
+ type webgpu_d_RaycastableRepresentation = RaycastableRepresentation;
72
+ type webgpu_d_ReactProps<P> = ReactProps<P>;
73
+ type webgpu_d_TSLNodeInput = TSLNodeInput;
74
+ type webgpu_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
75
+ type webgpu_d_ThreeElements = ThreeElements;
76
+ type webgpu_d_ThreeElementsOf<T extends Record<string, any>> = ThreeElementsOf<T>;
77
+ type webgpu_d_ThreeExports = ThreeExports;
78
+ type webgpu_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
79
+ type webgpu_d_Vector2 = Vector2;
80
+ type webgpu_d_Vector3 = Vector3;
81
+ type webgpu_d_Vector4 = Vector4;
82
+ type webgpu_d_VectorRepresentation = VectorRepresentation;
83
+ declare namespace webgpu_d {
84
+ export type { webgpu_d_Color as Color, webgpu_d_ElementOf as ElementOf, webgpu_d_ElementProps as ElementProps, webgpu_d_Euler as Euler, webgpu_d_EventProps as EventProps, webgpu_d_GeometryProps as GeometryProps, webgpu_d_GeometryTransformProps as GeometryTransformProps, webgpu_d_Layers as Layers, webgpu_d_MathProps as MathProps, webgpu_d_MathRepresentation as MathRepresentation, webgpu_d_MathType as MathType, webgpu_d_MathTypes as MathTypes, webgpu_d_Matrix3 as Matrix3, webgpu_d_Matrix4 as Matrix4, webgpu_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, webgpu_d_NodeProps as NodeProps, webgpu_d_Object3DMethod as Object3DMethod, webgpu_d_Quaternion as Quaternion, webgpu_d_RaycastableRepresentation as RaycastableRepresentation, webgpu_d_ReactProps as ReactProps, webgpu_d_TSLNodeInput as TSLNodeInput, webgpu_d_ThreeElement as ThreeElement, webgpu_d_ThreeElements as ThreeElements, webgpu_d_ThreeElementsOf as ThreeElementsOf, webgpu_d_ThreeExports as ThreeExports, webgpu_d_ThreeToJSXElements as ThreeToJSXElements, webgpu_d_Vector2 as Vector2, webgpu_d_Vector3 as Vector3, webgpu_d_Vector4 as Vector4, webgpu_d_VectorRepresentation as VectorRepresentation };
85
+ }
86
+
87
+ /**
88
+ * Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
89
+ *
90
+ * This file maintains backwards compatibility for existing webgpu imports.
91
+ */
92
+
93
+ /**
94
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
95
+ * Kept as an alias for backwards compatibility.
96
+ */
97
+ type TextureEntry = Texture;
98
+ /**
99
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
100
+ * Kept as an alias for backwards compatibility.
101
+ */
102
+ type TextureNode = Texture;
4472
103
 
4473
104
  interface TextureOperations {
4474
105
  add: (key: string, value: any) => void;
@@ -4478,45 +109,6 @@ interface TextureOperations {
4478
109
  }
4479
110
  declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
4480
111
 
4481
- /**
4482
- * Hook for managing WebGPU PostProcessing with automatic scenePass setup.
4483
- *
4484
- * Features:
4485
- * - Creates PostProcessing instance if not exists
4486
- * - Creates default scenePass (no MRT) automatically
4487
- * - Callbacks receive full RootState for flexibility
4488
- * - No auto-cleanup on unmount - use reset() for explicit cleanup
4489
- * - Scene/camera changes trigger scenePass recreation
4490
- *
4491
- * @param mainCB - Main callback to configure outputNode and create effect passes
4492
- * @param setupCB - Optional setup callback to configure MRT on scenePass
4493
- * @returns { passes, postProcessing, clearPasses, reset, rebuild }
4494
- *
4495
- * @example
4496
- * ```tsx
4497
- * // Simple effect
4498
- * usePostProcessing(({ postProcessing, passes }) => {
4499
- * postProcessing.outputNode = bloom(passes.scenePass.getTextureNode())
4500
- * })
4501
- *
4502
- * // With MRT setup
4503
- * usePostProcessing(
4504
- * ({ postProcessing, passes }) => {
4505
- * const beauty = passes.scenePass.getTextureNode().toInspector('Color')
4506
- * const vel = passes.scenePass.getTextureNode('velocity')
4507
- * postProcessing.outputNode = motionBlur(beauty, vel)
4508
- * },
4509
- * ({ passes }) => {
4510
- * passes.scenePass.setMRT(mrt({ output, velocity }))
4511
- * }
4512
- * )
4513
- *
4514
- * // Read-only access
4515
- * const { postProcessing, passes } = usePostProcessing()
4516
- * ```
4517
- */
4518
- declare function usePostProcessing(mainCB?: PostProcessingMainCallback, setupCB?: PostProcessingSetupCallback): UsePostProcessingReturn;
4519
-
4520
112
  //* Renderer Props ========================================
4521
113
 
4522
114
  type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
@@ -4564,5 +156,46 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
4564
156
  internal: WebGPUInternalState
4565
157
  }
4566
158
 
4567
- 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, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllNodes, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, usePostProcessing, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
4568
- export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearNodesFn, ClearUniformsFn, Color, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildNodesFn, RebuildUniformsFn, ReconcilerRoot, RemoveNodesFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureOperations, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager };
159
+ declare const R3F_BUILD_LEGACY = false;
160
+ declare const R3F_BUILD_WEBGPU = true;
161
+ /** Create a root that always constructs a WebGPURenderer. */
162
+ declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
163
+
164
+ /** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
165
+ type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
166
+ /** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
167
+ type UseFrameWebGPU = (callback?: FrameCallback<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
168
+ declare const useThree: UseThreeWebGPU;
169
+ declare const useFrame: UseFrameWebGPU;
170
+ /** `useRenderTarget` narrowed to the target this entry's renderer produces. */
171
+ declare const useRenderTarget: {
172
+ (options?: RenderTargetOptions): RenderTarget;
173
+ (size: number, options?: RenderTargetOptions): RenderTarget;
174
+ (width: number, height: number, options?: RenderTargetOptions): RenderTarget;
175
+ };
176
+
177
+ /** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
178
+ type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
179
+ /** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
180
+ onCreated?: (state: WebGPURootState) => void;
181
+ };
182
+
183
+ /**
184
+ * A DOM canvas which accepts threejs elements as children, rendered with WebGPU. `onCreated` is
185
+ * typed against `WebGPURootState`.
186
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
187
+ */
188
+ declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
189
+ /** Three.js constructors available as JSX elements on this entry. */
190
+ type ThreeExports = typeof ThreeWebGPU;
191
+ interface ThreeElements extends ThreeElementsOf$1<ThreeExports> {
192
+ }
193
+ declare module 'react' {
194
+ namespace JSX {
195
+ interface IntrinsicElements extends ThreeElements {
196
+ }
197
+ }
198
+ }
199
+
200
+ export { BaseRendererProps, RootState as BaseRootState, Canvas, Color$1 as Color, ConstructorRepresentation, ElementOf$1 as ElementOf, ElementProps$1 as ElementProps, Euler$1 as Euler, EventProps$1 as EventProps, GeometryProps$1 as GeometryProps, GeometryTransformProps$1 as GeometryTransformProps, Layers$1 as Layers, MathProps$1 as MathProps, MathRepresentation$1 as MathRepresentation, MathType$1 as MathType, MathTypes$1 as MathTypes, Matrix3$1 as Matrix3, Matrix4$1 as Matrix4, MutableOrReadonlyParameters$1 as MutableOrReadonlyParameters, NodeProps$1 as NodeProps, Object3DMethod$1 as Object3DMethod, Properties, Quaternion$1 as Quaternion, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, RaycastableRepresentation$1 as RaycastableRepresentation, ReactProps$1 as ReactProps, webgpu_d as ReactThreeFiber, ReconcilerRoot, RenderTargetOptions, RendererFactory, TSLNodeInput$1 as TSLNodeInput, ThreeElement$1 as ThreeElement, ThreeElementsOf$1 as ThreeElementsOf, ThreeToJSXElements$1 as ThreeToJSXElements, Vector2$1 as Vector2, Vector3$1 as Vector3, Vector4$1 as Vector4, VectorRepresentation$1 as VectorRepresentation, createRoot, createTextureOperations, useFrame, useRenderTarget, useThree };
201
+ export type { WebGPUCanvasProps as CanvasProps, WebGPUInternalState as InternalState, WebGPUR3FRenderer as R3FRenderer, WebGPURootState as RootState, TextureEntry, TextureNode, TextureOperations, ThreeElements, ThreeExports, UseFrameWebGPU, UseThreeWebGPU, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig };