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