@react-three/fiber 10.0.0-canary.9b237a7 → 10.0.0-canary.a1c1d93
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 +2 -1
- package/dist/extension.d.cts +9 -46
- package/dist/extension.d.mts +9 -46
- package/dist/extension.d.ts +9 -46
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -8
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.mjs +3 -3
- package/dist/legacy.cjs +2 -2
- package/dist/legacy.d.cts +4 -4
- package/dist/legacy.d.mts +4 -4
- package/dist/legacy.d.ts +4 -4
- package/dist/legacy.mjs +4 -4
- package/dist/shared/fiber.-1JhXWEC.d.cts +48 -0
- package/dist/shared/{fiber.DAg-9ieU.d.ts → fiber.Bkpap4yF.d.mts} +124 -101
- package/dist/shared/{fiber.Ddgoyqql.d.mts → fiber.BnIfHyTk.d.cts} +124 -101
- package/dist/shared/{fiber.Bw8YnGg5.d.cts → fiber.CLTHZhZp.d.cts} +109 -4
- package/dist/shared/{fiber.Bw8YnGg5.d.mts → fiber.CLTHZhZp.d.mts} +109 -4
- package/dist/shared/{fiber.Bw8YnGg5.d.ts → fiber.CLTHZhZp.d.ts} +109 -4
- package/dist/shared/fiber.CTEAJNmg.d.ts +48 -0
- package/dist/shared/{fiber.D9zziEOb.mjs → fiber.CUKAa7Rv.mjs} +28 -1
- package/dist/shared/fiber.CksZuiOV.d.mts +48 -0
- package/dist/shared/{fiber.COTqIf4o.mjs → fiber.Dl_2kSXg.mjs} +6379 -5238
- package/dist/shared/{fiber.DiPB625B.d.cts → fiber.NwhGYEh-.d.ts} +124 -101
- package/dist/shared/{fiber.D9dtW9DT.cjs → fiber.khFlPHPf.cjs} +30 -0
- package/dist/shared/{fiber.COk97oyZ.cjs → fiber.nPYZB2AE.cjs} +6388 -5247
- package/dist/webgpu/index.cjs +2 -2
- package/dist/webgpu/index.d.cts +4 -5
- package/dist/webgpu/index.d.mts +4 -5
- package/dist/webgpu/index.d.ts +4 -5
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +6 -6
- package/readme.md +1 -1
|
@@ -2,10 +2,9 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
3
3
|
import { Options } from 'react-use-measure';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
|
|
6
|
+
import { K as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, $ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, z as Args, l as EventHandlers, G as InstanceProps, k as DomEvent, H as Instance, y as Catalogue, w as Root, a7 as ThreeCore, Y as Bridge, _ as UnblockProps, a1 as Disposable, U as ThreeCamera, a0 as EquConfig } from './fiber.CLTHZhZp.cjs';
|
|
7
7
|
import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
|
|
8
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
8
|
|
|
10
9
|
//* Base Renderer Types =====================================
|
|
11
10
|
|
|
@@ -156,8 +155,11 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
156
155
|
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
157
156
|
size?: Size
|
|
158
157
|
/**
|
|
159
|
-
* Enables shadows (
|
|
160
|
-
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
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.
|
|
161
163
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
162
164
|
*/
|
|
163
165
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
|
|
@@ -235,83 +237,6 @@ type InjectState = Partial<
|
|
|
235
237
|
}
|
|
236
238
|
>
|
|
237
239
|
|
|
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
|
-
}
|
|
314
|
-
|
|
315
240
|
//* Loop Types ==============================
|
|
316
241
|
|
|
317
242
|
type GlobalRenderCallback = (timestamp: number) => void
|
|
@@ -618,8 +543,14 @@ type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
|
618
543
|
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
619
544
|
>
|
|
620
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
|
+
*/
|
|
621
552
|
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
622
|
-
[K in keyof T & string as
|
|
553
|
+
[K in keyof T & string as T[K] extends ConstructorRepresentation ? Uncapitalize<K> : never]: ThreeElement<T[K]>
|
|
623
554
|
}
|
|
624
555
|
|
|
625
556
|
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
@@ -875,7 +806,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
875
806
|
* </EnvironmentPortal>
|
|
876
807
|
* ```
|
|
877
808
|
*/
|
|
878
|
-
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps):
|
|
809
|
+
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
810
|
/**
|
|
880
811
|
* Sets up a global environment map for PBR materials and backgrounds.
|
|
881
812
|
* Affects scene.environment and optionally scene.background unless a custom scene is passed.
|
|
@@ -971,7 +902,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
|
|
|
971
902
|
* />
|
|
972
903
|
* ```
|
|
973
904
|
*/
|
|
974
|
-
declare function Environment(props: EnvironmentProps):
|
|
905
|
+
declare function Environment(props: EnvironmentProps): React$1.JSX.Element;
|
|
975
906
|
|
|
976
907
|
/**
|
|
977
908
|
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
@@ -1089,7 +1020,7 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
1089
1020
|
input: Parameters<typeof useTexture>[0];
|
|
1090
1021
|
onLoad?: Parameters<typeof useTexture>[1];
|
|
1091
1022
|
cache?: boolean;
|
|
1092
|
-
}) =>
|
|
1023
|
+
}) => React$1.JSX.Element;
|
|
1093
1024
|
|
|
1094
1025
|
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1095
1026
|
type TextureInput = string | string[] | Record<string, string>;
|
|
@@ -1876,7 +1807,8 @@ declare namespace ReactReconciler {
|
|
|
1876
1807
|
type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
|
|
1877
1808
|
|
|
1878
1809
|
type Lanes = number;
|
|
1879
|
-
|
|
1810
|
+
|
|
1811
|
+
type Lane = number & { __LaneBrand: any };
|
|
1880
1812
|
|
|
1881
1813
|
type Flags = number;
|
|
1882
1814
|
|
|
@@ -2207,7 +2139,6 @@ declare namespace ReactReconciler {
|
|
|
2207
2139
|
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
2208
2140
|
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
2209
2141
|
onDefaultTransitionIndicator: () => void,
|
|
2210
|
-
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
2211
2142
|
): OpaqueRoot;
|
|
2212
2143
|
|
|
2213
2144
|
createPortal(
|
|
@@ -2217,8 +2148,6 @@ declare namespace ReactReconciler {
|
|
|
2217
2148
|
key?: string | null,
|
|
2218
2149
|
): ReactPortal;
|
|
2219
2150
|
|
|
2220
|
-
registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
|
|
2221
|
-
|
|
2222
2151
|
createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
|
|
2223
2152
|
|
|
2224
2153
|
createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
|
|
@@ -2253,8 +2182,12 @@ declare namespace ReactReconciler {
|
|
|
2253
2182
|
isStrictMode: boolean,
|
|
2254
2183
|
concurrentUpdatesByDefaultOverride: null | boolean,
|
|
2255
2184
|
identifierPrefix: string,
|
|
2256
|
-
|
|
2185
|
+
onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
|
|
2186
|
+
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
2187
|
+
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
2188
|
+
onDefaultTransitionIndicator: () => void,
|
|
2257
2189
|
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
2190
|
+
formState: unknown,
|
|
2258
2191
|
): OpaqueRoot;
|
|
2259
2192
|
|
|
2260
2193
|
updateContainer(
|
|
@@ -2264,17 +2197,27 @@ declare namespace ReactReconciler {
|
|
|
2264
2197
|
callback?: (() => void) | null,
|
|
2265
2198
|
): Lane;
|
|
2266
2199
|
|
|
2200
|
+
updateContainerSync(
|
|
2201
|
+
element: ReactNode,
|
|
2202
|
+
container: OpaqueRoot,
|
|
2203
|
+
parentComponent?: Component<any, any> | null,
|
|
2204
|
+
callback?: (() => void) | null,
|
|
2205
|
+
): Lane;
|
|
2206
|
+
|
|
2267
2207
|
batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
|
|
2268
2208
|
|
|
2269
2209
|
deferredUpdates<A>(fn: () => A): A;
|
|
2270
2210
|
|
|
2271
2211
|
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
2212
|
|
|
2273
|
-
flushControlled(fn: () => any): void;
|
|
2274
|
-
|
|
2275
2213
|
flushSync(): void;
|
|
2276
2214
|
flushSync<R>(fn: () => R): R;
|
|
2277
2215
|
|
|
2216
|
+
flushSyncFromReconciler(): void;
|
|
2217
|
+
flushSyncFromReconciler<R>(fn: () => R): R;
|
|
2218
|
+
|
|
2219
|
+
flushSyncWork(): boolean;
|
|
2220
|
+
|
|
2278
2221
|
isAlreadyRendering(): boolean;
|
|
2279
2222
|
|
|
2280
2223
|
flushPassiveEffects(): boolean;
|
|
@@ -2283,16 +2226,10 @@ declare namespace ReactReconciler {
|
|
|
2283
2226
|
|
|
2284
2227
|
attemptSynchronousHydration(fiber: Fiber): void;
|
|
2285
2228
|
|
|
2286
|
-
attemptDiscreteHydration(fiber: Fiber): void;
|
|
2287
|
-
|
|
2288
2229
|
attemptContinuousHydration(fiber: Fiber): void;
|
|
2289
2230
|
|
|
2290
2231
|
attemptHydrationAtCurrentPriority(fiber: Fiber): void;
|
|
2291
2232
|
|
|
2292
|
-
getCurrentUpdatePriority(): LanePriority;
|
|
2293
|
-
|
|
2294
|
-
runWithPriority<T>(priority: LanePriority, fn: () => T): T;
|
|
2295
|
-
|
|
2296
2233
|
findHostInstance(component: any): PublicInstance | null;
|
|
2297
2234
|
|
|
2298
2235
|
findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
|
|
@@ -2305,18 +2242,80 @@ declare namespace ReactReconciler {
|
|
|
2305
2242
|
|
|
2306
2243
|
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
|
|
2307
2244
|
}
|
|
2245
|
+
|
|
2246
|
+
function defaultOnUncaughtError(error: Error): void;
|
|
2247
|
+
function defaultOnCaughtError(error: Error): void;
|
|
2248
|
+
function defaultOnRecoverableError(error: Error): void;
|
|
2249
|
+
|
|
2250
|
+
function startHostTransition(
|
|
2251
|
+
formFiber: Fiber,
|
|
2252
|
+
pendingState: unknown,
|
|
2253
|
+
action: ((formData: FormData) => void) | null,
|
|
2254
|
+
formData: FormData,
|
|
2255
|
+
): void;
|
|
2308
2256
|
}
|
|
2309
2257
|
|
|
2258
|
+
/**
|
|
2259
|
+
* Registers constructors so they can be rendered as JSX elements.
|
|
2260
|
+
*
|
|
2261
|
+
* - `extend({ OrbitControls })` makes each constructor available under its camelCased key
|
|
2262
|
+
* (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
|
|
2263
|
+
* namespace can be passed.
|
|
2264
|
+
* - `extend(MyClass)` registers one constructor and returns a component to render it with.
|
|
2265
|
+
*
|
|
2266
|
+
* Registrations are global, shared by every copy and entry of fiber, and are checked before the
|
|
2267
|
+
* three namespace of a root's renderer when an element name is resolved.
|
|
2268
|
+
*
|
|
2269
|
+
* @example
|
|
2270
|
+
* import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
|
|
2271
|
+
* extend({ OrbitControls })
|
|
2272
|
+
* // <orbitControls args={[camera, gl.domElement]} />
|
|
2273
|
+
*
|
|
2274
|
+
* @example
|
|
2275
|
+
* const Controls = extend(OrbitControls)
|
|
2276
|
+
* // <Controls args={[camera, gl.domElement]} />
|
|
2277
|
+
*
|
|
2278
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
|
|
2279
|
+
*/
|
|
2310
2280
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
2281
|
+
/** Registers each constructor in `objects` under its key; see the first overload. */
|
|
2311
2282
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
2283
|
+
/** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
|
|
2312
2284
|
declare function extend(objects: Record<string, unknown>): void;
|
|
2313
2285
|
|
|
2286
|
+
/**
|
|
2287
|
+
* R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
|
|
2288
|
+
* Each root's {@link RootStore} is its container, and children attach to `internal.container`
|
|
2289
|
+
* (a portal's target) or else the root's `scene`.
|
|
2290
|
+
*
|
|
2291
|
+
* - **Element names** resolve through `extend()` registrations first, then the three namespace of
|
|
2292
|
+
* the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
|
|
2293
|
+
* prefixed name exists. `<primitive object={...}>` wraps an existing object.
|
|
2294
|
+
* - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
|
|
2295
|
+
* Suspense discards never creates three objects.
|
|
2296
|
+
* - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
|
|
2297
|
+
* the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
|
|
2298
|
+
* already point to the new object.
|
|
2299
|
+
* - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
|
|
2300
|
+
* test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
|
|
2301
|
+
* - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
|
|
2302
|
+
* follows react-dom's event priorities. View-transition commits are flushed synchronously, since
|
|
2303
|
+
* three has nothing to animate between commits.
|
|
2304
|
+
*
|
|
2305
|
+
* `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
|
|
2306
|
+
*/
|
|
2314
2307
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
2315
2308
|
|
|
2316
2309
|
declare const isRenderer: (def: any) => boolean;
|
|
2317
2310
|
interface OffscreenCanvas extends EventTarget {
|
|
2318
2311
|
}
|
|
2319
2312
|
declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
|
|
2315
|
+
* for a renderer that is still being created. `callback` runs when the root is gone: after the
|
|
2316
|
+
* teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
|
|
2317
|
+
* from three r186), after that dispose has settled.
|
|
2318
|
+
*/
|
|
2320
2319
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
2321
2320
|
declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
|
|
2322
2321
|
interface PortalProps {
|
|
@@ -2333,6 +2332,30 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
2333
2332
|
*/
|
|
2334
2333
|
declare function flushSync<R>(fn: () => R): R;
|
|
2335
2334
|
|
|
2335
|
+
/**
|
|
2336
|
+
* Creates the Zustand store that holds one root's {@link RootState}.
|
|
2337
|
+
*
|
|
2338
|
+
* The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
|
|
2339
|
+
* are `null` placeholders until the root's renderer support has loaded and `configure()` in
|
|
2340
|
+
* `renderer.tsx` fills them in. Only core's part of `RootState` is created here; packages building on
|
|
2341
|
+
* fiber add their own fields through root extensions.
|
|
2342
|
+
*
|
|
2343
|
+
* Besides the initial state, the store wires up:
|
|
2344
|
+
* - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
|
|
2345
|
+
* deprecation when user code reads it outside legacy mode.
|
|
2346
|
+
* - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
|
|
2347
|
+
* - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
|
|
2348
|
+
* renderer when there is none).
|
|
2349
|
+
* - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
|
|
2350
|
+
* (when `autoUpdateFrustum` is set) the frustum.
|
|
2351
|
+
* - Calling `invalidate(state)` after every state change.
|
|
2352
|
+
*
|
|
2353
|
+
* `createRoot` calls this once per canvas.
|
|
2354
|
+
*
|
|
2355
|
+
* @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
|
|
2356
|
+
* @param advance - Steps a root manually. Bound into `state.advance`.
|
|
2357
|
+
* @returns The root's store, which is also the reconciler container for that root.
|
|
2358
|
+
*/
|
|
2336
2359
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
2337
2360
|
|
|
2338
2361
|
/** Whether any root has loaded a renderer yet. */
|
|
@@ -2848,5 +2871,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
2848
2871
|
[ONCE]: any[] | true;
|
|
2849
2872
|
};
|
|
2850
2873
|
|
|
2851
|
-
export {
|
|
2852
|
-
export type {
|
|
2874
|
+
export { REACT_INTERNAL_PROPS as a$, Texture as aA, useTextures as aF, useEnvironment as aH, addEffect as aI, addAfterEffect as aJ, addTail as aK, invalidate as aL, advance as aM, extend as aN, reconciler as aO, isRenderer as aP, _roots as aQ, unmountComponentAtNode as aR, createPortal as aS, Portal as aT, flushSync as aU, createStore as aV, useIsomorphicLayoutEffect as aW, useMutableCallback as aX, useBridge as aY, Block as aZ, ErrorBoundary as a_, registerPrimary as ad, getPrimary as ae, waitForPrimary as af, hasPrimary as ag, unregisterPrimary as ah, getPrimaryIds as ai, EnvironmentMap as ak, EnvironmentCube as al, EnvironmentPortal as am, Environment as an, presetsObj as ao, swapInteractivity as aq, removeInteractivity as ar, createEvents as as, useInstanceHandle as at, useGraph as au, useLoader as av, IsObject as aw, useTexture as az, findInitialRoot as b0, getRootState as b1, buildGraph as b2, dispose as b3, getInstanceProps as b4, prepare as b5, invalidateInstance as b6, RESERVED_PROPS as b7, resolve as b8, attach as b9, detach as ba, diffProps as bb, applyProps as bc, calculateDpr as bd, getUuidPrefix as be, updateCamera as bf, updateFrustum as bg, is as bh, isOrthographicCamera as bi, isRef as bj, isColorRepresentation as bk, isObject3D as bl, isTexture as bm, isLayers as bn, isUniform as bo, isVectorLike as bp, isCopyable as bq, hasConstructor as br, FROM_REF as bs, fromRef as bu, isFromRef as bv, ONCE as bw, once as bx, isOnce as bz, createPointerEvents as u, getThree as v, hasThree as w, whenThree as x };
|
|
2875
|
+
export type { InputLike as $, Renderer as A, BaseRendererProps as B, Color as C, ColorManagementConfig as D, Euler as E, DefaultGLProps as F, GeometryTransformProps as G, GLProps as H, DefaultRendererProps as I, CanvasSchedulerConfig as J, RendererConfigExtended as K, Layers as L, MutableOrReadonlyParameters as M, NodeProps as N, Object3DMethod as O, RendererProps as P, Quaternion as Q, RaycastableRepresentation as R, CameraProps as S, TSLNodeInput as T, RenderProps as U, VectorRepresentation as V, InjectState as W, GlobalRenderCallback as X, GlobalEffectType as Y, BackgroundConfig as Z, BackgroundProp as _, MathRepresentation as a, LoaderLike as a0, GLTFLike as a1, LoaderInstance as a2, InferLoadResult as a3, LoaderResult as a4, Extensions as a5, WebGLDefaultProps as a6, WebGLProps as a7, WebGLShadowConfig as a8, LegacyRenderer as a9, TextureInput as aB, TextureResult as aC, DisposeOptions as aD, UseTexturesReturn as aE, EnvironmentLoaderProps as aG, LegacyInternalState as aa, LegacyRootState as ab, PrimaryCanvasEntry as ac, EnvironmentProps as aj, PresetsType as ap, MappedTextureType as ax, UseTextureOptions as ay, MathTypes as b, FromRefMarker as bt, OnceValue as by, MathType as c, MathProps as d, Vector2 as e, Vector3 as f, Vector4 as g, Matrix3 as h, Matrix4 as i, EventProps as j, GeometryProps as k, ReactProps as l, ElementProps as m, ThreeElement as n, ThreeToJSXElements as o, ThreeElementsOf as p, ElementOf as q, RenderTargetOptions as r, ReconcilerRoot as s, CanvasProps as t, OffscreenCanvas$1 as y, RendererFactory as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi } from '@pmndrs/scheduler';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import * as THREE from 'three';
|
|
4
|
-
import { WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
3
|
+
import { WebGLRenderer, WebGLRenderTarget, Color, ColorRepresentation } from 'three';
|
|
4
|
+
import * as React from 'react';
|
|
5
5
|
import * as ThreeWebGPU from 'three/webgpu';
|
|
6
6
|
import { WebGPURenderer, RenderTarget, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
@@ -477,6 +477,11 @@ interface InternalState {
|
|
|
477
477
|
* Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
|
|
478
478
|
*/
|
|
479
479
|
support: R3FRendererSupport
|
|
480
|
+
/**
|
|
481
|
+
* Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
|
|
482
|
+
* a renderer passed in as an instance is never disposed by R3F.
|
|
483
|
+
*/
|
|
484
|
+
releaseRenderer?: () => void | Promise<void>
|
|
480
485
|
/** Global scheduler reference (for useFrame hook) */
|
|
481
486
|
scheduler: SchedulerApi | null
|
|
482
487
|
/**
|
|
@@ -489,6 +494,8 @@ interface InternalState {
|
|
|
489
494
|
rootId?: string
|
|
490
495
|
/** Function to unregister this root from the global scheduler */
|
|
491
496
|
unregisterRoot?: () => void
|
|
497
|
+
/** Function to stop following devicePixelRatio changes */
|
|
498
|
+
unwatchDpr?: () => void
|
|
492
499
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
500
|
container?: THREE.Object3D
|
|
494
501
|
/**
|
|
@@ -530,6 +537,12 @@ interface InternalState {
|
|
|
530
537
|
* Only set when isSecondary is true.
|
|
531
538
|
*/
|
|
532
539
|
targetId?: string
|
|
540
|
+
/**
|
|
541
|
+
* This secondary stopped sharing because the primary's renderer fell back to its
|
|
542
|
+
* WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
|
|
543
|
+
* `isSecondary` (which marks a canvas borrowing another's renderer).
|
|
544
|
+
*/
|
|
545
|
+
sharedRendererFallback?: boolean
|
|
533
546
|
/**
|
|
534
547
|
* Function to unregister this primary canvas from the registry.
|
|
535
548
|
* Only set when this canvas has an `id` prop.
|
|
@@ -654,6 +667,91 @@ interface RootState {
|
|
|
654
667
|
|
|
655
668
|
type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
|
|
656
669
|
|
|
670
|
+
//* Reconciler Types ==============================
|
|
671
|
+
|
|
672
|
+
// FiberRoot is an opaque internal React type - we define it locally
|
|
673
|
+
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
674
|
+
type FiberRoot = any
|
|
675
|
+
|
|
676
|
+
/** A promise tagged with its state, the protocol React's `use` reads */
|
|
677
|
+
type TrackedPromise<T> = Promise<T> &
|
|
678
|
+
({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
|
|
679
|
+
|
|
680
|
+
interface Root {
|
|
681
|
+
fiber: FiberRoot
|
|
682
|
+
store: RootStore
|
|
683
|
+
/** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
|
|
684
|
+
unmountClaim: symbol | null
|
|
685
|
+
/** Pending only while a renderer is being created */
|
|
686
|
+
ready: TrackedPromise<unknown>
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
690
|
+
type AttachType<O = any> = string | AttachFnType<O>
|
|
691
|
+
|
|
692
|
+
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
693
|
+
|
|
694
|
+
interface Catalogue {
|
|
695
|
+
[name: string]: ConstructorRepresentation
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// TODO: handle constructor overloads
|
|
699
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
700
|
+
// https://github.com/microsoft/TypeScript/issues/37079
|
|
701
|
+
type Args<T> = T extends ConstructorRepresentation
|
|
702
|
+
? T extends typeof Color
|
|
703
|
+
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
704
|
+
: ConstructorParameters<T>
|
|
705
|
+
: any[]
|
|
706
|
+
|
|
707
|
+
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
708
|
+
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
709
|
+
? { args?: Args<P> }
|
|
710
|
+
: { args: Args<P> }
|
|
711
|
+
: { args: unknown[] }
|
|
712
|
+
|
|
713
|
+
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
714
|
+
object?: T
|
|
715
|
+
dispose?: null
|
|
716
|
+
attach?: AttachType<T>
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface Instance<O = any> {
|
|
720
|
+
root: RootStore
|
|
721
|
+
type: string
|
|
722
|
+
parent: Instance | null
|
|
723
|
+
children: Instance[]
|
|
724
|
+
props: InstanceProps<O> & Record<string, unknown>
|
|
725
|
+
object: O & { __r3f?: Instance<O> }
|
|
726
|
+
eventCount: number
|
|
727
|
+
handlers: Partial<EventHandlers>
|
|
728
|
+
attach?: AttachType<O>
|
|
729
|
+
previousAttach?: any
|
|
730
|
+
isHidden: boolean
|
|
731
|
+
/** Set of props that have been applied via once() */
|
|
732
|
+
appliedOnce?: Set<string>
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
interface HostConfig {
|
|
736
|
+
type: string
|
|
737
|
+
props: Instance['props']
|
|
738
|
+
container: RootStore
|
|
739
|
+
instance: Instance
|
|
740
|
+
textInstance: void
|
|
741
|
+
suspenseInstance: Instance
|
|
742
|
+
hydratableInstance: never
|
|
743
|
+
formInstance: never
|
|
744
|
+
publicInstance: Instance['object']
|
|
745
|
+
hostContext: {}
|
|
746
|
+
childSet: never
|
|
747
|
+
timeoutHandle: number | undefined
|
|
748
|
+
noTimeout: -1
|
|
749
|
+
TransitionStatus: null
|
|
750
|
+
}
|
|
751
|
+
declare global {
|
|
752
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
753
|
+
}
|
|
754
|
+
|
|
657
755
|
interface RootExtension {
|
|
658
756
|
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
659
757
|
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
@@ -695,7 +793,14 @@ declare function useStore(): RootStore;
|
|
|
695
793
|
*/
|
|
696
794
|
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
697
795
|
|
|
796
|
+
/**
|
|
797
|
+
* React context that carries the current root's {@link RootStore}. Each root provides its store and
|
|
798
|
+
* each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
|
|
799
|
+
*
|
|
800
|
+
* Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
|
|
801
|
+
* of fiber shares a single context.
|
|
802
|
+
*/
|
|
698
803
|
declare const context: React.Context<RootStore>;
|
|
699
804
|
|
|
700
|
-
export { useStore as
|
|
701
|
-
export type {
|
|
805
|
+
export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
|
|
806
|
+
export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
|