@react-three/fiber 10.0.0-canary.f75fbf6 → 10.0.0-canary.fbd44ae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.cjs +8 -8
- package/dist/extension.d.cts +4 -4
- package/dist/extension.d.mts +4 -4
- package/dist/extension.d.ts +4 -4
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +3 -3
- package/dist/legacy.cjs +13 -13
- package/dist/legacy.d.cts +10 -7
- package/dist/legacy.d.mts +10 -7
- package/dist/legacy.d.ts +10 -7
- package/dist/legacy.mjs +4 -4
- package/dist/shared/{fiber.DH-VJXM_.d.ts → fiber.3jeDXXYd.d.mts} +82 -458
- package/dist/shared/{fiber.AN9kOS0N.d.mts → fiber.B_KQAb3I.d.ts} +82 -458
- package/dist/shared/{fiber.EDf0d92E.cjs → fiber.Bi_S5KAx.cjs} +2213 -1675
- package/dist/shared/{fiber.BgP4izaL.d.cts → fiber.C6hitYDY.d.cts} +1 -1
- package/dist/shared/{fiber.BgxhptM_.mjs → fiber.CFK811nR.mjs} +2099 -1561
- package/dist/shared/{fiber.Dh8K6RJr.d.cts → fiber.C_MFx7We.d.cts} +472 -20
- package/dist/shared/{fiber.Dh8K6RJr.d.mts → fiber.C_MFx7We.d.mts} +472 -20
- package/dist/shared/{fiber.Dh8K6RJr.d.ts → fiber.C_MFx7We.d.ts} +472 -20
- package/dist/shared/{fiber.BcX0-yko.d.mts → fiber.D4fD6H74.d.mts} +1 -1
- package/dist/shared/{fiber.B0oukOFO.mjs → fiber.QxL_6jra.mjs} +80 -54
- package/dist/shared/{fiber.BIhZnMzg.d.ts → fiber.YgTUGbja.d.ts} +1 -1
- package/dist/shared/{fiber.khFlPHPf.cjs → fiber.eR9ie2vQ.cjs} +80 -52
- package/dist/shared/{fiber.cO-9hDzr.d.cts → fiber.fR3DaJb1.d.cts} +82 -458
- package/dist/webgpu/index.cjs +13 -13
- package/dist/webgpu/index.d.cts +5 -5
- package/dist/webgpu/index.d.mts +5 -5
- package/dist/webgpu/index.d.ts +5 -5
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +2 -2
|
@@ -1,241 +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 { ColorRepresentation, Euler
|
|
6
|
-
import {
|
|
7
|
-
import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
|
|
8
|
-
|
|
9
|
-
//* Base Renderer Types =====================================
|
|
10
|
-
|
|
11
|
-
// Shim for OffscreenCanvas since it was removed from DOM types
|
|
12
|
-
interface OffscreenCanvas$1 extends EventTarget {}
|
|
13
|
-
|
|
14
|
-
interface BaseRendererProps {
|
|
15
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
16
|
-
powerPreference?: 'high-performance' | 'low-power' | 'default'
|
|
17
|
-
antialias?: boolean
|
|
18
|
-
alpha?: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type RendererFactory<TRenderer, TParams> =
|
|
22
|
-
| TRenderer
|
|
23
|
-
| ((defaultProps: TParams) => TRenderer)
|
|
24
|
-
| ((defaultProps: TParams) => Promise<TRenderer>)
|
|
25
|
-
|
|
26
|
-
interface Renderer {
|
|
27
|
-
render: (scene: THREE.Scene, camera: THREE.Camera) => any
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//* Color Management Config ==============================
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
34
|
-
*/
|
|
35
|
-
interface ColorManagementConfig {
|
|
36
|
-
/**
|
|
37
|
-
* Color space assigned to 8-bit input textures (color maps).
|
|
38
|
-
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
39
|
-
* @default THREE.SRGBColorSpace
|
|
40
|
-
*/
|
|
41
|
-
textureColorSpace?: THREE.ColorSpace
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//* WebGL Renderer Props ==============================
|
|
45
|
-
|
|
46
|
-
type DefaultGLProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
|
|
47
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type GLProps =
|
|
51
|
-
| Renderer
|
|
52
|
-
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
53
|
-
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
54
|
-
| (Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> & ColorManagementConfig)
|
|
55
|
-
|
|
56
|
-
//* WebGPU Renderer Props ==============================
|
|
57
|
-
|
|
58
|
-
type DefaultRendererProps = {
|
|
59
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
60
|
-
[key: string]: any
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Canvas-level scheduler configuration.
|
|
65
|
-
* Controls render timing relative to other canvases.
|
|
66
|
-
*/
|
|
67
|
-
interface CanvasSchedulerConfig {
|
|
68
|
-
/**
|
|
69
|
-
* Run this Canvas root before the referenced Canvas root id(s).
|
|
70
|
-
*/
|
|
71
|
-
before?: string | string[]
|
|
72
|
-
/**
|
|
73
|
-
* Run this Canvas root after the referenced Canvas root id(s).
|
|
74
|
-
*/
|
|
75
|
-
after?: string | string[]
|
|
76
|
-
/**
|
|
77
|
-
* Numeric root order. Lower values run first.
|
|
78
|
-
*/
|
|
79
|
-
order?: number
|
|
80
|
-
/**
|
|
81
|
-
* Limit this Canvas's default render job (frames per second).
|
|
82
|
-
*/
|
|
83
|
-
fps?: number
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Extended renderer configuration for multi-canvas support and color management.
|
|
88
|
-
*/
|
|
89
|
-
interface RendererConfigExtended extends ColorManagementConfig {
|
|
90
|
-
/** Share renderer from another canvas (WebGPU only) */
|
|
91
|
-
primaryCanvas?: string
|
|
92
|
-
/** Canvas-level scheduler options */
|
|
93
|
-
scheduler?: CanvasSchedulerConfig
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The `renderer` prop: opt into three's WebGPU renderer.
|
|
98
|
-
* - `true` (the `<Canvas renderer>` shorthand) or `{}`: a default `WebGPURenderer`
|
|
99
|
-
* - a props bag: constructor parameters (`antialias`, `forceWebGL`, ...) and renderer properties
|
|
100
|
-
* (`toneMapping`, ...), plus `textureColorSpace`, `primaryCanvas` and `scheduler`
|
|
101
|
-
* - a renderer instance, or a sync/async factory receiving the default props. Structural, like
|
|
102
|
-
* the `gl` prop: anything with `render()`, so a wrapped or mocked renderer is accepted.
|
|
103
|
-
*/
|
|
104
|
-
type RendererProps =
|
|
105
|
-
| boolean
|
|
106
|
-
| Renderer
|
|
107
|
-
| ((defaultProps: DefaultRendererProps) => Renderer)
|
|
108
|
-
| ((defaultProps: DefaultRendererProps) => Promise<Renderer>)
|
|
109
|
-
| (Partial<Properties<WebGPURenderer> & WebGPURendererParameters> & RendererConfigExtended)
|
|
110
|
-
|
|
111
|
-
//* Camera Props ==============================
|
|
112
|
-
|
|
113
|
-
type CameraProps = (
|
|
114
|
-
| THREE.Camera
|
|
115
|
-
| Partial<
|
|
116
|
-
ThreeElement<typeof THREE.Camera> &
|
|
117
|
-
ThreeElement<typeof THREE.PerspectiveCamera> &
|
|
118
|
-
ThreeElement<typeof THREE.OrthographicCamera>
|
|
119
|
-
>
|
|
120
|
-
) & {
|
|
121
|
-
/** Flags the camera as manual, putting projection into your own hands */
|
|
122
|
-
manual?: boolean
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
//* Render Props ==============================
|
|
126
|
-
|
|
127
|
-
interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
128
|
-
/**
|
|
129
|
-
* Unique identifier for multi-canvas renderer sharing.
|
|
130
|
-
* Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
|
|
131
|
-
* Also sets the HTML `id` attribute on the canvas element.
|
|
132
|
-
* @example <Canvas id="main-viewer">...</Canvas>
|
|
133
|
-
*/
|
|
134
|
-
id?: string
|
|
135
|
-
/**
|
|
136
|
-
* Share the renderer from another canvas instead of creating a new one.
|
|
137
|
-
* Pass the `id` of the primary canvas to share its WebGPURenderer.
|
|
138
|
-
* Only available with WebGPU (not legacy WebGL).
|
|
139
|
-
*
|
|
140
|
-
* Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
primaryCanvas?: string
|
|
144
|
-
/**
|
|
145
|
-
* Canvas-level scheduler options. Controls render timing relative to other canvases.
|
|
146
|
-
*
|
|
147
|
-
* Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
scheduler?: CanvasSchedulerConfig
|
|
151
|
-
/** A threejs renderer instance or props that go into the default renderer */
|
|
152
|
-
gl?: GLProps
|
|
153
|
-
/** A WebGPU renderer instance or props that go into the default renderer */
|
|
154
|
-
renderer?: RendererProps
|
|
155
|
-
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
156
|
-
size?: Size
|
|
157
|
-
/**
|
|
158
|
-
* Enables shadows (`true` uses `THREE.PCFShadowMap`). Can accept `renderer.shadowMap` options for
|
|
159
|
-
* fine-tuning, but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
160
|
-
*
|
|
161
|
-
* `'soft'` is a deprecated alias of `'percentage'`: both map to `THREE.PCFShadowMap`, because three.js
|
|
162
|
-
* deprecated `PCFSoftShadowMap` and made `PCFShadowMap` soft. Using `'soft'` logs a deprecation notice.
|
|
163
|
-
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
164
|
-
*/
|
|
165
|
-
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
|
|
166
|
-
/** Creates an orthographic camera */
|
|
167
|
-
orthographic?: boolean
|
|
168
|
-
/**
|
|
169
|
-
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
170
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
171
|
-
*/
|
|
172
|
-
frameloop?: Frameloop
|
|
173
|
-
/**
|
|
174
|
-
* R3F performance options for adaptive performance.
|
|
175
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
176
|
-
*/
|
|
177
|
-
performance?: Partial<Omit<Performance, 'regress'>>
|
|
178
|
-
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
179
|
-
dpr?: Dpr
|
|
180
|
-
/**
|
|
181
|
-
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
182
|
-
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
183
|
-
*/
|
|
184
|
-
raycaster?: Partial<Omit<THREE.Raycaster, 'params'>> & { params?: Partial<THREE.RaycasterParameters> }
|
|
185
|
-
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
186
|
-
scene?: THREE.Scene | Partial<THREE.Scene>
|
|
187
|
-
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
188
|
-
camera?: CameraProps
|
|
189
|
-
/** An R3F event manager to manage elements' pointer events */
|
|
190
|
-
events?: (store: RootStore) => EventManager<Element>
|
|
191
|
-
/** Callback after the canvas has rendered (but not yet committed) */
|
|
192
|
-
onCreated?: (state: RootState) => void
|
|
193
|
-
/** Response for pointer clicks that have missed any target */
|
|
194
|
-
onPointerMissed?: (event: MouseEvent) => void
|
|
195
|
-
/** Response for dragover events that have missed any target */
|
|
196
|
-
onDragOverMissed?: (event: DragEvent) => void
|
|
197
|
-
/** Response for drop events that have missed any target */
|
|
198
|
-
onDropMissed?: (event: DragEvent) => void
|
|
199
|
-
/** Whether to automatically update the frustum each frame (default: true) */
|
|
200
|
-
autoUpdateFrustum?: boolean
|
|
201
|
-
/**
|
|
202
|
-
* Enable WebGPU occlusion queries for onOccluded/onVisible events.
|
|
203
|
-
* Auto-enabled when any object uses onOccluded or onVisible handlers.
|
|
204
|
-
* Only works with WebGPU renderer - WebGL will log a warning.
|
|
205
|
-
*/
|
|
206
|
-
occlusion?: boolean
|
|
207
|
-
/** Internal: stored size props from Canvas for reset functionality */
|
|
208
|
-
_sizeProps?: { width?: number; height?: number } | null
|
|
209
|
-
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
210
|
-
forceEven?: boolean
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
//* Reconciler Root ==============================
|
|
214
|
-
|
|
215
|
-
interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
216
|
-
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
|
|
217
|
-
render: (element: ReactNode) => RootStore
|
|
218
|
-
unmount: () => void
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
//* Inject State ==============================
|
|
222
|
-
|
|
223
|
-
type InjectState = Partial<
|
|
224
|
-
Omit<RootState, 'events'> & {
|
|
225
|
-
events?: {
|
|
226
|
-
enabled?: boolean
|
|
227
|
-
priority?: number
|
|
228
|
-
compute?: ComputeFunction
|
|
229
|
-
connected?: any
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
|
|
233
|
-
* This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
|
|
234
|
-
* Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
|
|
235
|
-
*/
|
|
236
|
-
injectScene?: boolean
|
|
237
|
-
}
|
|
238
|
-
>
|
|
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';
|
|
239
8
|
|
|
240
9
|
//* Loop Types ==============================
|
|
241
10
|
|
|
@@ -270,12 +39,12 @@ interface BackgroundConfig {
|
|
|
270
39
|
files?: string | string[]
|
|
271
40
|
/** Separate files for scene.background (visual backdrop) */
|
|
272
41
|
backgroundMap?: string | string[]
|
|
273
|
-
backgroundRotation?: Euler
|
|
42
|
+
backgroundRotation?: Euler | [number, number, number]
|
|
274
43
|
backgroundBlurriness?: number
|
|
275
44
|
backgroundIntensity?: number
|
|
276
45
|
/** Separate files for scene.environment (PBR lighting/reflections) */
|
|
277
46
|
envMap?: string | string[]
|
|
278
|
-
environmentRotation?: Euler
|
|
47
|
+
environmentRotation?: Euler | [number, number, number]
|
|
279
48
|
environmentIntensity?: number
|
|
280
49
|
path?: string
|
|
281
50
|
extensions?: (loader: Loader) => void
|
|
@@ -325,9 +94,7 @@ type BackgroundProp =
|
|
|
325
94
|
//* Canvas Types ==============================
|
|
326
95
|
|
|
327
96
|
interface CanvasProps
|
|
328
|
-
extends
|
|
329
|
-
Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
|
|
330
|
-
React$1.HTMLAttributes<HTMLDivElement> {
|
|
97
|
+
extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
|
|
331
98
|
children?: React$1.ReactNode
|
|
332
99
|
ref?: React$1.Ref<HTMLCanvasElement>
|
|
333
100
|
/** Canvas fallback content, similar to img's alt prop */
|
|
@@ -446,211 +213,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
446
213
|
|
|
447
214
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
448
215
|
|
|
449
|
-
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
450
|
-
|
|
451
|
-
interface MathRepresentation {
|
|
452
|
-
set(...args: number[]): any
|
|
453
|
-
}
|
|
454
|
-
interface VectorRepresentation extends MathRepresentation {
|
|
455
|
-
setScalar(value: number): any
|
|
456
|
-
}
|
|
457
|
-
type MathTypes = MathRepresentation | THREE.Euler | THREE.Color
|
|
458
|
-
|
|
459
|
-
type MathType<T extends MathTypes> = T extends THREE.Color
|
|
460
|
-
? Args<typeof THREE.Color> | THREE.ColorRepresentation
|
|
461
|
-
: T extends VectorRepresentation | THREE.Layers | THREE.Euler
|
|
462
|
-
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
463
|
-
: T | MutableOrReadonlyParameters<T['set']>
|
|
464
|
-
|
|
465
|
-
type MathProps<P> = {
|
|
466
|
-
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
type Vector2 = MathType<THREE.Vector2>
|
|
470
|
-
type Vector3 = MathType<THREE.Vector3>
|
|
471
|
-
type Vector4 = MathType<THREE.Vector4>
|
|
472
|
-
type Color = MathType<THREE.Color>
|
|
473
|
-
type Layers = MathType<THREE.Layers>
|
|
474
|
-
type Quaternion = MathType<THREE.Quaternion>
|
|
475
|
-
type Euler = MathType<THREE.Euler>
|
|
476
|
-
type Matrix3 = MathType<THREE.Matrix3>
|
|
477
|
-
type Matrix4 = MathType<THREE.Matrix4>
|
|
478
|
-
|
|
479
|
-
interface RaycastableRepresentation {
|
|
480
|
-
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
|
|
481
|
-
}
|
|
482
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Props for geometry transform methods that can be called with `once()`.
|
|
486
|
-
* These methods modify the geometry in-place and only make sense to call once on mount.
|
|
487
|
-
*
|
|
488
|
-
* @example
|
|
489
|
-
* import { once } from '@react-three/fiber'
|
|
490
|
-
*
|
|
491
|
-
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
492
|
-
* <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
|
|
493
|
-
* <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
|
|
494
|
-
*/
|
|
495
|
-
interface GeometryTransformProps {
|
|
496
|
-
/** Rotate the geometry about the X axis (radians). Use with once(). */
|
|
497
|
-
rotateX?: number
|
|
498
|
-
/** Rotate the geometry about the Y axis (radians). Use with once(). */
|
|
499
|
-
rotateY?: number
|
|
500
|
-
/** Rotate the geometry about the Z axis (radians). Use with once(). */
|
|
501
|
-
rotateZ?: number
|
|
502
|
-
/** Translate the geometry (x, y, z). Use with once(). */
|
|
503
|
-
translate?: [x: number, y: number, z: number]
|
|
504
|
-
/** Scale the geometry (x, y, z). Use with once(). */
|
|
505
|
-
scale?: [x: number, y: number, z: number]
|
|
506
|
-
/** Center the geometry based on bounding box. Use with once(). */
|
|
507
|
-
center?: true
|
|
508
|
-
/** Apply a Matrix4 transformation. Use with once(). */
|
|
509
|
-
applyMatrix4?: THREE.Matrix4
|
|
510
|
-
/** Apply a Quaternion rotation. Use with once(). */
|
|
511
|
-
applyQuaternion?: THREE.Quaternion
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
type GeometryProps<P> = P extends THREE.BufferGeometry ? GeometryTransformProps : {}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Workaround for @types/three TSL node type issues.
|
|
518
|
-
* The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
|
|
519
|
-
* This transforms `Node | null` properties to accept any object with node-like shape.
|
|
520
|
-
*/
|
|
521
|
-
type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
525
|
-
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
526
|
-
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
527
|
-
*/
|
|
528
|
-
type NodeProps<P> = {
|
|
529
|
-
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
interface ReactProps<P> {
|
|
533
|
-
children?: React.ReactNode
|
|
534
|
-
ref?: React.Ref<P>
|
|
535
|
-
key?: React.Key
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
539
|
-
Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
|
|
540
|
-
>
|
|
541
|
-
|
|
542
|
-
type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
543
|
-
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
544
|
-
>
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Every constructor export of a three namespace as an uncapitalized JSX element. Non-constructor
|
|
548
|
-
* exports (constants, functions, nested namespaces) are dropped from the keys rather than mapped
|
|
549
|
-
* to `never`: a single `never`-valued key in `JSX.IntrinsicElements` collapses the props of any
|
|
550
|
-
* tag typed `React.ElementType` (#3898).
|
|
551
|
-
*/
|
|
552
|
-
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
553
|
-
[K in keyof T & string as T[K] extends ConstructorRepresentation ? Uncapitalize<K> : never]: ThreeElement<T[K]>
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
557
|
-
type Object3DMethod = NonNullable<
|
|
558
|
-
{
|
|
559
|
-
[K in keyof THREE.Object3D]-?: THREE.Object3D[K] extends (...args: any[]) => any ? K : never
|
|
560
|
-
}[keyof THREE.Object3D]
|
|
561
|
-
>
|
|
562
|
-
|
|
563
|
-
/** Look up a key present in a generic element map. */
|
|
564
|
-
type ElementOf<E, K extends string> = E[Extract<keyof E, K>]
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* The JSX element map derived from an entry's Three.js exports. Each entry declares its own
|
|
568
|
-
* `ThreeElements` from this (`src/index.tsx`, `src/legacy.tsx`, `src/webgpu/index.tsx`) and augments
|
|
569
|
-
* react's `IntrinsicElements` with it, so `/legacy` never advertises node materials and `/webgpu`
|
|
570
|
-
* never advertises a `<webGLRenderer>`.
|
|
571
|
-
*/
|
|
572
|
-
type ThreeElementsOf<T extends Record<string, any>> = Omit<
|
|
573
|
-
ThreeToJSXElements<T>,
|
|
574
|
-
'audio' | 'source' | 'line' | 'path'
|
|
575
|
-
> & {
|
|
576
|
-
/**
|
|
577
|
-
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
578
|
-
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
579
|
-
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
580
|
-
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
581
|
-
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
582
|
-
*/
|
|
583
|
-
primitive: Omit<ThreeElement<typeof THREE.Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
584
|
-
object: object
|
|
585
|
-
ref?: React.Ref<any>
|
|
586
|
-
[prop: string]: unknown
|
|
587
|
-
}
|
|
588
|
-
// Conflicts with DOM types can be accessed through a three* prefix
|
|
589
|
-
threeAudio: ElementOf<ThreeToJSXElements<T>, 'audio'>
|
|
590
|
-
threeSource: ElementOf<ThreeToJSXElements<T>, 'source'>
|
|
591
|
-
threeLine: ElementOf<ThreeToJSXElements<T>, 'line'>
|
|
592
|
-
threePath: ElementOf<ThreeToJSXElements<T>, 'path'>
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* @fileoverview Registry for primary canvases that can be targeted by secondary canvases
|
|
597
|
-
*
|
|
598
|
-
* Enables multi-canvas WebGPU rendering where multiple Canvas components share
|
|
599
|
-
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
600
|
-
*
|
|
601
|
-
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
602
|
-
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
603
|
-
*/
|
|
604
|
-
|
|
605
|
-
interface PrimaryCanvasEntry {
|
|
606
|
-
/** The WebGPURenderer instance owned by this primary canvas */
|
|
607
|
-
renderer: WebGPURenderer;
|
|
608
|
-
/** The zustand store for this canvas */
|
|
609
|
-
store: RootStore;
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Register a primary canvas that can be targeted by secondary canvases.
|
|
613
|
-
*
|
|
614
|
-
* @param id - Unique identifier for this primary canvas
|
|
615
|
-
* @param renderer - The WebGPURenderer owned by this canvas
|
|
616
|
-
* @param store - The zustand store for this canvas
|
|
617
|
-
* @returns Cleanup function to unregister on unmount
|
|
618
|
-
*/
|
|
619
|
-
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
|
|
620
|
-
/**
|
|
621
|
-
* Get a registered primary canvas by id.
|
|
622
|
-
*
|
|
623
|
-
* @param id - The id of the primary canvas to look up
|
|
624
|
-
* @returns The primary canvas entry or undefined if not found
|
|
625
|
-
*/
|
|
626
|
-
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
627
|
-
/**
|
|
628
|
-
* Wait for a primary canvas to be registered.
|
|
629
|
-
* Returns immediately if already registered, otherwise waits.
|
|
630
|
-
*
|
|
631
|
-
* @param id - The id of the primary canvas to wait for
|
|
632
|
-
* @param timeout - Optional timeout in ms (default: 5000)
|
|
633
|
-
* @returns Promise that resolves with the primary canvas entry
|
|
634
|
-
*/
|
|
635
|
-
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
636
|
-
/**
|
|
637
|
-
* Check if a primary canvas with the given id exists.
|
|
638
|
-
*
|
|
639
|
-
* @param id - The id to check
|
|
640
|
-
* @returns True if a primary canvas with this id is registered
|
|
641
|
-
*/
|
|
642
|
-
declare function hasPrimary(id: string): boolean;
|
|
643
|
-
/**
|
|
644
|
-
* Unregister a primary canvas. Called on unmount.
|
|
645
|
-
*
|
|
646
|
-
* @param id - The id of the primary canvas to unregister
|
|
647
|
-
*/
|
|
648
|
-
declare function unregisterPrimary(id: string): void;
|
|
649
|
-
/**
|
|
650
|
-
* Get all registered primary canvas ids. Useful for debugging.
|
|
651
|
-
*/
|
|
652
|
-
declare function getPrimaryIds(): string[];
|
|
653
|
-
|
|
654
216
|
type EnvironmentLoaderProps = {
|
|
655
217
|
files?: string | string[];
|
|
656
218
|
path?: string;
|
|
@@ -723,9 +285,9 @@ type EnvironmentProps = {
|
|
|
723
285
|
blur?: number;
|
|
724
286
|
backgroundBlurriness?: number;
|
|
725
287
|
backgroundIntensity?: number;
|
|
726
|
-
backgroundRotation?: Euler;
|
|
288
|
+
backgroundRotation?: Euler$1;
|
|
727
289
|
environmentIntensity?: number;
|
|
728
|
-
environmentRotation?: Euler;
|
|
290
|
+
environmentRotation?: Euler$1;
|
|
729
291
|
map?: Texture$1;
|
|
730
292
|
preset?: PresetsType;
|
|
731
293
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2305,12 +1867,23 @@ declare function extend(objects: Record<string, unknown>): void;
|
|
|
2305
1867
|
* `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
|
|
2306
1868
|
*/
|
|
2307
1869
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
1872
|
+
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
1873
|
+
* Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
|
|
1874
|
+
* having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
|
|
1875
|
+
*/
|
|
1876
|
+
declare function flushSync<R>(fn: () => R): R;
|
|
2308
1877
|
|
|
2309
|
-
declare const isRenderer: (def: any) => boolean;
|
|
2310
|
-
interface OffscreenCanvas extends EventTarget {
|
|
2311
|
-
}
|
|
2312
1878
|
declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
1879
|
+
/**
|
|
1880
|
+
* Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
|
|
1881
|
+
* for a renderer that is still being created. `callback` runs when the root is gone: after the
|
|
1882
|
+
* teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
|
|
1883
|
+
* from three r186), after that dispose has settled.
|
|
1884
|
+
*/
|
|
2313
1885
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
1886
|
+
|
|
2314
1887
|
declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
|
|
2315
1888
|
interface PortalProps {
|
|
2316
1889
|
children: ReactNode;
|
|
@@ -2318,20 +1891,71 @@ interface PortalProps {
|
|
|
2318
1891
|
container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
|
|
2319
1892
|
}
|
|
2320
1893
|
declare function Portal({ children, container, state }: PortalProps): JSX.Element;
|
|
1894
|
+
|
|
1895
|
+
/** Renderer resources: creation, shared canvas lookup, and ownership through final release. */
|
|
1896
|
+
|
|
1897
|
+
declare const isRenderer: (def: any) => boolean;
|
|
1898
|
+
interface PrimaryCanvasEntry {
|
|
1899
|
+
/** The WebGPURenderer instance owned by this primary canvas */
|
|
1900
|
+
renderer: WebGPURenderer;
|
|
1901
|
+
/** The zustand store for this canvas */
|
|
1902
|
+
store: RootStore;
|
|
1903
|
+
/** The primary's scheduler root id; a sharing canvas renders after it by default */
|
|
1904
|
+
rootId?: string;
|
|
1905
|
+
}
|
|
2321
1906
|
/**
|
|
2322
|
-
*
|
|
2323
|
-
*
|
|
2324
|
-
*
|
|
2325
|
-
*
|
|
1907
|
+
* Register a primary canvas that can be targeted by secondary canvases.
|
|
1908
|
+
*
|
|
1909
|
+
* @param id - Registry key: the canvas id, or DEFAULT_PRIMARY
|
|
1910
|
+
* @param renderer - The WebGPURenderer owned by this canvas
|
|
1911
|
+
* @param store - The zustand store for this canvas
|
|
1912
|
+
* @param options - The owner token that announced it and its scheduler root id
|
|
1913
|
+
* @returns Cleanup function to unregister on unmount
|
|
2326
1914
|
*/
|
|
2327
|
-
declare function
|
|
1915
|
+
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore, options?: {
|
|
1916
|
+
token?: object;
|
|
1917
|
+
rootId?: string;
|
|
1918
|
+
}): () => void;
|
|
1919
|
+
/**
|
|
1920
|
+
* Get a registered primary canvas by id.
|
|
1921
|
+
*
|
|
1922
|
+
* @param id - The id of the primary canvas to look up
|
|
1923
|
+
* @returns The primary canvas entry or undefined if not found
|
|
1924
|
+
*/
|
|
1925
|
+
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
1926
|
+
/**
|
|
1927
|
+
* Wait for a primary canvas to be registered (`share="id"`).
|
|
1928
|
+
* Returns immediately if already registered, otherwise waits, even through a primary remounting.
|
|
1929
|
+
*
|
|
1930
|
+
* @param id - The id of the primary canvas to wait for
|
|
1931
|
+
* @param timeout - Optional timeout in ms (default: 5000)
|
|
1932
|
+
* @returns Promise that resolves with the primary canvas entry
|
|
1933
|
+
*/
|
|
1934
|
+
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
1935
|
+
/**
|
|
1936
|
+
* Check if a primary canvas with the given id exists.
|
|
1937
|
+
*
|
|
1938
|
+
* @param id - The id to check
|
|
1939
|
+
* @returns True if a primary canvas with this id is registered
|
|
1940
|
+
*/
|
|
1941
|
+
declare function hasPrimary(id: string): boolean;
|
|
1942
|
+
/**
|
|
1943
|
+
* Unregister a primary canvas. Called on unmount.
|
|
1944
|
+
*
|
|
1945
|
+
* @param id - The id of the primary canvas to unregister
|
|
1946
|
+
*/
|
|
1947
|
+
declare function unregisterPrimary(id: string): void;
|
|
1948
|
+
/**
|
|
1949
|
+
* Get all registered primary canvas ids. Useful for debugging.
|
|
1950
|
+
*/
|
|
1951
|
+
declare function getPrimaryIds(): string[];
|
|
2328
1952
|
|
|
2329
1953
|
/**
|
|
2330
1954
|
* Creates the Zustand store that holds one root's {@link RootState}.
|
|
2331
1955
|
*
|
|
2332
1956
|
* The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
|
|
2333
1957
|
* are `null` placeholders until the root's renderer support has loaded and `configure()` in
|
|
2334
|
-
* `
|
|
1958
|
+
* `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
|
|
2335
1959
|
* fiber add their own fields through root extensions.
|
|
2336
1960
|
*
|
|
2337
1961
|
* Besides the initial state, the store wires up:
|
|
@@ -2382,7 +2006,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
|
|
|
2382
2006
|
*/
|
|
2383
2007
|
declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
|
|
2384
2008
|
/**
|
|
2385
|
-
* Bridges renderer Context and
|
|
2009
|
+
* Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
|
|
2386
2010
|
* Used to maintain React context when rendering into portals or secondary canvases.
|
|
2387
2011
|
*
|
|
2388
2012
|
* @returns A Bridge component that wraps children with the parent renderer's context
|
|
@@ -2865,5 +2489,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
2865
2489
|
[ONCE]: any[] | true;
|
|
2866
2490
|
};
|
|
2867
2491
|
|
|
2868
|
-
export {
|
|
2869
|
-
export type {
|
|
2492
|
+
export { useTexture as $, EnvironmentMap as H, EnvironmentCube as J, EnvironmentPortal as K, Environment as M, presetsObj as N, swapInteractivity as Q, removeInteractivity as S, createEvents as T, useInstanceHandle as U, useGraph as V, useLoader as X, IsObject as Y, addEffect as a, Texture as a0, useTextures as a5, useEnvironment as a7, extend as a8, reconciler as a9, diffProps as aA, applyProps as aB, is as aC, isOrthographicCamera as aD, isRef as aE, isColorRepresentation as aF, isObject3D as aG, isTexture as aH, isLayers as aI, isUniform as aJ, isVectorLike as aK, isCopyable as aL, hasConstructor as aM, FROM_REF as aN, fromRef as aP, isFromRef as aQ, ONCE as aR, once as aS, isOnce as aU, flushSync as aa, _roots as ab, unmountComponentAtNode as ac, createPortal as ad, Portal as ae, useIsomorphicLayoutEffect as af, useMutableCallback as ag, useBridge as ah, Block as ai, ErrorBoundary as aj, calculateDpr as ak, getUuidPrefix as al, updateCamera as am, updateFrustum as an, REACT_INTERNAL_PROPS as ao, findInitialRoot as ap, getRootState as aq, buildGraph as ar, dispose as as, getInstanceProps as at, prepare as au, invalidateInstance as av, RESERVED_PROPS as aw, resolve as ax, attach as ay, detach as az, addAfterEffect as b, createPointerEvents as c, addTail as d, advance as e, isRenderer as f, getPrimary as g, hasPrimary as h, invalidate as i, getPrimaryIds as j, createStore as k, getThree as l, hasThree as m, whenThree as n, registerPrimary as r, unregisterPrimary as u, waitForPrimary as w };
|
|
2493
|
+
export type { LegacyInternalState as A, BackgroundConfig as B, CanvasProps as C, LegacyRootState as D, Extensions as E, EnvironmentProps as F, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as O, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Z, UseTextureOptions as _, TextureInput as a1, TextureResult as a2, DisposeOptions as a3, UseTexturesReturn as a4, EnvironmentLoaderProps as a6, FromRefMarker as aO, OnceValue as aT, GlobalEffectType as o, BackgroundProp as p, GLTFLike as q, LoaderInstance as s, InferLoadResult as t, LoaderResult as v, WebGLProps as x, WebGLShadowConfig as y, LegacyRenderer as z };
|