@react-three/fiber 10.0.0-canary.bc9af3b → 10.0.0-canary.bf4b0be

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