@react-three/fiber 10.0.0-canary.e3891fb → 10.0.0-canary.e78793c
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 -8
- package/dist/extension.d.cts +50 -6
- package/dist/extension.d.mts +50 -6
- package/dist/extension.d.ts +50 -6
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +17 -19
- package/dist/index.d.cts +16 -49
- package/dist/index.d.mts +16 -49
- package/dist/index.d.ts +16 -49
- package/dist/index.mjs +7 -8
- package/dist/legacy.cjs +37 -15
- package/dist/legacy.d.cts +10 -8
- package/dist/legacy.d.mts +10 -8
- package/dist/legacy.d.ts +10 -8
- package/dist/legacy.mjs +13 -5
- package/dist/shared/{fiber.C4GU39Za.d.ts → fiber.34TOMPo3.d.cts} +190 -471
- package/dist/shared/fiber.BFuGd7gN.d.cts +90 -0
- package/dist/shared/fiber.BSYBnw8x.mjs +16563 -0
- package/dist/shared/{fiber.B0oukOFO.mjs → fiber.Biz9olEe.mjs} +181 -64
- package/dist/shared/fiber.Bll9fqKA.d.mts +90 -0
- package/dist/shared/{fiber.Cg2YRc54.d.cts → fiber.CjMAAsJy.d.ts} +190 -471
- package/dist/shared/{fiber.I5Q4dVvl.d.cts → fiber.DQTSZ24m.d.cts} +488 -26
- package/dist/shared/{fiber.I5Q4dVvl.d.mts → fiber.DQTSZ24m.d.mts} +488 -26
- package/dist/shared/{fiber.I5Q4dVvl.d.ts → fiber.DQTSZ24m.d.ts} +488 -26
- package/dist/shared/fiber.DUgKvaq-.mjs +9 -0
- package/dist/shared/{fiber.khFlPHPf.cjs → fiber.DfiCufha.cjs} +186 -62
- package/dist/shared/fiber.DuA4F8L5.d.ts +90 -0
- package/dist/shared/{fiber.2dyldILT.d.mts → fiber.Dy7Uz273.d.mts} +190 -471
- package/dist/shared/fiber.X4yI0DId.cjs +14 -0
- package/dist/shared/fiber.nDnBf1np.cjs +16661 -0
- package/dist/webgpu/index.cjs +16 -18
- package/dist/webgpu/index.d.cts +17 -79
- package/dist/webgpu/index.d.mts +17 -79
- package/dist/webgpu/index.d.ts +17 -79
- package/dist/webgpu/index.mjs +7 -9
- 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.BU0vBHc9.d.mts +0 -48
- package/dist/shared/fiber.Cx-UAmMb.d.ts +0 -48
- package/dist/shared/fiber.DAl4H27x.d.cts +0 -48
- package/dist/shared/fiber.L0cJPxh2.cjs +0 -15151
- package/dist/shared/fiber.UW5CRgts.mjs +0 -15053
|
@@ -1,239 +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 { ak as RenderProps, m as ConstructorRepresentation, aI as ObjectMap, a7 as BaseRendererProps, a8 as RendererFactory, az as Properties, I as InternalState, H as RootState, E as Euler$1, J as RootStore, a3 as EventManager, Z as DomEvent, av as Instance, o as ThreeElement, ar as Catalogue, ao as Root, al as InjectState, aQ as ThreeCore, aF as Bridge, aH as UnblockProps, aK as Disposable, D as Dpr, aD as ThreeCamera, y as Size, aJ as EquConfig } from './fiber.DQTSZ24m.cjs';
|
|
4
5
|
import * as THREE from 'three';
|
|
5
|
-
import { ColorRepresentation, Euler
|
|
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
|
-
>
|
|
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';
|
|
237
8
|
|
|
238
9
|
//* Loop Types ==============================
|
|
239
10
|
|
|
@@ -264,16 +35,16 @@ type PresetsType = keyof typeof presetsObj;
|
|
|
264
35
|
interface BackgroundConfig {
|
|
265
36
|
/** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
|
|
266
37
|
preset?: PresetsType
|
|
267
|
-
/** 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) */
|
|
268
39
|
files?: string | string[]
|
|
269
40
|
/** Separate files for scene.background (visual backdrop) */
|
|
270
41
|
backgroundMap?: string | string[]
|
|
271
|
-
backgroundRotation?: Euler
|
|
42
|
+
backgroundRotation?: Euler | [number, number, number]
|
|
272
43
|
backgroundBlurriness?: number
|
|
273
44
|
backgroundIntensity?: number
|
|
274
45
|
/** Separate files for scene.environment (PBR lighting/reflections) */
|
|
275
46
|
envMap?: string | string[]
|
|
276
|
-
environmentRotation?: Euler
|
|
47
|
+
environmentRotation?: Euler | [number, number, number]
|
|
277
48
|
environmentIntensity?: number
|
|
278
49
|
path?: string
|
|
279
50
|
extensions?: (loader: Loader) => void
|
|
@@ -284,7 +55,7 @@ interface BackgroundConfig {
|
|
|
284
55
|
*
|
|
285
56
|
* String detection priority:
|
|
286
57
|
* 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
287
|
-
* 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)
|
|
288
59
|
* 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
|
|
289
60
|
*
|
|
290
61
|
* @example Color
|
|
@@ -323,9 +94,7 @@ type BackgroundProp =
|
|
|
323
94
|
//* Canvas Types ==============================
|
|
324
95
|
|
|
325
96
|
interface CanvasProps
|
|
326
|
-
extends
|
|
327
|
-
Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
|
|
328
|
-
React$1.HTMLAttributes<HTMLDivElement> {
|
|
97
|
+
extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
|
|
329
98
|
children?: React$1.ReactNode
|
|
330
99
|
ref?: React$1.Ref<HTMLCanvasElement>
|
|
331
100
|
/** Canvas fallback content, similar to img's alt prop */
|
|
@@ -444,205 +213,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
444
213
|
|
|
445
214
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
446
215
|
|
|
447
|
-
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
448
|
-
|
|
449
|
-
interface MathRepresentation {
|
|
450
|
-
set(...args: number[]): any
|
|
451
|
-
}
|
|
452
|
-
interface VectorRepresentation extends MathRepresentation {
|
|
453
|
-
setScalar(value: number): any
|
|
454
|
-
}
|
|
455
|
-
type MathTypes = MathRepresentation | THREE.Euler | THREE.Color
|
|
456
|
-
|
|
457
|
-
type MathType<T extends MathTypes> = T extends THREE.Color
|
|
458
|
-
? Args<typeof THREE.Color> | THREE.ColorRepresentation
|
|
459
|
-
: T extends VectorRepresentation | THREE.Layers | THREE.Euler
|
|
460
|
-
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
461
|
-
: T | MutableOrReadonlyParameters<T['set']>
|
|
462
|
-
|
|
463
|
-
type MathProps<P> = {
|
|
464
|
-
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
type Vector2 = MathType<THREE.Vector2>
|
|
468
|
-
type Vector3 = MathType<THREE.Vector3>
|
|
469
|
-
type Vector4 = MathType<THREE.Vector4>
|
|
470
|
-
type Color = MathType<THREE.Color>
|
|
471
|
-
type Layers = MathType<THREE.Layers>
|
|
472
|
-
type Quaternion = MathType<THREE.Quaternion>
|
|
473
|
-
type Euler = MathType<THREE.Euler>
|
|
474
|
-
type Matrix3 = MathType<THREE.Matrix3>
|
|
475
|
-
type Matrix4 = MathType<THREE.Matrix4>
|
|
476
|
-
|
|
477
|
-
interface RaycastableRepresentation {
|
|
478
|
-
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
|
|
479
|
-
}
|
|
480
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Props for geometry transform methods that can be called with `once()`.
|
|
484
|
-
* These methods modify the geometry in-place and only make sense to call once on mount.
|
|
485
|
-
*
|
|
486
|
-
* @example
|
|
487
|
-
* import { once } from '@react-three/fiber'
|
|
488
|
-
*
|
|
489
|
-
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
490
|
-
* <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
|
|
491
|
-
* <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
|
|
492
|
-
*/
|
|
493
|
-
interface GeometryTransformProps {
|
|
494
|
-
/** Rotate the geometry about the X axis (radians). Use with once(). */
|
|
495
|
-
rotateX?: number
|
|
496
|
-
/** Rotate the geometry about the Y axis (radians). Use with once(). */
|
|
497
|
-
rotateY?: number
|
|
498
|
-
/** Rotate the geometry about the Z axis (radians). Use with once(). */
|
|
499
|
-
rotateZ?: number
|
|
500
|
-
/** Translate the geometry (x, y, z). Use with once(). */
|
|
501
|
-
translate?: [x: number, y: number, z: number]
|
|
502
|
-
/** Scale the geometry (x, y, z). Use with once(). */
|
|
503
|
-
scale?: [x: number, y: number, z: number]
|
|
504
|
-
/** Center the geometry based on bounding box. Use with once(). */
|
|
505
|
-
center?: true
|
|
506
|
-
/** Apply a Matrix4 transformation. Use with once(). */
|
|
507
|
-
applyMatrix4?: THREE.Matrix4
|
|
508
|
-
/** Apply a Quaternion rotation. Use with once(). */
|
|
509
|
-
applyQuaternion?: THREE.Quaternion
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
type GeometryProps<P> = P extends THREE.BufferGeometry ? GeometryTransformProps : {}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Workaround for @types/three TSL node type issues.
|
|
516
|
-
* The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
|
|
517
|
-
* This transforms `Node | null` properties to accept any object with node-like shape.
|
|
518
|
-
*/
|
|
519
|
-
type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
523
|
-
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
524
|
-
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
525
|
-
*/
|
|
526
|
-
type NodeProps<P> = {
|
|
527
|
-
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
interface ReactProps<P> {
|
|
531
|
-
children?: React.ReactNode
|
|
532
|
-
ref?: React.Ref<P>
|
|
533
|
-
key?: React.Key
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
537
|
-
Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
|
|
538
|
-
>
|
|
539
|
-
|
|
540
|
-
type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
541
|
-
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
542
|
-
>
|
|
543
|
-
|
|
544
|
-
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
545
|
-
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
549
|
-
type Object3DMethod = NonNullable<
|
|
550
|
-
{
|
|
551
|
-
[K in keyof THREE.Object3D]-?: THREE.Object3D[K] extends (...args: any[]) => any ? K : never
|
|
552
|
-
}[keyof THREE.Object3D]
|
|
553
|
-
>
|
|
554
|
-
|
|
555
|
-
/** Look up a key present in a generic element map. */
|
|
556
|
-
type ElementOf<E, K extends string> = E[Extract<keyof E, K>]
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* The JSX element map derived from an entry's Three.js exports. Each entry declares its own
|
|
560
|
-
* `ThreeElements` from this (`src/index.tsx`, `src/legacy.tsx`, `src/webgpu/index.tsx`) and augments
|
|
561
|
-
* react's `IntrinsicElements` with it, so `/legacy` never advertises node materials and `/webgpu`
|
|
562
|
-
* never advertises a `<webGLRenderer>`.
|
|
563
|
-
*/
|
|
564
|
-
type ThreeElementsOf<T extends Record<string, any>> = Omit<
|
|
565
|
-
ThreeToJSXElements<T>,
|
|
566
|
-
'audio' | 'source' | 'line' | 'path'
|
|
567
|
-
> & {
|
|
568
|
-
/**
|
|
569
|
-
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
570
|
-
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
571
|
-
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
572
|
-
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
573
|
-
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
574
|
-
*/
|
|
575
|
-
primitive: Omit<ThreeElement<typeof THREE.Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
576
|
-
object: object
|
|
577
|
-
ref?: React.Ref<any>
|
|
578
|
-
[prop: string]: unknown
|
|
579
|
-
}
|
|
580
|
-
// Conflicts with DOM types can be accessed through a three* prefix
|
|
581
|
-
threeAudio: ElementOf<ThreeToJSXElements<T>, 'audio'>
|
|
582
|
-
threeSource: ElementOf<ThreeToJSXElements<T>, 'source'>
|
|
583
|
-
threeLine: ElementOf<ThreeToJSXElements<T>, 'line'>
|
|
584
|
-
threePath: ElementOf<ThreeToJSXElements<T>, 'path'>
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* @fileoverview Registry for primary canvases that can be targeted by secondary canvases
|
|
589
|
-
*
|
|
590
|
-
* Enables multi-canvas WebGPU rendering where multiple Canvas components share
|
|
591
|
-
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
592
|
-
*
|
|
593
|
-
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
594
|
-
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
595
|
-
*/
|
|
596
|
-
|
|
597
|
-
interface PrimaryCanvasEntry {
|
|
598
|
-
/** The WebGPURenderer instance owned by this primary canvas */
|
|
599
|
-
renderer: WebGPURenderer;
|
|
600
|
-
/** The zustand store for this canvas */
|
|
601
|
-
store: RootStore;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Register a primary canvas that can be targeted by secondary canvases.
|
|
605
|
-
*
|
|
606
|
-
* @param id - Unique identifier for this primary canvas
|
|
607
|
-
* @param renderer - The WebGPURenderer owned by this canvas
|
|
608
|
-
* @param store - The zustand store for this canvas
|
|
609
|
-
* @returns Cleanup function to unregister on unmount
|
|
610
|
-
*/
|
|
611
|
-
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
|
|
612
|
-
/**
|
|
613
|
-
* Get a registered primary canvas by id.
|
|
614
|
-
*
|
|
615
|
-
* @param id - The id of the primary canvas to look up
|
|
616
|
-
* @returns The primary canvas entry or undefined if not found
|
|
617
|
-
*/
|
|
618
|
-
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
619
|
-
/**
|
|
620
|
-
* Wait for a primary canvas to be registered.
|
|
621
|
-
* Returns immediately if already registered, otherwise waits.
|
|
622
|
-
*
|
|
623
|
-
* @param id - The id of the primary canvas to wait for
|
|
624
|
-
* @param timeout - Optional timeout in ms (default: 5000)
|
|
625
|
-
* @returns Promise that resolves with the primary canvas entry
|
|
626
|
-
*/
|
|
627
|
-
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
628
|
-
/**
|
|
629
|
-
* Check if a primary canvas with the given id exists.
|
|
630
|
-
*
|
|
631
|
-
* @param id - The id to check
|
|
632
|
-
* @returns True if a primary canvas with this id is registered
|
|
633
|
-
*/
|
|
634
|
-
declare function hasPrimary(id: string): boolean;
|
|
635
|
-
/**
|
|
636
|
-
* Unregister a primary canvas. Called on unmount.
|
|
637
|
-
*
|
|
638
|
-
* @param id - The id of the primary canvas to unregister
|
|
639
|
-
*/
|
|
640
|
-
declare function unregisterPrimary(id: string): void;
|
|
641
|
-
/**
|
|
642
|
-
* Get all registered primary canvas ids. Useful for debugging.
|
|
643
|
-
*/
|
|
644
|
-
declare function getPrimaryIds(): string[];
|
|
645
|
-
|
|
646
216
|
type EnvironmentLoaderProps = {
|
|
647
217
|
files?: string | string[];
|
|
648
218
|
path?: string;
|
|
@@ -700,7 +270,7 @@ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'pre
|
|
|
700
270
|
* - scale: Scale of backside projected sphere (default: 1000)
|
|
701
271
|
*
|
|
702
272
|
* Additional loader props:
|
|
703
|
-
* @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
|
|
704
274
|
* @property path - Base path for file loading
|
|
705
275
|
* @property extensions - Texture extensions override
|
|
706
276
|
*/
|
|
@@ -715,9 +285,9 @@ type EnvironmentProps = {
|
|
|
715
285
|
blur?: number;
|
|
716
286
|
backgroundBlurriness?: number;
|
|
717
287
|
backgroundIntensity?: number;
|
|
718
|
-
backgroundRotation?: Euler;
|
|
288
|
+
backgroundRotation?: Euler$1;
|
|
719
289
|
environmentIntensity?: number;
|
|
720
|
-
environmentRotation?: Euler;
|
|
290
|
+
environmentRotation?: Euler$1;
|
|
721
291
|
map?: Texture$1;
|
|
722
292
|
preset?: PresetsType;
|
|
723
293
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -743,8 +313,9 @@ type EnvironmentProps = {
|
|
|
743
313
|
declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
|
|
744
314
|
/**
|
|
745
315
|
* Internal component that loads environment textures from files or presets.
|
|
746
|
-
* Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg
|
|
747
|
-
*
|
|
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.
|
|
748
319
|
*
|
|
749
320
|
* @example With preset
|
|
750
321
|
* ```jsx
|
|
@@ -798,14 +369,14 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
798
369
|
* </EnvironmentPortal>
|
|
799
370
|
* ```
|
|
800
371
|
*/
|
|
801
|
-
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;
|
|
802
373
|
/**
|
|
803
374
|
* Sets up a global environment map for PBR materials and backgrounds.
|
|
804
375
|
* Affects scene.environment and optionally scene.background unless a custom scene is passed.
|
|
805
376
|
*
|
|
806
377
|
* Supports multiple input methods:
|
|
807
378
|
* - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
808
|
-
* - **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)
|
|
809
380
|
* - **Texture**: Pre-existing cube texture via `map` prop
|
|
810
381
|
* - **Custom Scene**: Render children into environment using portal and cube camera
|
|
811
382
|
* - **Ground Projection**: Project environment onto ground plane
|
|
@@ -894,7 +465,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
|
|
|
894
465
|
* />
|
|
895
466
|
* ```
|
|
896
467
|
*/
|
|
897
|
-
declare function Environment(props: EnvironmentProps):
|
|
468
|
+
declare function Environment(props: EnvironmentProps): React$1.JSX.Element;
|
|
898
469
|
|
|
899
470
|
/**
|
|
900
471
|
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
@@ -1012,7 +583,7 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
1012
583
|
input: Parameters<typeof useTexture>[0];
|
|
1013
584
|
onLoad?: Parameters<typeof useTexture>[1];
|
|
1014
585
|
cache?: boolean;
|
|
1015
|
-
}) =>
|
|
586
|
+
}) => React$1.JSX.Element;
|
|
1016
587
|
|
|
1017
588
|
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1018
589
|
type TextureInput = string | string[] | Record<string, string>;
|
|
@@ -1799,7 +1370,8 @@ declare namespace ReactReconciler {
|
|
|
1799
1370
|
type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
|
|
1800
1371
|
|
|
1801
1372
|
type Lanes = number;
|
|
1802
|
-
|
|
1373
|
+
|
|
1374
|
+
type Lane = number & { __LaneBrand: any };
|
|
1803
1375
|
|
|
1804
1376
|
type Flags = number;
|
|
1805
1377
|
|
|
@@ -2130,7 +1702,6 @@ declare namespace ReactReconciler {
|
|
|
2130
1702
|
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
2131
1703
|
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
2132
1704
|
onDefaultTransitionIndicator: () => void,
|
|
2133
|
-
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
2134
1705
|
): OpaqueRoot;
|
|
2135
1706
|
|
|
2136
1707
|
createPortal(
|
|
@@ -2140,8 +1711,6 @@ declare namespace ReactReconciler {
|
|
|
2140
1711
|
key?: string | null,
|
|
2141
1712
|
): ReactPortal;
|
|
2142
1713
|
|
|
2143
|
-
registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
|
|
2144
|
-
|
|
2145
1714
|
createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
|
|
2146
1715
|
|
|
2147
1716
|
createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
|
|
@@ -2176,8 +1745,12 @@ declare namespace ReactReconciler {
|
|
|
2176
1745
|
isStrictMode: boolean,
|
|
2177
1746
|
concurrentUpdatesByDefaultOverride: null | boolean,
|
|
2178
1747
|
identifierPrefix: string,
|
|
2179
|
-
|
|
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,
|
|
2180
1752
|
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
1753
|
+
formState: unknown,
|
|
2181
1754
|
): OpaqueRoot;
|
|
2182
1755
|
|
|
2183
1756
|
updateContainer(
|
|
@@ -2187,17 +1760,27 @@ declare namespace ReactReconciler {
|
|
|
2187
1760
|
callback?: (() => void) | null,
|
|
2188
1761
|
): Lane;
|
|
2189
1762
|
|
|
1763
|
+
updateContainerSync(
|
|
1764
|
+
element: ReactNode,
|
|
1765
|
+
container: OpaqueRoot,
|
|
1766
|
+
parentComponent?: Component<any, any> | null,
|
|
1767
|
+
callback?: (() => void) | null,
|
|
1768
|
+
): Lane;
|
|
1769
|
+
|
|
2190
1770
|
batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
|
|
2191
1771
|
|
|
2192
1772
|
deferredUpdates<A>(fn: () => A): A;
|
|
2193
1773
|
|
|
2194
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;
|
|
2195
1775
|
|
|
2196
|
-
flushControlled(fn: () => any): void;
|
|
2197
|
-
|
|
2198
1776
|
flushSync(): void;
|
|
2199
1777
|
flushSync<R>(fn: () => R): R;
|
|
2200
1778
|
|
|
1779
|
+
flushSyncFromReconciler(): void;
|
|
1780
|
+
flushSyncFromReconciler<R>(fn: () => R): R;
|
|
1781
|
+
|
|
1782
|
+
flushSyncWork(): boolean;
|
|
1783
|
+
|
|
2201
1784
|
isAlreadyRendering(): boolean;
|
|
2202
1785
|
|
|
2203
1786
|
flushPassiveEffects(): boolean;
|
|
@@ -2206,16 +1789,10 @@ declare namespace ReactReconciler {
|
|
|
2206
1789
|
|
|
2207
1790
|
attemptSynchronousHydration(fiber: Fiber): void;
|
|
2208
1791
|
|
|
2209
|
-
attemptDiscreteHydration(fiber: Fiber): void;
|
|
2210
|
-
|
|
2211
1792
|
attemptContinuousHydration(fiber: Fiber): void;
|
|
2212
1793
|
|
|
2213
1794
|
attemptHydrationAtCurrentPriority(fiber: Fiber): void;
|
|
2214
1795
|
|
|
2215
|
-
getCurrentUpdatePriority(): LanePriority;
|
|
2216
|
-
|
|
2217
|
-
runWithPriority<T>(priority: LanePriority, fn: () => T): T;
|
|
2218
|
-
|
|
2219
1796
|
findHostInstance(component: any): PublicInstance | null;
|
|
2220
1797
|
|
|
2221
1798
|
findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
|
|
@@ -2228,19 +1805,86 @@ declare namespace ReactReconciler {
|
|
|
2228
1805
|
|
|
2229
1806
|
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
|
|
2230
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;
|
|
2231
1819
|
}
|
|
2232
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
|
+
*/
|
|
2233
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. */
|
|
2234
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. */
|
|
2235
1847
|
declare function extend(objects: Record<string, unknown>): void;
|
|
2236
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
|
+
*/
|
|
2237
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;
|
|
2238
1878
|
|
|
2239
|
-
declare const isRenderer: (def: any) => boolean;
|
|
2240
|
-
interface OffscreenCanvas extends EventTarget {
|
|
2241
|
-
}
|
|
2242
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
|
+
*/
|
|
2243
1886
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
1887
|
+
|
|
2244
1888
|
declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
|
|
2245
1889
|
interface PortalProps {
|
|
2246
1890
|
children: ReactNode;
|
|
@@ -2248,14 +1892,89 @@ interface PortalProps {
|
|
|
2248
1892
|
container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
|
|
2249
1893
|
}
|
|
2250
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
|
+
}
|
|
2251
1907
|
/**
|
|
2252
|
-
*
|
|
2253
|
-
*
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
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
|
|
2256
1915
|
*/
|
|
2257
|
-
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[];
|
|
2258
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
|
+
*/
|
|
2259
1978
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
2260
1979
|
|
|
2261
1980
|
/** Whether any root has loaded a renderer yet. */
|
|
@@ -2288,7 +2007,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
|
|
|
2288
2007
|
*/
|
|
2289
2008
|
declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
|
|
2290
2009
|
/**
|
|
2291
|
-
* Bridges renderer Context and
|
|
2010
|
+
* Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
|
|
2292
2011
|
* Used to maintain React context when rendering into portals or secondary canvases.
|
|
2293
2012
|
*
|
|
2294
2013
|
* @returns A Bridge component that wraps children with the parent renderer's context
|
|
@@ -2771,5 +2490,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
2771
2490
|
[ONCE]: any[] | true;
|
|
2772
2491
|
};
|
|
2773
2492
|
|
|
2774
|
-
export {
|
|
2775
|
-
export type {
|
|
2493
|
+
export { Texture as $, EnvironmentMap as F, EnvironmentCube as H, EnvironmentPortal as J, Environment as K, presetsObj as M, swapInteractivity as O, removeInteractivity as Q, createEvents as S, useInstanceHandle as T, useGraph as U, useLoader as V, IsObject as X, useTexture as _, addEffect as a, useTextures as a4, useEnvironment as a6, extend as a7, reconciler as a8, flushSync as a9, applyProps as aA, is as aB, isOrthographicCamera as aC, isRef as aD, isColorRepresentation as aE, isObject3D as aF, isTexture as aG, isLayers as aH, isUniform as aI, isVectorLike as aJ, isCopyable as aK, hasConstructor as aL, FROM_REF as aM, fromRef as aO, isFromRef as aP, ONCE as aQ, once as aR, isOnce as aT, _roots as aa, unmountComponentAtNode as ab, createPortal as ac, Portal as ad, useIsomorphicLayoutEffect as ae, useMutableCallback as af, useBridge as ag, Block as ah, ErrorBoundary as ai, calculateDpr as aj, getUuidPrefix as ak, updateCamera as al, updateFrustum as am, REACT_INTERNAL_PROPS as an, findInitialRoot as ao, getRootState as ap, buildGraph as aq, dispose as ar, getInstanceProps as as, prepare as at, invalidateInstance as au, RESERVED_PROPS as av, resolve as aw, attach as ax, detach as ay, diffProps 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, LegacyRootState as C, EnvironmentProps as D, Extensions as E, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as N, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Y, UseTextureOptions as Z, TextureInput as a0, TextureResult as a1, DisposeOptions as a2, UseTexturesReturn as a3, EnvironmentLoaderProps as a5, FromRefMarker as aN, OnceValue as aS, CanvasProps as aU, 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 };
|