@react-three/fiber 10.0.0-canary.f81281f → 10.0.0-canary.fbc659b
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 +14 -15
- package/dist/index.d.cts +13 -13
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +4 -5
- package/dist/legacy.cjs +37 -15
- 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 +13 -5
- package/dist/shared/fiber.BdIbKbh7.mjs +16563 -0
- package/dist/shared/{fiber.C_v1rkNg.mjs → fiber.Biz9olEe.mjs} +214 -62
- package/dist/shared/fiber.C6hitYDY.d.cts +48 -0
- package/dist/shared/{fiber.Bw8YnGg5.d.cts → fiber.C_MFx7We.d.cts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.mts → fiber.C_MFx7We.d.mts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.ts → fiber.C_MFx7We.d.ts} +555 -19
- package/dist/shared/{fiber.DAg-9ieU.d.ts → fiber.CtivZ3IY.d.ts} +190 -548
- package/dist/shared/{fiber.Ddgoyqql.d.mts → fiber.CvlK0a1Z.d.mts} +190 -548
- package/dist/shared/fiber.D4fD6H74.d.mts +48 -0
- package/dist/shared/{fiber.B6zNSmwj.cjs → fiber.DfiCufha.cjs} +222 -60
- package/dist/shared/{fiber.DiPB625B.d.cts → fiber.VTTQNnlj.d.cts} +190 -548
- package/dist/shared/fiber.YgTUGbja.d.ts +48 -0
- package/dist/shared/fiber.nDnBf1np.cjs +16661 -0
- package/dist/webgpu/index.cjs +13 -13
- package/dist/webgpu/index.d.cts +12 -7
- package/dist/webgpu/index.d.mts +12 -7
- package/dist/webgpu/index.d.ts +12 -7
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +8 -8
- package/readme.md +1 -1
- package/dist/chunks/webgl.cjs +0 -27
- package/dist/chunks/webgl.mjs +0 -11
- 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.js';
|
|
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
|
|
|
@@ -341,16 +35,16 @@ type PresetsType = keyof typeof presetsObj;
|
|
|
341
35
|
interface BackgroundConfig {
|
|
342
36
|
/** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
|
|
343
37
|
preset?: PresetsType
|
|
344
|
-
/** Files for cube texture (6 faces) or single
|
|
38
|
+
/** Files for cube texture (6 faces) or a single equirect (.hdr, .exr, .jpg, .png, .webp, .avif, .gif) */
|
|
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
|
|
@@ -361,7 +55,7 @@ interface BackgroundConfig {
|
|
|
361
55
|
*
|
|
362
56
|
* String detection priority:
|
|
363
57
|
* 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
364
|
-
* 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
|
|
58
|
+
* 2. URL - starts with /, ./, ../, http://, https://, data:, OR has an image extension (a query or hash may follow)
|
|
365
59
|
* 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
|
|
366
60
|
*
|
|
367
61
|
* @example Color
|
|
@@ -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;
|
|
@@ -777,7 +270,7 @@ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'pre
|
|
|
777
270
|
* - scale: Scale of backside projected sphere (default: 1000)
|
|
778
271
|
*
|
|
779
272
|
* Additional loader props:
|
|
780
|
-
* @property files - File path(s) for environment. Supports .hdr, .exr, Ultra HDR .
|
|
273
|
+
* @property files - File path(s) for environment. Supports .hdr, .exr, .jpg (Ultra HDR or plain), an LDR .png/.webp/.avif/.gif, or array of 6 cube faces
|
|
781
274
|
* @property path - Base path for file loading
|
|
782
275
|
* @property extensions - Texture extensions override
|
|
783
276
|
*/
|
|
@@ -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>;
|
|
@@ -820,8 +313,9 @@ type EnvironmentProps = {
|
|
|
820
313
|
declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
|
|
821
314
|
/**
|
|
822
315
|
* Internal component that loads environment textures from files or presets.
|
|
823
|
-
* Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg
|
|
824
|
-
*
|
|
316
|
+
* Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg (a JPEG without a gain
|
|
317
|
+
* map loads as a plain image), TextureLoader for an LDR .png/.webp/.avif/.gif, or CubeTextureLoader
|
|
318
|
+
* for arrays of images.
|
|
825
319
|
*
|
|
826
320
|
* @example With preset
|
|
827
321
|
* ```jsx
|
|
@@ -875,14 +369,14 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
875
369
|
* </EnvironmentPortal>
|
|
876
370
|
* ```
|
|
877
371
|
*/
|
|
878
|
-
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps):
|
|
372
|
+
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
373
|
/**
|
|
880
374
|
* Sets up a global environment map for PBR materials and backgrounds.
|
|
881
375
|
* Affects scene.environment and optionally scene.background unless a custom scene is passed.
|
|
882
376
|
*
|
|
883
377
|
* Supports multiple input methods:
|
|
884
378
|
* - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
885
|
-
* - **Files**: HDR (.hdr), EXR (.exr), Ultra HDR
|
|
379
|
+
* - **Files**: HDR (.hdr), EXR (.exr), JPEG (.jpg, Ultra HDR when it carries a gain map), LDR image (.png, .webp, .avif, .gif), or cube faces (array of 6 images)
|
|
886
380
|
* - **Texture**: Pre-existing cube texture via `map` prop
|
|
887
381
|
* - **Custom Scene**: Render children into environment using portal and cube camera
|
|
888
382
|
* - **Ground Projection**: Project environment onto ground plane
|
|
@@ -971,7 +465,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
|
|
|
971
465
|
* />
|
|
972
466
|
* ```
|
|
973
467
|
*/
|
|
974
|
-
declare function Environment(props: EnvironmentProps):
|
|
468
|
+
declare function Environment(props: EnvironmentProps): React$1.JSX.Element;
|
|
975
469
|
|
|
976
470
|
/**
|
|
977
471
|
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
@@ -1089,7 +583,7 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
1089
583
|
input: Parameters<typeof useTexture>[0];
|
|
1090
584
|
onLoad?: Parameters<typeof useTexture>[1];
|
|
1091
585
|
cache?: boolean;
|
|
1092
|
-
}) =>
|
|
586
|
+
}) => React$1.JSX.Element;
|
|
1093
587
|
|
|
1094
588
|
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1095
589
|
type TextureInput = string | string[] | Record<string, string>;
|
|
@@ -1876,7 +1370,8 @@ declare namespace ReactReconciler {
|
|
|
1876
1370
|
type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
|
|
1877
1371
|
|
|
1878
1372
|
type Lanes = number;
|
|
1879
|
-
|
|
1373
|
+
|
|
1374
|
+
type Lane = number & { __LaneBrand: any };
|
|
1880
1375
|
|
|
1881
1376
|
type Flags = number;
|
|
1882
1377
|
|
|
@@ -2207,7 +1702,6 @@ declare namespace ReactReconciler {
|
|
|
2207
1702
|
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
2208
1703
|
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
2209
1704
|
onDefaultTransitionIndicator: () => void,
|
|
2210
|
-
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
2211
1705
|
): OpaqueRoot;
|
|
2212
1706
|
|
|
2213
1707
|
createPortal(
|
|
@@ -2217,8 +1711,6 @@ declare namespace ReactReconciler {
|
|
|
2217
1711
|
key?: string | null,
|
|
2218
1712
|
): ReactPortal;
|
|
2219
1713
|
|
|
2220
|
-
registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
|
|
2221
|
-
|
|
2222
1714
|
createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
|
|
2223
1715
|
|
|
2224
1716
|
createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
|
|
@@ -2253,8 +1745,12 @@ declare namespace ReactReconciler {
|
|
|
2253
1745
|
isStrictMode: boolean,
|
|
2254
1746
|
concurrentUpdatesByDefaultOverride: null | boolean,
|
|
2255
1747
|
identifierPrefix: string,
|
|
2256
|
-
|
|
1748
|
+
onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
|
|
1749
|
+
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
1750
|
+
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
1751
|
+
onDefaultTransitionIndicator: () => void,
|
|
2257
1752
|
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
1753
|
+
formState: unknown,
|
|
2258
1754
|
): OpaqueRoot;
|
|
2259
1755
|
|
|
2260
1756
|
updateContainer(
|
|
@@ -2264,17 +1760,27 @@ declare namespace ReactReconciler {
|
|
|
2264
1760
|
callback?: (() => void) | null,
|
|
2265
1761
|
): Lane;
|
|
2266
1762
|
|
|
1763
|
+
updateContainerSync(
|
|
1764
|
+
element: ReactNode,
|
|
1765
|
+
container: OpaqueRoot,
|
|
1766
|
+
parentComponent?: Component<any, any> | null,
|
|
1767
|
+
callback?: (() => void) | null,
|
|
1768
|
+
): Lane;
|
|
1769
|
+
|
|
2267
1770
|
batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
|
|
2268
1771
|
|
|
2269
1772
|
deferredUpdates<A>(fn: () => A): A;
|
|
2270
1773
|
|
|
2271
1774
|
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
1775
|
|
|
2273
|
-
flushControlled(fn: () => any): void;
|
|
2274
|
-
|
|
2275
1776
|
flushSync(): void;
|
|
2276
1777
|
flushSync<R>(fn: () => R): R;
|
|
2277
1778
|
|
|
1779
|
+
flushSyncFromReconciler(): void;
|
|
1780
|
+
flushSyncFromReconciler<R>(fn: () => R): R;
|
|
1781
|
+
|
|
1782
|
+
flushSyncWork(): boolean;
|
|
1783
|
+
|
|
2278
1784
|
isAlreadyRendering(): boolean;
|
|
2279
1785
|
|
|
2280
1786
|
flushPassiveEffects(): boolean;
|
|
@@ -2283,16 +1789,10 @@ declare namespace ReactReconciler {
|
|
|
2283
1789
|
|
|
2284
1790
|
attemptSynchronousHydration(fiber: Fiber): void;
|
|
2285
1791
|
|
|
2286
|
-
attemptDiscreteHydration(fiber: Fiber): void;
|
|
2287
|
-
|
|
2288
1792
|
attemptContinuousHydration(fiber: Fiber): void;
|
|
2289
1793
|
|
|
2290
1794
|
attemptHydrationAtCurrentPriority(fiber: Fiber): void;
|
|
2291
1795
|
|
|
2292
|
-
getCurrentUpdatePriority(): LanePriority;
|
|
2293
|
-
|
|
2294
|
-
runWithPriority<T>(priority: LanePriority, fn: () => T): T;
|
|
2295
|
-
|
|
2296
1796
|
findHostInstance(component: any): PublicInstance | null;
|
|
2297
1797
|
|
|
2298
1798
|
findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
|
|
@@ -2305,19 +1805,86 @@ declare namespace ReactReconciler {
|
|
|
2305
1805
|
|
|
2306
1806
|
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
|
|
2307
1807
|
}
|
|
1808
|
+
|
|
1809
|
+
function defaultOnUncaughtError(error: Error): void;
|
|
1810
|
+
function defaultOnCaughtError(error: Error): void;
|
|
1811
|
+
function defaultOnRecoverableError(error: Error): void;
|
|
1812
|
+
|
|
1813
|
+
function startHostTransition(
|
|
1814
|
+
formFiber: Fiber,
|
|
1815
|
+
pendingState: unknown,
|
|
1816
|
+
action: ((formData: FormData) => void) | null,
|
|
1817
|
+
formData: FormData,
|
|
1818
|
+
): void;
|
|
2308
1819
|
}
|
|
2309
1820
|
|
|
1821
|
+
/**
|
|
1822
|
+
* Registers constructors so they can be rendered as JSX elements.
|
|
1823
|
+
*
|
|
1824
|
+
* - `extend({ OrbitControls })` makes each constructor available under its camelCased key
|
|
1825
|
+
* (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
|
|
1826
|
+
* namespace can be passed.
|
|
1827
|
+
* - `extend(MyClass)` registers one constructor and returns a component to render it with.
|
|
1828
|
+
*
|
|
1829
|
+
* Registrations are global, shared by every copy and entry of fiber, and are checked before the
|
|
1830
|
+
* three namespace of a root's renderer when an element name is resolved.
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
|
|
1834
|
+
* extend({ OrbitControls })
|
|
1835
|
+
* // <orbitControls args={[camera, gl.domElement]} />
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* const Controls = extend(OrbitControls)
|
|
1839
|
+
* // <Controls args={[camera, gl.domElement]} />
|
|
1840
|
+
*
|
|
1841
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
|
|
1842
|
+
*/
|
|
2310
1843
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
1844
|
+
/** Registers each constructor in `objects` under its key; see the first overload. */
|
|
2311
1845
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
1846
|
+
/** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
|
|
2312
1847
|
declare function extend(objects: Record<string, unknown>): void;
|
|
2313
1848
|
|
|
1849
|
+
/**
|
|
1850
|
+
* R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
|
|
1851
|
+
* Each root's {@link RootStore} is its container, and children attach to `internal.container`
|
|
1852
|
+
* (a portal's target) or else the root's `scene`.
|
|
1853
|
+
*
|
|
1854
|
+
* - **Element names** resolve through `extend()` registrations first, then the three namespace of
|
|
1855
|
+
* the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
|
|
1856
|
+
* prefixed name exists. `<primitive object={...}>` wraps an existing object.
|
|
1857
|
+
* - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
|
|
1858
|
+
* Suspense discards never creates three objects.
|
|
1859
|
+
* - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
|
|
1860
|
+
* the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
|
|
1861
|
+
* already point to the new object.
|
|
1862
|
+
* - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
|
|
1863
|
+
* test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
|
|
1864
|
+
* - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
|
|
1865
|
+
* follows react-dom's event priorities. View-transition commits are flushed synchronously, since
|
|
1866
|
+
* three has nothing to animate between commits.
|
|
1867
|
+
*
|
|
1868
|
+
* `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
|
|
1869
|
+
*/
|
|
2314
1870
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
1873
|
+
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
1874
|
+
* Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
|
|
1875
|
+
* having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
|
|
1876
|
+
*/
|
|
1877
|
+
declare function flushSync<R>(fn: () => R): R;
|
|
2315
1878
|
|
|
2316
|
-
declare const isRenderer: (def: any) => boolean;
|
|
2317
|
-
interface OffscreenCanvas extends EventTarget {
|
|
2318
|
-
}
|
|
2319
1879
|
declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
|
|
1882
|
+
* for a renderer that is still being created. `callback` runs when the root is gone: after the
|
|
1883
|
+
* teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
|
|
1884
|
+
* from three r186), after that dispose has settled.
|
|
1885
|
+
*/
|
|
2320
1886
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
1887
|
+
|
|
2321
1888
|
declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
|
|
2322
1889
|
interface PortalProps {
|
|
2323
1890
|
children: ReactNode;
|
|
@@ -2325,14 +1892,89 @@ interface PortalProps {
|
|
|
2325
1892
|
container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
|
|
2326
1893
|
}
|
|
2327
1894
|
declare function Portal({ children, container, state }: PortalProps): JSX.Element;
|
|
1895
|
+
|
|
1896
|
+
/** Renderer resources: creation, shared canvas lookup, and ownership through final release. */
|
|
1897
|
+
|
|
1898
|
+
declare const isRenderer: (def: any) => boolean;
|
|
1899
|
+
interface PrimaryCanvasEntry {
|
|
1900
|
+
/** The WebGPURenderer instance owned by this primary canvas */
|
|
1901
|
+
renderer: WebGPURenderer;
|
|
1902
|
+
/** The zustand store for this canvas */
|
|
1903
|
+
store: RootStore;
|
|
1904
|
+
/** The primary's scheduler root id; a sharing canvas renders after it by default */
|
|
1905
|
+
rootId?: string;
|
|
1906
|
+
}
|
|
2328
1907
|
/**
|
|
2329
|
-
*
|
|
2330
|
-
*
|
|
2331
|
-
*
|
|
2332
|
-
*
|
|
1908
|
+
* Register a primary canvas that can be targeted by secondary canvases.
|
|
1909
|
+
*
|
|
1910
|
+
* @param id - Registry key: the canvas id, or DEFAULT_PRIMARY
|
|
1911
|
+
* @param renderer - The WebGPURenderer owned by this canvas
|
|
1912
|
+
* @param store - The zustand store for this canvas
|
|
1913
|
+
* @param options - The owner token that announced it and its scheduler root id
|
|
1914
|
+
* @returns Cleanup function to unregister on unmount
|
|
2333
1915
|
*/
|
|
2334
|
-
declare function
|
|
1916
|
+
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore, options?: {
|
|
1917
|
+
token?: object;
|
|
1918
|
+
rootId?: string;
|
|
1919
|
+
}): () => void;
|
|
1920
|
+
/**
|
|
1921
|
+
* Get a registered primary canvas by id.
|
|
1922
|
+
*
|
|
1923
|
+
* @param id - The id of the primary canvas to look up
|
|
1924
|
+
* @returns The primary canvas entry or undefined if not found
|
|
1925
|
+
*/
|
|
1926
|
+
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
1927
|
+
/**
|
|
1928
|
+
* Wait for a primary canvas to be registered (`share="id"`).
|
|
1929
|
+
* Returns immediately if already registered, otherwise waits, even through a primary remounting.
|
|
1930
|
+
*
|
|
1931
|
+
* @param id - The id of the primary canvas to wait for
|
|
1932
|
+
* @param timeout - Optional timeout in ms (default: 5000)
|
|
1933
|
+
* @returns Promise that resolves with the primary canvas entry
|
|
1934
|
+
*/
|
|
1935
|
+
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
1936
|
+
/**
|
|
1937
|
+
* Check if a primary canvas with the given id exists.
|
|
1938
|
+
*
|
|
1939
|
+
* @param id - The id to check
|
|
1940
|
+
* @returns True if a primary canvas with this id is registered
|
|
1941
|
+
*/
|
|
1942
|
+
declare function hasPrimary(id: string): boolean;
|
|
1943
|
+
/**
|
|
1944
|
+
* Unregister a primary canvas. Called on unmount.
|
|
1945
|
+
*
|
|
1946
|
+
* @param id - The id of the primary canvas to unregister
|
|
1947
|
+
*/
|
|
1948
|
+
declare function unregisterPrimary(id: string): void;
|
|
1949
|
+
/**
|
|
1950
|
+
* Get all registered primary canvas ids. Useful for debugging.
|
|
1951
|
+
*/
|
|
1952
|
+
declare function getPrimaryIds(): string[];
|
|
2335
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* Creates the Zustand store that holds one root's {@link RootState}.
|
|
1956
|
+
*
|
|
1957
|
+
* The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
|
|
1958
|
+
* are `null` placeholders until the root's renderer support has loaded and `configure()` in
|
|
1959
|
+
* `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
|
|
1960
|
+
* fiber add their own fields through root extensions.
|
|
1961
|
+
*
|
|
1962
|
+
* Besides the initial state, the store wires up:
|
|
1963
|
+
* - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
|
|
1964
|
+
* deprecation when user code reads it outside legacy mode.
|
|
1965
|
+
* - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
|
|
1966
|
+
* - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
|
|
1967
|
+
* renderer when there is none).
|
|
1968
|
+
* - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
|
|
1969
|
+
* (when `autoUpdateFrustum` is set) the frustum.
|
|
1970
|
+
* - Calling `invalidate(state)` after every state change.
|
|
1971
|
+
*
|
|
1972
|
+
* `createRoot` calls this once per canvas.
|
|
1973
|
+
*
|
|
1974
|
+
* @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
|
|
1975
|
+
* @param advance - Steps a root manually. Bound into `state.advance`.
|
|
1976
|
+
* @returns The root's store, which is also the reconciler container for that root.
|
|
1977
|
+
*/
|
|
2336
1978
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
2337
1979
|
|
|
2338
1980
|
/** Whether any root has loaded a renderer yet. */
|
|
@@ -2365,7 +2007,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
|
|
|
2365
2007
|
*/
|
|
2366
2008
|
declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
|
|
2367
2009
|
/**
|
|
2368
|
-
* Bridges renderer Context and
|
|
2010
|
+
* Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
|
|
2369
2011
|
* Used to maintain React context when rendering into portals or secondary canvases.
|
|
2370
2012
|
*
|
|
2371
2013
|
* @returns A Bridge component that wraps children with the parent renderer's context
|
|
@@ -2848,5 +2490,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
2848
2490
|
[ONCE]: any[] | true;
|
|
2849
2491
|
};
|
|
2850
2492
|
|
|
2851
|
-
export {
|
|
2852
|
-
export type {
|
|
2493
|
+
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 };
|
|
2494
|
+
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 };
|