@react-three/fiber 10.0.0-canary.f81281f → 10.0.0-canary.fbd44ae
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/extension.cjs +8 -7
- package/dist/extension.d.cts +10 -47
- package/dist/extension.d.mts +10 -47
- package/dist/extension.d.ts +10 -47
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.mjs +3 -3
- package/dist/legacy.cjs +13 -13
- package/dist/legacy.d.cts +10 -7
- package/dist/legacy.d.mts +10 -7
- package/dist/legacy.d.ts +10 -7
- package/dist/legacy.mjs +4 -4
- package/dist/shared/{fiber.DAg-9ieU.d.ts → fiber.3jeDXXYd.d.mts} +183 -542
- package/dist/shared/{fiber.Ddgoyqql.d.mts → fiber.B_KQAb3I.d.ts} +183 -542
- package/dist/shared/fiber.Bi_S5KAx.cjs +16630 -0
- package/dist/shared/fiber.C6hitYDY.d.cts +48 -0
- package/dist/shared/fiber.CFK811nR.mjs +16532 -0
- package/dist/shared/{fiber.Bw8YnGg5.d.ts → fiber.C_MFx7We.d.cts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.cts → fiber.C_MFx7We.d.mts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.mts → fiber.C_MFx7We.d.ts} +555 -19
- package/dist/shared/fiber.D4fD6H74.d.mts +48 -0
- package/dist/shared/{fiber.C_v1rkNg.mjs → fiber.QxL_6jra.mjs} +113 -52
- package/dist/shared/fiber.YgTUGbja.d.ts +48 -0
- package/dist/shared/{fiber.B6zNSmwj.cjs → fiber.eR9ie2vQ.cjs} +116 -50
- package/dist/shared/{fiber.DiPB625B.d.cts → fiber.fR3DaJb1.d.cts} +183 -542
- package/dist/webgpu/index.cjs +13 -13
- package/dist/webgpu/index.d.cts +5 -6
- package/dist/webgpu/index.d.mts +5 -6
- package/dist/webgpu/index.d.ts +5 -6
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +7 -7
- package/readme.md +1 -1
- package/dist/shared/fiber.BGL2rpse.cjs +0 -15129
- package/dist/shared/fiber.Ch4JrXS2.mjs +0 -15031
|
@@ -1,316 +1,10 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
3
3
|
import { Options } from 'react-use-measure';
|
|
4
|
+
import { al as RenderProps, m as ConstructorRepresentation, aJ as ObjectMap, a8 as BaseRendererProps, a9 as RendererFactory, aA as Properties, I as InternalState, J as RootState, E as Euler$1, K as RootStore, a4 as EventManager, _ as DomEvent, aw as Instance, o as ThreeElement, as as Catalogue, ap as Root, am as InjectState, aR as ThreeCore, aG as Bridge, aI as UnblockProps, aL as Disposable, D as Dpr, aE as ThreeCamera, z as Size, aK as EquConfig } from './fiber.C_MFx7We.mjs';
|
|
4
5
|
import * as THREE from 'three';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
|
|
8
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
//* Base Renderer Types =====================================
|
|
11
|
-
|
|
12
|
-
// Shim for OffscreenCanvas since it was removed from DOM types
|
|
13
|
-
interface OffscreenCanvas$1 extends EventTarget {}
|
|
14
|
-
|
|
15
|
-
interface BaseRendererProps {
|
|
16
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
17
|
-
powerPreference?: 'high-performance' | 'low-power' | 'default'
|
|
18
|
-
antialias?: boolean
|
|
19
|
-
alpha?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type RendererFactory<TRenderer, TParams> =
|
|
23
|
-
| TRenderer
|
|
24
|
-
| ((defaultProps: TParams) => TRenderer)
|
|
25
|
-
| ((defaultProps: TParams) => Promise<TRenderer>)
|
|
26
|
-
|
|
27
|
-
interface Renderer {
|
|
28
|
-
render: (scene: THREE.Scene, camera: THREE.Camera) => any
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//* Color Management Config ==============================
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
35
|
-
*/
|
|
36
|
-
interface ColorManagementConfig {
|
|
37
|
-
/**
|
|
38
|
-
* Color space assigned to 8-bit input textures (color maps).
|
|
39
|
-
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
40
|
-
* @default THREE.SRGBColorSpace
|
|
41
|
-
*/
|
|
42
|
-
textureColorSpace?: THREE.ColorSpace
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//* WebGL Renderer Props ==============================
|
|
46
|
-
|
|
47
|
-
type DefaultGLProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
|
|
48
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type GLProps =
|
|
52
|
-
| Renderer
|
|
53
|
-
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
54
|
-
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
55
|
-
| (Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> & ColorManagementConfig)
|
|
56
|
-
|
|
57
|
-
//* WebGPU Renderer Props ==============================
|
|
58
|
-
|
|
59
|
-
type DefaultRendererProps = {
|
|
60
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
61
|
-
[key: string]: any
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Canvas-level scheduler configuration.
|
|
66
|
-
* Controls render timing relative to other canvases.
|
|
67
|
-
*/
|
|
68
|
-
interface CanvasSchedulerConfig {
|
|
69
|
-
/**
|
|
70
|
-
* Run this Canvas root before the referenced Canvas root id(s).
|
|
71
|
-
*/
|
|
72
|
-
before?: string | string[]
|
|
73
|
-
/**
|
|
74
|
-
* Run this Canvas root after the referenced Canvas root id(s).
|
|
75
|
-
*/
|
|
76
|
-
after?: string | string[]
|
|
77
|
-
/**
|
|
78
|
-
* Numeric root order. Lower values run first.
|
|
79
|
-
*/
|
|
80
|
-
order?: number
|
|
81
|
-
/**
|
|
82
|
-
* Limit this Canvas's default render job (frames per second).
|
|
83
|
-
*/
|
|
84
|
-
fps?: number
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Extended renderer configuration for multi-canvas support and color management.
|
|
89
|
-
*/
|
|
90
|
-
interface RendererConfigExtended extends ColorManagementConfig {
|
|
91
|
-
/** Share renderer from another canvas (WebGPU only) */
|
|
92
|
-
primaryCanvas?: string
|
|
93
|
-
/** Canvas-level scheduler options */
|
|
94
|
-
scheduler?: CanvasSchedulerConfig
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The `renderer` prop: opt into three's WebGPU renderer.
|
|
99
|
-
* - `true` (the `<Canvas renderer>` shorthand) or `{}`: a default `WebGPURenderer`
|
|
100
|
-
* - a props bag: constructor parameters (`antialias`, `forceWebGL`, ...) and renderer properties
|
|
101
|
-
* (`toneMapping`, ...), plus `textureColorSpace`, `primaryCanvas` and `scheduler`
|
|
102
|
-
* - a renderer instance, or a sync/async factory receiving the default props. Structural, like
|
|
103
|
-
* the `gl` prop: anything with `render()`, so a wrapped or mocked renderer is accepted.
|
|
104
|
-
*/
|
|
105
|
-
type RendererProps =
|
|
106
|
-
| boolean
|
|
107
|
-
| Renderer
|
|
108
|
-
| ((defaultProps: DefaultRendererProps) => Renderer)
|
|
109
|
-
| ((defaultProps: DefaultRendererProps) => Promise<Renderer>)
|
|
110
|
-
| (Partial<Properties<WebGPURenderer> & WebGPURendererParameters> & RendererConfigExtended)
|
|
111
|
-
|
|
112
|
-
//* Camera Props ==============================
|
|
113
|
-
|
|
114
|
-
type CameraProps = (
|
|
115
|
-
| THREE.Camera
|
|
116
|
-
| Partial<
|
|
117
|
-
ThreeElement<typeof THREE.Camera> &
|
|
118
|
-
ThreeElement<typeof THREE.PerspectiveCamera> &
|
|
119
|
-
ThreeElement<typeof THREE.OrthographicCamera>
|
|
120
|
-
>
|
|
121
|
-
) & {
|
|
122
|
-
/** Flags the camera as manual, putting projection into your own hands */
|
|
123
|
-
manual?: boolean
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//* Render Props ==============================
|
|
127
|
-
|
|
128
|
-
interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
129
|
-
/**
|
|
130
|
-
* Unique identifier for multi-canvas renderer sharing.
|
|
131
|
-
* Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
|
|
132
|
-
* Also sets the HTML `id` attribute on the canvas element.
|
|
133
|
-
* @example <Canvas id="main-viewer">...</Canvas>
|
|
134
|
-
*/
|
|
135
|
-
id?: string
|
|
136
|
-
/**
|
|
137
|
-
* Share the renderer from another canvas instead of creating a new one.
|
|
138
|
-
* Pass the `id` of the primary canvas to share its WebGPURenderer.
|
|
139
|
-
* Only available with WebGPU (not legacy WebGL).
|
|
140
|
-
*
|
|
141
|
-
* Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
|
|
142
|
-
* @internal
|
|
143
|
-
*/
|
|
144
|
-
primaryCanvas?: string
|
|
145
|
-
/**
|
|
146
|
-
* Canvas-level scheduler options. Controls render timing relative to other canvases.
|
|
147
|
-
*
|
|
148
|
-
* Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
|
|
149
|
-
* @internal
|
|
150
|
-
*/
|
|
151
|
-
scheduler?: CanvasSchedulerConfig
|
|
152
|
-
/** A threejs renderer instance or props that go into the default renderer */
|
|
153
|
-
gl?: GLProps
|
|
154
|
-
/** A WebGPU renderer instance or props that go into the default renderer */
|
|
155
|
-
renderer?: RendererProps
|
|
156
|
-
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
157
|
-
size?: Size
|
|
158
|
-
/**
|
|
159
|
-
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
160
|
-
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
161
|
-
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
162
|
-
*/
|
|
163
|
-
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
|
|
164
|
-
/** Creates an orthographic camera */
|
|
165
|
-
orthographic?: boolean
|
|
166
|
-
/**
|
|
167
|
-
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
168
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
169
|
-
*/
|
|
170
|
-
frameloop?: Frameloop
|
|
171
|
-
/**
|
|
172
|
-
* R3F performance options for adaptive performance.
|
|
173
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
174
|
-
*/
|
|
175
|
-
performance?: Partial<Omit<Performance, 'regress'>>
|
|
176
|
-
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
177
|
-
dpr?: Dpr
|
|
178
|
-
/**
|
|
179
|
-
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
180
|
-
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
181
|
-
*/
|
|
182
|
-
raycaster?: Partial<Omit<THREE.Raycaster, 'params'>> & { params?: Partial<THREE.RaycasterParameters> }
|
|
183
|
-
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
184
|
-
scene?: THREE.Scene | Partial<THREE.Scene>
|
|
185
|
-
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
186
|
-
camera?: CameraProps
|
|
187
|
-
/** An R3F event manager to manage elements' pointer events */
|
|
188
|
-
events?: (store: RootStore) => EventManager<Element>
|
|
189
|
-
/** Callback after the canvas has rendered (but not yet committed) */
|
|
190
|
-
onCreated?: (state: RootState) => void
|
|
191
|
-
/** Response for pointer clicks that have missed any target */
|
|
192
|
-
onPointerMissed?: (event: MouseEvent) => void
|
|
193
|
-
/** Response for dragover events that have missed any target */
|
|
194
|
-
onDragOverMissed?: (event: DragEvent) => void
|
|
195
|
-
/** Response for drop events that have missed any target */
|
|
196
|
-
onDropMissed?: (event: DragEvent) => void
|
|
197
|
-
/** Whether to automatically update the frustum each frame (default: true) */
|
|
198
|
-
autoUpdateFrustum?: boolean
|
|
199
|
-
/**
|
|
200
|
-
* Enable WebGPU occlusion queries for onOccluded/onVisible events.
|
|
201
|
-
* Auto-enabled when any object uses onOccluded or onVisible handlers.
|
|
202
|
-
* Only works with WebGPU renderer - WebGL will log a warning.
|
|
203
|
-
*/
|
|
204
|
-
occlusion?: boolean
|
|
205
|
-
/** Internal: stored size props from Canvas for reset functionality */
|
|
206
|
-
_sizeProps?: { width?: number; height?: number } | null
|
|
207
|
-
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
208
|
-
forceEven?: boolean
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//* Reconciler Root ==============================
|
|
212
|
-
|
|
213
|
-
interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
214
|
-
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
|
|
215
|
-
render: (element: ReactNode) => RootStore
|
|
216
|
-
unmount: () => void
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
//* Inject State ==============================
|
|
220
|
-
|
|
221
|
-
type InjectState = Partial<
|
|
222
|
-
Omit<RootState, 'events'> & {
|
|
223
|
-
events?: {
|
|
224
|
-
enabled?: boolean
|
|
225
|
-
priority?: number
|
|
226
|
-
compute?: ComputeFunction
|
|
227
|
-
connected?: any
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
|
|
231
|
-
* This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
|
|
232
|
-
* Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
|
|
233
|
-
*/
|
|
234
|
-
injectScene?: boolean
|
|
235
|
-
}
|
|
236
|
-
>
|
|
237
|
-
|
|
238
|
-
//* Reconciler Types ==============================
|
|
239
|
-
|
|
240
|
-
// FiberRoot is an opaque internal React type - we define it locally
|
|
241
|
-
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
242
|
-
type FiberRoot = any
|
|
243
|
-
|
|
244
|
-
interface Root {
|
|
245
|
-
fiber: FiberRoot
|
|
246
|
-
store: RootStore
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
250
|
-
type AttachType<O = any> = string | AttachFnType<O>
|
|
251
|
-
|
|
252
|
-
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
253
|
-
|
|
254
|
-
interface Catalogue {
|
|
255
|
-
[name: string]: ConstructorRepresentation
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// TODO: handle constructor overloads
|
|
259
|
-
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
260
|
-
// https://github.com/microsoft/TypeScript/issues/37079
|
|
261
|
-
type Args<T> = T extends ConstructorRepresentation
|
|
262
|
-
? T extends typeof Color$1
|
|
263
|
-
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
264
|
-
: ConstructorParameters<T>
|
|
265
|
-
: any[]
|
|
266
|
-
|
|
267
|
-
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
268
|
-
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
269
|
-
? { args?: Args<P> }
|
|
270
|
-
: { args: Args<P> }
|
|
271
|
-
: { args: unknown[] }
|
|
272
|
-
|
|
273
|
-
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
274
|
-
object?: T
|
|
275
|
-
dispose?: null
|
|
276
|
-
attach?: AttachType<T>
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
interface Instance<O = any> {
|
|
280
|
-
root: RootStore
|
|
281
|
-
type: string
|
|
282
|
-
parent: Instance | null
|
|
283
|
-
children: Instance[]
|
|
284
|
-
props: InstanceProps<O> & Record<string, unknown>
|
|
285
|
-
object: O & { __r3f?: Instance<O> }
|
|
286
|
-
eventCount: number
|
|
287
|
-
handlers: Partial<EventHandlers>
|
|
288
|
-
attach?: AttachType<O>
|
|
289
|
-
previousAttach?: any
|
|
290
|
-
isHidden: boolean
|
|
291
|
-
/** Set of props that have been applied via once() */
|
|
292
|
-
appliedOnce?: Set<string>
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
interface HostConfig {
|
|
296
|
-
type: string
|
|
297
|
-
props: Instance['props']
|
|
298
|
-
container: RootStore
|
|
299
|
-
instance: Instance
|
|
300
|
-
textInstance: void
|
|
301
|
-
suspenseInstance: Instance
|
|
302
|
-
hydratableInstance: never
|
|
303
|
-
formInstance: never
|
|
304
|
-
publicInstance: Instance['object']
|
|
305
|
-
hostContext: {}
|
|
306
|
-
childSet: never
|
|
307
|
-
timeoutHandle: number | undefined
|
|
308
|
-
noTimeout: -1
|
|
309
|
-
TransitionStatus: null
|
|
310
|
-
}
|
|
311
|
-
declare global {
|
|
312
|
-
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
313
|
-
}
|
|
6
|
+
import { ColorRepresentation, Euler, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
|
|
7
|
+
import { WebGPURenderer } from 'three/webgpu';
|
|
314
8
|
|
|
315
9
|
//* Loop Types ==============================
|
|
316
10
|
|
|
@@ -345,12 +39,12 @@ interface BackgroundConfig {
|
|
|
345
39
|
files?: string | string[]
|
|
346
40
|
/** Separate files for scene.background (visual backdrop) */
|
|
347
41
|
backgroundMap?: string | string[]
|
|
348
|
-
backgroundRotation?: Euler
|
|
42
|
+
backgroundRotation?: Euler | [number, number, number]
|
|
349
43
|
backgroundBlurriness?: number
|
|
350
44
|
backgroundIntensity?: number
|
|
351
45
|
/** Separate files for scene.environment (PBR lighting/reflections) */
|
|
352
46
|
envMap?: string | string[]
|
|
353
|
-
environmentRotation?: Euler
|
|
47
|
+
environmentRotation?: Euler | [number, number, number]
|
|
354
48
|
environmentIntensity?: number
|
|
355
49
|
path?: string
|
|
356
50
|
extensions?: (loader: Loader) => void
|
|
@@ -400,9 +94,7 @@ type BackgroundProp =
|
|
|
400
94
|
//* Canvas Types ==============================
|
|
401
95
|
|
|
402
96
|
interface CanvasProps
|
|
403
|
-
extends
|
|
404
|
-
Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
|
|
405
|
-
React$1.HTMLAttributes<HTMLDivElement> {
|
|
97
|
+
extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
|
|
406
98
|
children?: React$1.ReactNode
|
|
407
99
|
ref?: React$1.Ref<HTMLCanvasElement>
|
|
408
100
|
/** Canvas fallback content, similar to img's alt prop */
|
|
@@ -521,205 +213,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
521
213
|
|
|
522
214
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
523
215
|
|
|
524
|
-
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
525
|
-
|
|
526
|
-
interface MathRepresentation {
|
|
527
|
-
set(...args: number[]): any
|
|
528
|
-
}
|
|
529
|
-
interface VectorRepresentation extends MathRepresentation {
|
|
530
|
-
setScalar(value: number): any
|
|
531
|
-
}
|
|
532
|
-
type MathTypes = MathRepresentation | THREE.Euler | THREE.Color
|
|
533
|
-
|
|
534
|
-
type MathType<T extends MathTypes> = T extends THREE.Color
|
|
535
|
-
? Args<typeof THREE.Color> | THREE.ColorRepresentation
|
|
536
|
-
: T extends VectorRepresentation | THREE.Layers | THREE.Euler
|
|
537
|
-
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
538
|
-
: T | MutableOrReadonlyParameters<T['set']>
|
|
539
|
-
|
|
540
|
-
type MathProps<P> = {
|
|
541
|
-
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
type Vector2 = MathType<THREE.Vector2>
|
|
545
|
-
type Vector3 = MathType<THREE.Vector3>
|
|
546
|
-
type Vector4 = MathType<THREE.Vector4>
|
|
547
|
-
type Color = MathType<THREE.Color>
|
|
548
|
-
type Layers = MathType<THREE.Layers>
|
|
549
|
-
type Quaternion = MathType<THREE.Quaternion>
|
|
550
|
-
type Euler = MathType<THREE.Euler>
|
|
551
|
-
type Matrix3 = MathType<THREE.Matrix3>
|
|
552
|
-
type Matrix4 = MathType<THREE.Matrix4>
|
|
553
|
-
|
|
554
|
-
interface RaycastableRepresentation {
|
|
555
|
-
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
|
|
556
|
-
}
|
|
557
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Props for geometry transform methods that can be called with `once()`.
|
|
561
|
-
* These methods modify the geometry in-place and only make sense to call once on mount.
|
|
562
|
-
*
|
|
563
|
-
* @example
|
|
564
|
-
* import { once } from '@react-three/fiber'
|
|
565
|
-
*
|
|
566
|
-
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
567
|
-
* <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
|
|
568
|
-
* <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
|
|
569
|
-
*/
|
|
570
|
-
interface GeometryTransformProps {
|
|
571
|
-
/** Rotate the geometry about the X axis (radians). Use with once(). */
|
|
572
|
-
rotateX?: number
|
|
573
|
-
/** Rotate the geometry about the Y axis (radians). Use with once(). */
|
|
574
|
-
rotateY?: number
|
|
575
|
-
/** Rotate the geometry about the Z axis (radians). Use with once(). */
|
|
576
|
-
rotateZ?: number
|
|
577
|
-
/** Translate the geometry (x, y, z). Use with once(). */
|
|
578
|
-
translate?: [x: number, y: number, z: number]
|
|
579
|
-
/** Scale the geometry (x, y, z). Use with once(). */
|
|
580
|
-
scale?: [x: number, y: number, z: number]
|
|
581
|
-
/** Center the geometry based on bounding box. Use with once(). */
|
|
582
|
-
center?: true
|
|
583
|
-
/** Apply a Matrix4 transformation. Use with once(). */
|
|
584
|
-
applyMatrix4?: THREE.Matrix4
|
|
585
|
-
/** Apply a Quaternion rotation. Use with once(). */
|
|
586
|
-
applyQuaternion?: THREE.Quaternion
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
type GeometryProps<P> = P extends THREE.BufferGeometry ? GeometryTransformProps : {}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Workaround for @types/three TSL node type issues.
|
|
593
|
-
* The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
|
|
594
|
-
* This transforms `Node | null` properties to accept any object with node-like shape.
|
|
595
|
-
*/
|
|
596
|
-
type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
600
|
-
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
601
|
-
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
602
|
-
*/
|
|
603
|
-
type NodeProps<P> = {
|
|
604
|
-
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
interface ReactProps<P> {
|
|
608
|
-
children?: React.ReactNode
|
|
609
|
-
ref?: React.Ref<P>
|
|
610
|
-
key?: React.Key
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
614
|
-
Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
|
|
615
|
-
>
|
|
616
|
-
|
|
617
|
-
type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
618
|
-
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
619
|
-
>
|
|
620
|
-
|
|
621
|
-
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
622
|
-
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
626
|
-
type Object3DMethod = NonNullable<
|
|
627
|
-
{
|
|
628
|
-
[K in keyof THREE.Object3D]-?: THREE.Object3D[K] extends (...args: any[]) => any ? K : never
|
|
629
|
-
}[keyof THREE.Object3D]
|
|
630
|
-
>
|
|
631
|
-
|
|
632
|
-
/** Look up a key present in a generic element map. */
|
|
633
|
-
type ElementOf<E, K extends string> = E[Extract<keyof E, K>]
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* The JSX element map derived from an entry's Three.js exports. Each entry declares its own
|
|
637
|
-
* `ThreeElements` from this (`src/index.tsx`, `src/legacy.tsx`, `src/webgpu/index.tsx`) and augments
|
|
638
|
-
* react's `IntrinsicElements` with it, so `/legacy` never advertises node materials and `/webgpu`
|
|
639
|
-
* never advertises a `<webGLRenderer>`.
|
|
640
|
-
*/
|
|
641
|
-
type ThreeElementsOf<T extends Record<string, any>> = Omit<
|
|
642
|
-
ThreeToJSXElements<T>,
|
|
643
|
-
'audio' | 'source' | 'line' | 'path'
|
|
644
|
-
> & {
|
|
645
|
-
/**
|
|
646
|
-
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
647
|
-
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
648
|
-
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
649
|
-
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
650
|
-
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
651
|
-
*/
|
|
652
|
-
primitive: Omit<ThreeElement<typeof THREE.Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
653
|
-
object: object
|
|
654
|
-
ref?: React.Ref<any>
|
|
655
|
-
[prop: string]: unknown
|
|
656
|
-
}
|
|
657
|
-
// Conflicts with DOM types can be accessed through a three* prefix
|
|
658
|
-
threeAudio: ElementOf<ThreeToJSXElements<T>, 'audio'>
|
|
659
|
-
threeSource: ElementOf<ThreeToJSXElements<T>, 'source'>
|
|
660
|
-
threeLine: ElementOf<ThreeToJSXElements<T>, 'line'>
|
|
661
|
-
threePath: ElementOf<ThreeToJSXElements<T>, 'path'>
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* @fileoverview Registry for primary canvases that can be targeted by secondary canvases
|
|
666
|
-
*
|
|
667
|
-
* Enables multi-canvas WebGPU rendering where multiple Canvas components share
|
|
668
|
-
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
669
|
-
*
|
|
670
|
-
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
671
|
-
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
672
|
-
*/
|
|
673
|
-
|
|
674
|
-
interface PrimaryCanvasEntry {
|
|
675
|
-
/** The WebGPURenderer instance owned by this primary canvas */
|
|
676
|
-
renderer: WebGPURenderer;
|
|
677
|
-
/** The zustand store for this canvas */
|
|
678
|
-
store: RootStore;
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Register a primary canvas that can be targeted by secondary canvases.
|
|
682
|
-
*
|
|
683
|
-
* @param id - Unique identifier for this primary canvas
|
|
684
|
-
* @param renderer - The WebGPURenderer owned by this canvas
|
|
685
|
-
* @param store - The zustand store for this canvas
|
|
686
|
-
* @returns Cleanup function to unregister on unmount
|
|
687
|
-
*/
|
|
688
|
-
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
|
|
689
|
-
/**
|
|
690
|
-
* Get a registered primary canvas by id.
|
|
691
|
-
*
|
|
692
|
-
* @param id - The id of the primary canvas to look up
|
|
693
|
-
* @returns The primary canvas entry or undefined if not found
|
|
694
|
-
*/
|
|
695
|
-
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
696
|
-
/**
|
|
697
|
-
* Wait for a primary canvas to be registered.
|
|
698
|
-
* Returns immediately if already registered, otherwise waits.
|
|
699
|
-
*
|
|
700
|
-
* @param id - The id of the primary canvas to wait for
|
|
701
|
-
* @param timeout - Optional timeout in ms (default: 5000)
|
|
702
|
-
* @returns Promise that resolves with the primary canvas entry
|
|
703
|
-
*/
|
|
704
|
-
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
705
|
-
/**
|
|
706
|
-
* Check if a primary canvas with the given id exists.
|
|
707
|
-
*
|
|
708
|
-
* @param id - The id to check
|
|
709
|
-
* @returns True if a primary canvas with this id is registered
|
|
710
|
-
*/
|
|
711
|
-
declare function hasPrimary(id: string): boolean;
|
|
712
|
-
/**
|
|
713
|
-
* Unregister a primary canvas. Called on unmount.
|
|
714
|
-
*
|
|
715
|
-
* @param id - The id of the primary canvas to unregister
|
|
716
|
-
*/
|
|
717
|
-
declare function unregisterPrimary(id: string): void;
|
|
718
|
-
/**
|
|
719
|
-
* Get all registered primary canvas ids. Useful for debugging.
|
|
720
|
-
*/
|
|
721
|
-
declare function getPrimaryIds(): string[];
|
|
722
|
-
|
|
723
216
|
type EnvironmentLoaderProps = {
|
|
724
217
|
files?: string | string[];
|
|
725
218
|
path?: string;
|
|
@@ -792,9 +285,9 @@ type EnvironmentProps = {
|
|
|
792
285
|
blur?: number;
|
|
793
286
|
backgroundBlurriness?: number;
|
|
794
287
|
backgroundIntensity?: number;
|
|
795
|
-
backgroundRotation?: Euler;
|
|
288
|
+
backgroundRotation?: Euler$1;
|
|
796
289
|
environmentIntensity?: number;
|
|
797
|
-
environmentRotation?: Euler;
|
|
290
|
+
environmentRotation?: Euler$1;
|
|
798
291
|
map?: Texture$1;
|
|
799
292
|
preset?: PresetsType;
|
|
800
293
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -875,7 +368,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
875
368
|
* </EnvironmentPortal>
|
|
876
369
|
* ```
|
|
877
370
|
*/
|
|
878
|
-
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps):
|
|
371
|
+
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): React$1.JSX.Element;
|
|
879
372
|
/**
|
|
880
373
|
* Sets up a global environment map for PBR materials and backgrounds.
|
|
881
374
|
* Affects scene.environment and optionally scene.background unless a custom scene is passed.
|
|
@@ -971,7 +464,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
|
|
|
971
464
|
* />
|
|
972
465
|
* ```
|
|
973
466
|
*/
|
|
974
|
-
declare function Environment(props: EnvironmentProps):
|
|
467
|
+
declare function Environment(props: EnvironmentProps): React$1.JSX.Element;
|
|
975
468
|
|
|
976
469
|
/**
|
|
977
470
|
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
@@ -1089,7 +582,7 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
1089
582
|
input: Parameters<typeof useTexture>[0];
|
|
1090
583
|
onLoad?: Parameters<typeof useTexture>[1];
|
|
1091
584
|
cache?: boolean;
|
|
1092
|
-
}) =>
|
|
585
|
+
}) => React$1.JSX.Element;
|
|
1093
586
|
|
|
1094
587
|
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1095
588
|
type TextureInput = string | string[] | Record<string, string>;
|
|
@@ -1876,7 +1369,8 @@ declare namespace ReactReconciler {
|
|
|
1876
1369
|
type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
|
|
1877
1370
|
|
|
1878
1371
|
type Lanes = number;
|
|
1879
|
-
|
|
1372
|
+
|
|
1373
|
+
type Lane = number & { __LaneBrand: any };
|
|
1880
1374
|
|
|
1881
1375
|
type Flags = number;
|
|
1882
1376
|
|
|
@@ -2207,7 +1701,6 @@ declare namespace ReactReconciler {
|
|
|
2207
1701
|
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
2208
1702
|
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
2209
1703
|
onDefaultTransitionIndicator: () => void,
|
|
2210
|
-
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
2211
1704
|
): OpaqueRoot;
|
|
2212
1705
|
|
|
2213
1706
|
createPortal(
|
|
@@ -2217,8 +1710,6 @@ declare namespace ReactReconciler {
|
|
|
2217
1710
|
key?: string | null,
|
|
2218
1711
|
): ReactPortal;
|
|
2219
1712
|
|
|
2220
|
-
registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
|
|
2221
|
-
|
|
2222
1713
|
createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
|
|
2223
1714
|
|
|
2224
1715
|
createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
|
|
@@ -2253,8 +1744,12 @@ declare namespace ReactReconciler {
|
|
|
2253
1744
|
isStrictMode: boolean,
|
|
2254
1745
|
concurrentUpdatesByDefaultOverride: null | boolean,
|
|
2255
1746
|
identifierPrefix: string,
|
|
2256
|
-
|
|
1747
|
+
onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
|
|
1748
|
+
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
1749
|
+
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
1750
|
+
onDefaultTransitionIndicator: () => void,
|
|
2257
1751
|
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
1752
|
+
formState: unknown,
|
|
2258
1753
|
): OpaqueRoot;
|
|
2259
1754
|
|
|
2260
1755
|
updateContainer(
|
|
@@ -2264,17 +1759,27 @@ declare namespace ReactReconciler {
|
|
|
2264
1759
|
callback?: (() => void) | null,
|
|
2265
1760
|
): Lane;
|
|
2266
1761
|
|
|
1762
|
+
updateContainerSync(
|
|
1763
|
+
element: ReactNode,
|
|
1764
|
+
container: OpaqueRoot,
|
|
1765
|
+
parentComponent?: Component<any, any> | null,
|
|
1766
|
+
callback?: (() => void) | null,
|
|
1767
|
+
): Lane;
|
|
1768
|
+
|
|
2267
1769
|
batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
|
|
2268
1770
|
|
|
2269
1771
|
deferredUpdates<A>(fn: () => A): A;
|
|
2270
1772
|
|
|
2271
1773
|
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;
|
|
2272
1774
|
|
|
2273
|
-
flushControlled(fn: () => any): void;
|
|
2274
|
-
|
|
2275
1775
|
flushSync(): void;
|
|
2276
1776
|
flushSync<R>(fn: () => R): R;
|
|
2277
1777
|
|
|
1778
|
+
flushSyncFromReconciler(): void;
|
|
1779
|
+
flushSyncFromReconciler<R>(fn: () => R): R;
|
|
1780
|
+
|
|
1781
|
+
flushSyncWork(): boolean;
|
|
1782
|
+
|
|
2278
1783
|
isAlreadyRendering(): boolean;
|
|
2279
1784
|
|
|
2280
1785
|
flushPassiveEffects(): boolean;
|
|
@@ -2283,16 +1788,10 @@ declare namespace ReactReconciler {
|
|
|
2283
1788
|
|
|
2284
1789
|
attemptSynchronousHydration(fiber: Fiber): void;
|
|
2285
1790
|
|
|
2286
|
-
attemptDiscreteHydration(fiber: Fiber): void;
|
|
2287
|
-
|
|
2288
1791
|
attemptContinuousHydration(fiber: Fiber): void;
|
|
2289
1792
|
|
|
2290
1793
|
attemptHydrationAtCurrentPriority(fiber: Fiber): void;
|
|
2291
1794
|
|
|
2292
|
-
getCurrentUpdatePriority(): LanePriority;
|
|
2293
|
-
|
|
2294
|
-
runWithPriority<T>(priority: LanePriority, fn: () => T): T;
|
|
2295
|
-
|
|
2296
1795
|
findHostInstance(component: any): PublicInstance | null;
|
|
2297
1796
|
|
|
2298
1797
|
findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
|
|
@@ -2305,19 +1804,86 @@ declare namespace ReactReconciler {
|
|
|
2305
1804
|
|
|
2306
1805
|
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
|
|
2307
1806
|
}
|
|
1807
|
+
|
|
1808
|
+
function defaultOnUncaughtError(error: Error): void;
|
|
1809
|
+
function defaultOnCaughtError(error: Error): void;
|
|
1810
|
+
function defaultOnRecoverableError(error: Error): void;
|
|
1811
|
+
|
|
1812
|
+
function startHostTransition(
|
|
1813
|
+
formFiber: Fiber,
|
|
1814
|
+
pendingState: unknown,
|
|
1815
|
+
action: ((formData: FormData) => void) | null,
|
|
1816
|
+
formData: FormData,
|
|
1817
|
+
): void;
|
|
2308
1818
|
}
|
|
2309
1819
|
|
|
1820
|
+
/**
|
|
1821
|
+
* Registers constructors so they can be rendered as JSX elements.
|
|
1822
|
+
*
|
|
1823
|
+
* - `extend({ OrbitControls })` makes each constructor available under its camelCased key
|
|
1824
|
+
* (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
|
|
1825
|
+
* namespace can be passed.
|
|
1826
|
+
* - `extend(MyClass)` registers one constructor and returns a component to render it with.
|
|
1827
|
+
*
|
|
1828
|
+
* Registrations are global, shared by every copy and entry of fiber, and are checked before the
|
|
1829
|
+
* three namespace of a root's renderer when an element name is resolved.
|
|
1830
|
+
*
|
|
1831
|
+
* @example
|
|
1832
|
+
* import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
|
|
1833
|
+
* extend({ OrbitControls })
|
|
1834
|
+
* // <orbitControls args={[camera, gl.domElement]} />
|
|
1835
|
+
*
|
|
1836
|
+
* @example
|
|
1837
|
+
* const Controls = extend(OrbitControls)
|
|
1838
|
+
* // <Controls args={[camera, gl.domElement]} />
|
|
1839
|
+
*
|
|
1840
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
|
|
1841
|
+
*/
|
|
2310
1842
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
1843
|
+
/** Registers each constructor in `objects` under its key; see the first overload. */
|
|
2311
1844
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
1845
|
+
/** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
|
|
2312
1846
|
declare function extend(objects: Record<string, unknown>): void;
|
|
2313
1847
|
|
|
1848
|
+
/**
|
|
1849
|
+
* R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
|
|
1850
|
+
* Each root's {@link RootStore} is its container, and children attach to `internal.container`
|
|
1851
|
+
* (a portal's target) or else the root's `scene`.
|
|
1852
|
+
*
|
|
1853
|
+
* - **Element names** resolve through `extend()` registrations first, then the three namespace of
|
|
1854
|
+
* the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
|
|
1855
|
+
* prefixed name exists. `<primitive object={...}>` wraps an existing object.
|
|
1856
|
+
* - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
|
|
1857
|
+
* Suspense discards never creates three objects.
|
|
1858
|
+
* - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
|
|
1859
|
+
* the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
|
|
1860
|
+
* already point to the new object.
|
|
1861
|
+
* - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
|
|
1862
|
+
* test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
|
|
1863
|
+
* - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
|
|
1864
|
+
* follows react-dom's event priorities. View-transition commits are flushed synchronously, since
|
|
1865
|
+
* three has nothing to animate between commits.
|
|
1866
|
+
*
|
|
1867
|
+
* `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
|
|
1868
|
+
*/
|
|
2314
1869
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
1872
|
+
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
1873
|
+
* Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
|
|
1874
|
+
* having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
|
|
1875
|
+
*/
|
|
1876
|
+
declare function flushSync<R>(fn: () => R): R;
|
|
2315
1877
|
|
|
2316
|
-
declare const isRenderer: (def: any) => boolean;
|
|
2317
|
-
interface OffscreenCanvas extends EventTarget {
|
|
2318
|
-
}
|
|
2319
1878
|
declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
1879
|
+
/**
|
|
1880
|
+
* Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
|
|
1881
|
+
* for a renderer that is still being created. `callback` runs when the root is gone: after the
|
|
1882
|
+
* teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
|
|
1883
|
+
* from three r186), after that dispose has settled.
|
|
1884
|
+
*/
|
|
2320
1885
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
1886
|
+
|
|
2321
1887
|
declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
|
|
2322
1888
|
interface PortalProps {
|
|
2323
1889
|
children: ReactNode;
|
|
@@ -2325,14 +1891,89 @@ interface PortalProps {
|
|
|
2325
1891
|
container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
|
|
2326
1892
|
}
|
|
2327
1893
|
declare function Portal({ children, container, state }: PortalProps): JSX.Element;
|
|
1894
|
+
|
|
1895
|
+
/** Renderer resources: creation, shared canvas lookup, and ownership through final release. */
|
|
1896
|
+
|
|
1897
|
+
declare const isRenderer: (def: any) => boolean;
|
|
1898
|
+
interface PrimaryCanvasEntry {
|
|
1899
|
+
/** The WebGPURenderer instance owned by this primary canvas */
|
|
1900
|
+
renderer: WebGPURenderer;
|
|
1901
|
+
/** The zustand store for this canvas */
|
|
1902
|
+
store: RootStore;
|
|
1903
|
+
/** The primary's scheduler root id; a sharing canvas renders after it by default */
|
|
1904
|
+
rootId?: string;
|
|
1905
|
+
}
|
|
2328
1906
|
/**
|
|
2329
|
-
*
|
|
2330
|
-
*
|
|
2331
|
-
*
|
|
2332
|
-
*
|
|
1907
|
+
* Register a primary canvas that can be targeted by secondary canvases.
|
|
1908
|
+
*
|
|
1909
|
+
* @param id - Registry key: the canvas id, or DEFAULT_PRIMARY
|
|
1910
|
+
* @param renderer - The WebGPURenderer owned by this canvas
|
|
1911
|
+
* @param store - The zustand store for this canvas
|
|
1912
|
+
* @param options - The owner token that announced it and its scheduler root id
|
|
1913
|
+
* @returns Cleanup function to unregister on unmount
|
|
2333
1914
|
*/
|
|
2334
|
-
declare function
|
|
1915
|
+
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore, options?: {
|
|
1916
|
+
token?: object;
|
|
1917
|
+
rootId?: string;
|
|
1918
|
+
}): () => void;
|
|
1919
|
+
/**
|
|
1920
|
+
* Get a registered primary canvas by id.
|
|
1921
|
+
*
|
|
1922
|
+
* @param id - The id of the primary canvas to look up
|
|
1923
|
+
* @returns The primary canvas entry or undefined if not found
|
|
1924
|
+
*/
|
|
1925
|
+
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
1926
|
+
/**
|
|
1927
|
+
* Wait for a primary canvas to be registered (`share="id"`).
|
|
1928
|
+
* Returns immediately if already registered, otherwise waits, even through a primary remounting.
|
|
1929
|
+
*
|
|
1930
|
+
* @param id - The id of the primary canvas to wait for
|
|
1931
|
+
* @param timeout - Optional timeout in ms (default: 5000)
|
|
1932
|
+
* @returns Promise that resolves with the primary canvas entry
|
|
1933
|
+
*/
|
|
1934
|
+
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
1935
|
+
/**
|
|
1936
|
+
* Check if a primary canvas with the given id exists.
|
|
1937
|
+
*
|
|
1938
|
+
* @param id - The id to check
|
|
1939
|
+
* @returns True if a primary canvas with this id is registered
|
|
1940
|
+
*/
|
|
1941
|
+
declare function hasPrimary(id: string): boolean;
|
|
1942
|
+
/**
|
|
1943
|
+
* Unregister a primary canvas. Called on unmount.
|
|
1944
|
+
*
|
|
1945
|
+
* @param id - The id of the primary canvas to unregister
|
|
1946
|
+
*/
|
|
1947
|
+
declare function unregisterPrimary(id: string): void;
|
|
1948
|
+
/**
|
|
1949
|
+
* Get all registered primary canvas ids. Useful for debugging.
|
|
1950
|
+
*/
|
|
1951
|
+
declare function getPrimaryIds(): string[];
|
|
2335
1952
|
|
|
1953
|
+
/**
|
|
1954
|
+
* Creates the Zustand store that holds one root's {@link RootState}.
|
|
1955
|
+
*
|
|
1956
|
+
* The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
|
|
1957
|
+
* are `null` placeholders until the root's renderer support has loaded and `configure()` in
|
|
1958
|
+
* `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
|
|
1959
|
+
* fiber add their own fields through root extensions.
|
|
1960
|
+
*
|
|
1961
|
+
* Besides the initial state, the store wires up:
|
|
1962
|
+
* - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
|
|
1963
|
+
* deprecation when user code reads it outside legacy mode.
|
|
1964
|
+
* - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
|
|
1965
|
+
* - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
|
|
1966
|
+
* renderer when there is none).
|
|
1967
|
+
* - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
|
|
1968
|
+
* (when `autoUpdateFrustum` is set) the frustum.
|
|
1969
|
+
* - Calling `invalidate(state)` after every state change.
|
|
1970
|
+
*
|
|
1971
|
+
* `createRoot` calls this once per canvas.
|
|
1972
|
+
*
|
|
1973
|
+
* @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
|
|
1974
|
+
* @param advance - Steps a root manually. Bound into `state.advance`.
|
|
1975
|
+
* @returns The root's store, which is also the reconciler container for that root.
|
|
1976
|
+
*/
|
|
2336
1977
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
2337
1978
|
|
|
2338
1979
|
/** Whether any root has loaded a renderer yet. */
|
|
@@ -2365,7 +2006,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
|
|
|
2365
2006
|
*/
|
|
2366
2007
|
declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
|
|
2367
2008
|
/**
|
|
2368
|
-
* Bridges renderer Context and
|
|
2009
|
+
* Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
|
|
2369
2010
|
* Used to maintain React context when rendering into portals or secondary canvases.
|
|
2370
2011
|
*
|
|
2371
2012
|
* @returns A Bridge component that wraps children with the parent renderer's context
|
|
@@ -2848,5 +2489,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
2848
2489
|
[ONCE]: any[] | true;
|
|
2849
2490
|
};
|
|
2850
2491
|
|
|
2851
|
-
export {
|
|
2852
|
-
export type {
|
|
2492
|
+
export { useTexture as $, EnvironmentMap as H, EnvironmentCube as J, EnvironmentPortal as K, Environment as M, presetsObj as N, swapInteractivity as Q, removeInteractivity as S, createEvents as T, useInstanceHandle as U, useGraph as V, useLoader as X, IsObject as Y, addEffect as a, Texture as a0, useTextures as a5, useEnvironment as a7, extend as a8, reconciler as a9, diffProps as aA, applyProps as aB, is as aC, isOrthographicCamera as aD, isRef as aE, isColorRepresentation as aF, isObject3D as aG, isTexture as aH, isLayers as aI, isUniform as aJ, isVectorLike as aK, isCopyable as aL, hasConstructor as aM, FROM_REF as aN, fromRef as aP, isFromRef as aQ, ONCE as aR, once as aS, isOnce as aU, flushSync as aa, _roots as ab, unmountComponentAtNode as ac, createPortal as ad, Portal as ae, useIsomorphicLayoutEffect as af, useMutableCallback as ag, useBridge as ah, Block as ai, ErrorBoundary as aj, calculateDpr as ak, getUuidPrefix as al, updateCamera as am, updateFrustum as an, REACT_INTERNAL_PROPS as ao, findInitialRoot as ap, getRootState as aq, buildGraph as ar, dispose as as, getInstanceProps as at, prepare as au, invalidateInstance as av, RESERVED_PROPS as aw, resolve as ax, attach as ay, detach as az, addAfterEffect as b, createPointerEvents as c, addTail as d, advance as e, isRenderer as f, getPrimary as g, hasPrimary as h, invalidate as i, getPrimaryIds as j, createStore as k, getThree as l, hasThree as m, whenThree as n, registerPrimary as r, unregisterPrimary as u, waitForPrimary as w };
|
|
2493
|
+
export type { LegacyInternalState as A, BackgroundConfig as B, CanvasProps as C, LegacyRootState as D, Extensions as E, EnvironmentProps as F, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as O, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Z, UseTextureOptions as _, TextureInput as a1, TextureResult as a2, DisposeOptions as a3, UseTexturesReturn as a4, EnvironmentLoaderProps as a6, FromRefMarker as aO, OnceValue as aT, GlobalEffectType as o, BackgroundProp as p, GLTFLike as q, LoaderInstance as s, InferLoadResult as t, LoaderResult as v, WebGLProps as x, WebGLShadowConfig as y, LegacyRenderer as z };
|