@react-three/fiber 9.6.1 → 9.8.0
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/CHANGELOG.md +1241 -1204
- package/dist/declarations/react-reconciler/index.d.ts +30 -13
- package/dist/declarations/src/core/events.d.ts +94 -94
- package/dist/declarations/src/core/hooks.d.ts +53 -53
- package/dist/declarations/src/core/index.d.ts +14 -13
- package/dist/declarations/src/core/loop.d.ts +31 -31
- package/dist/declarations/src/core/promise.d.ts +15 -0
- package/dist/declarations/src/core/reconciler.d.ts +54 -50
- package/dist/declarations/src/core/renderer.d.ts +91 -89
- package/dist/declarations/src/core/store.d.ts +130 -130
- package/dist/declarations/src/core/utils.d.ts +265 -262
- package/dist/declarations/src/index.d.ts +6 -6
- package/dist/declarations/src/native/Canvas.d.ts +13 -13
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native.d.ts +6 -6
- package/dist/declarations/src/three-types.d.ts +68 -68
- package/dist/declarations/src/web/Canvas.d.ts +23 -23
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/events-803f4abc.esm.js +17563 -0
- package/dist/{events-583399dd.cjs.prod.js → events-a79ef12b.cjs.prod.js} +3558 -2807
- package/dist/{events-f19bcc32.cjs.dev.js → events-ce5e34e8.cjs.dev.js} +7985 -6652
- package/dist/react-three-fiber.cjs.dev.js +61 -43
- package/dist/react-three-fiber.cjs.prod.js +61 -43
- package/dist/react-three-fiber.esm.js +63 -45
- package/native/dist/react-three-fiber-native.cjs.dev.js +49 -43
- package/native/dist/react-three-fiber-native.cjs.prod.js +49 -43
- package/native/dist/react-three-fiber-native.esm.js +50 -44
- package/native/package.json +5 -5
- package/package.json +6 -6
- package/react-reconciler/index.d.ts +30 -13
- package/react-reconciler/index.js +79 -77
- package/readme.md +253 -253
- package/dist/events-b389eeca.esm.js +0 -16231
|
@@ -610,7 +610,8 @@ declare namespace ReactReconciler {
|
|
|
610
610
|
type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
|
|
611
611
|
|
|
612
612
|
type Lanes = number;
|
|
613
|
-
|
|
613
|
+
|
|
614
|
+
type Lane = number & { __LaneBrand: any };
|
|
614
615
|
|
|
615
616
|
type Flags = number;
|
|
616
617
|
|
|
@@ -941,7 +942,6 @@ declare namespace ReactReconciler {
|
|
|
941
942
|
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
942
943
|
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
943
944
|
onDefaultTransitionIndicator: () => void,
|
|
944
|
-
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
945
945
|
): OpaqueRoot;
|
|
946
946
|
|
|
947
947
|
createPortal(
|
|
@@ -951,8 +951,6 @@ declare namespace ReactReconciler {
|
|
|
951
951
|
key?: string | null,
|
|
952
952
|
): ReactPortal;
|
|
953
953
|
|
|
954
|
-
registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
|
|
955
|
-
|
|
956
954
|
createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
|
|
957
955
|
|
|
958
956
|
createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
|
|
@@ -987,8 +985,12 @@ declare namespace ReactReconciler {
|
|
|
987
985
|
isStrictMode: boolean,
|
|
988
986
|
concurrentUpdatesByDefaultOverride: null | boolean,
|
|
989
987
|
identifierPrefix: string,
|
|
990
|
-
|
|
988
|
+
onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
|
|
989
|
+
onCaughtError: (error: Error, info: BaseErrorInfo) => void,
|
|
990
|
+
onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
|
|
991
|
+
onDefaultTransitionIndicator: () => void,
|
|
991
992
|
transitionCallbacks: null | TransitionTracingCallbacks,
|
|
993
|
+
formState: unknown,
|
|
992
994
|
): OpaqueRoot;
|
|
993
995
|
|
|
994
996
|
updateContainer(
|
|
@@ -998,17 +1000,27 @@ declare namespace ReactReconciler {
|
|
|
998
1000
|
callback?: (() => void) | null,
|
|
999
1001
|
): Lane;
|
|
1000
1002
|
|
|
1003
|
+
updateContainerSync(
|
|
1004
|
+
element: ReactNode,
|
|
1005
|
+
container: OpaqueRoot,
|
|
1006
|
+
parentComponent?: Component<any, any> | null,
|
|
1007
|
+
callback?: (() => void) | null,
|
|
1008
|
+
): Lane;
|
|
1009
|
+
|
|
1001
1010
|
batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
|
|
1002
1011
|
|
|
1003
1012
|
deferredUpdates<A>(fn: () => A): A;
|
|
1004
1013
|
|
|
1005
1014
|
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;
|
|
1006
1015
|
|
|
1007
|
-
flushControlled(fn: () => any): void;
|
|
1008
|
-
|
|
1009
1016
|
flushSync(): void;
|
|
1010
1017
|
flushSync<R>(fn: () => R): R;
|
|
1011
1018
|
|
|
1019
|
+
flushSyncFromReconciler(): void;
|
|
1020
|
+
flushSyncFromReconciler<R>(fn: () => R): R;
|
|
1021
|
+
|
|
1022
|
+
flushSyncWork(): boolean;
|
|
1023
|
+
|
|
1012
1024
|
isAlreadyRendering(): boolean;
|
|
1013
1025
|
|
|
1014
1026
|
flushPassiveEffects(): boolean;
|
|
@@ -1017,16 +1029,10 @@ declare namespace ReactReconciler {
|
|
|
1017
1029
|
|
|
1018
1030
|
attemptSynchronousHydration(fiber: Fiber): void;
|
|
1019
1031
|
|
|
1020
|
-
attemptDiscreteHydration(fiber: Fiber): void;
|
|
1021
|
-
|
|
1022
1032
|
attemptContinuousHydration(fiber: Fiber): void;
|
|
1023
1033
|
|
|
1024
1034
|
attemptHydrationAtCurrentPriority(fiber: Fiber): void;
|
|
1025
1035
|
|
|
1026
|
-
getCurrentUpdatePriority(): LanePriority;
|
|
1027
|
-
|
|
1028
|
-
runWithPriority<T>(priority: LanePriority, fn: () => T): T;
|
|
1029
|
-
|
|
1030
1036
|
findHostInstance(component: any): PublicInstance | null;
|
|
1031
1037
|
|
|
1032
1038
|
findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
|
|
@@ -1039,6 +1045,17 @@ declare namespace ReactReconciler {
|
|
|
1039
1045
|
|
|
1040
1046
|
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
|
|
1041
1047
|
}
|
|
1048
|
+
|
|
1049
|
+
function defaultOnUncaughtError(error: Error): void;
|
|
1050
|
+
function defaultOnCaughtError(error: Error): void;
|
|
1051
|
+
function defaultOnRecoverableError(error: Error): void;
|
|
1052
|
+
|
|
1053
|
+
function startHostTransition(
|
|
1054
|
+
formFiber: Fiber,
|
|
1055
|
+
pendingState: unknown,
|
|
1056
|
+
action: ((formData: FormData) => void) | null,
|
|
1057
|
+
formData: FormData,
|
|
1058
|
+
): void;
|
|
1042
1059
|
}
|
|
1043
1060
|
|
|
1044
1061
|
export = ReactReconciler;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { type Properties } from "./utils.js";
|
|
3
|
-
import type { RootState, RootStore } from "./store.js";
|
|
4
|
-
export interface Intersection extends THREE.Intersection {
|
|
5
|
-
/** The event source (the object which registered the handler) */
|
|
6
|
-
eventObject: THREE.Object3D;
|
|
7
|
-
}
|
|
8
|
-
export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
9
|
-
/** The event source (the object which registered the handler) */
|
|
10
|
-
eventObject: THREE.Object3D;
|
|
11
|
-
/** An array of intersections */
|
|
12
|
-
intersections: Intersection[];
|
|
13
|
-
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
14
|
-
unprojectedPoint: THREE.Vector3;
|
|
15
|
-
/** Normalized event coordinates */
|
|
16
|
-
pointer: THREE.Vector2;
|
|
17
|
-
/** Delta between first click and this event */
|
|
18
|
-
delta: number;
|
|
19
|
-
/** The ray that pierced it */
|
|
20
|
-
ray: THREE.Ray;
|
|
21
|
-
/** The camera that was used by the raycaster */
|
|
22
|
-
camera: Camera;
|
|
23
|
-
/** stopPropagation will stop underlying handlers from firing */
|
|
24
|
-
stopPropagation: () => void;
|
|
25
|
-
/** The original host event */
|
|
26
|
-
nativeEvent: TSourceEvent;
|
|
27
|
-
/** If the event was stopped by calling stopPropagation */
|
|
28
|
-
stopped: boolean;
|
|
29
|
-
}
|
|
30
|
-
export type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
31
|
-
export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
|
|
32
|
-
export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
33
|
-
export interface Events {
|
|
34
|
-
onClick: EventListener;
|
|
35
|
-
onContextMenu: EventListener;
|
|
36
|
-
onDoubleClick: EventListener;
|
|
37
|
-
onWheel: EventListener;
|
|
38
|
-
onPointerDown: EventListener;
|
|
39
|
-
onPointerUp: EventListener;
|
|
40
|
-
onPointerLeave: EventListener;
|
|
41
|
-
onPointerMove: EventListener;
|
|
42
|
-
onPointerCancel: EventListener;
|
|
43
|
-
onLostPointerCapture: EventListener;
|
|
44
|
-
}
|
|
45
|
-
export interface EventHandlers {
|
|
46
|
-
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
47
|
-
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
48
|
-
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
49
|
-
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
50
|
-
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
51
|
-
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
52
|
-
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
53
|
-
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
54
|
-
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
55
|
-
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
56
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
57
|
-
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
58
|
-
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
59
|
-
onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void;
|
|
60
|
-
}
|
|
61
|
-
export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
62
|
-
export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
63
|
-
export interface EventManager<TTarget> {
|
|
64
|
-
/** Determines if the event layer is active */
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
|
|
67
|
-
priority: number;
|
|
68
|
-
/** The compute function needs to set up the raycaster and an xy- pointer */
|
|
69
|
-
compute?: ComputeFunction;
|
|
70
|
-
/** The filter can re-order or re-structure the intersections */
|
|
71
|
-
filter?: FilterFunction;
|
|
72
|
-
/** The target node the event layer is tied to */
|
|
73
|
-
connected?: TTarget;
|
|
74
|
-
/** All the pointer event handlers through which the host forwards native events */
|
|
75
|
-
handlers?: Events;
|
|
76
|
-
/** Allows re-connecting to another target */
|
|
77
|
-
connect?: (target: TTarget) => void;
|
|
78
|
-
/** Removes all existing events handlers from the target */
|
|
79
|
-
disconnect?: () => void;
|
|
80
|
-
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
81
|
-
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
82
|
-
*/
|
|
83
|
-
update?: () => void;
|
|
84
|
-
}
|
|
85
|
-
export interface PointerCaptureTarget {
|
|
86
|
-
intersection: Intersection;
|
|
87
|
-
target: Element;
|
|
88
|
-
}
|
|
89
|
-
/** This function transfers all interactivity state from one object instance to another. Used when swapping instances due to reconstruction. */
|
|
90
|
-
export declare function swapInteractivity(store: RootStore, object: THREE.Object3D, newObject: THREE.Object3D): void;
|
|
91
|
-
export declare function removeInteractivity(store: RootStore, object: THREE.Object3D): void;
|
|
92
|
-
export declare function createEvents(store: RootStore): {
|
|
93
|
-
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
94
|
-
};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { type Properties } from "./utils.js";
|
|
3
|
+
import type { RootState, RootStore } from "./store.js";
|
|
4
|
+
export interface Intersection extends THREE.Intersection {
|
|
5
|
+
/** The event source (the object which registered the handler) */
|
|
6
|
+
eventObject: THREE.Object3D;
|
|
7
|
+
}
|
|
8
|
+
export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
9
|
+
/** The event source (the object which registered the handler) */
|
|
10
|
+
eventObject: THREE.Object3D;
|
|
11
|
+
/** An array of intersections */
|
|
12
|
+
intersections: Intersection[];
|
|
13
|
+
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
14
|
+
unprojectedPoint: THREE.Vector3;
|
|
15
|
+
/** Normalized event coordinates */
|
|
16
|
+
pointer: THREE.Vector2;
|
|
17
|
+
/** Delta between first click and this event */
|
|
18
|
+
delta: number;
|
|
19
|
+
/** The ray that pierced it */
|
|
20
|
+
ray: THREE.Ray;
|
|
21
|
+
/** The camera that was used by the raycaster */
|
|
22
|
+
camera: Camera;
|
|
23
|
+
/** stopPropagation will stop underlying handlers from firing */
|
|
24
|
+
stopPropagation: () => void;
|
|
25
|
+
/** The original host event */
|
|
26
|
+
nativeEvent: TSourceEvent;
|
|
27
|
+
/** If the event was stopped by calling stopPropagation */
|
|
28
|
+
stopped: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
31
|
+
export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
|
|
32
|
+
export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
33
|
+
export interface Events {
|
|
34
|
+
onClick: EventListener;
|
|
35
|
+
onContextMenu: EventListener;
|
|
36
|
+
onDoubleClick: EventListener;
|
|
37
|
+
onWheel: EventListener;
|
|
38
|
+
onPointerDown: EventListener;
|
|
39
|
+
onPointerUp: EventListener;
|
|
40
|
+
onPointerLeave: EventListener;
|
|
41
|
+
onPointerMove: EventListener;
|
|
42
|
+
onPointerCancel: EventListener;
|
|
43
|
+
onLostPointerCapture: EventListener;
|
|
44
|
+
}
|
|
45
|
+
export interface EventHandlers {
|
|
46
|
+
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
47
|
+
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
48
|
+
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
49
|
+
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
50
|
+
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
51
|
+
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
52
|
+
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
53
|
+
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
54
|
+
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
55
|
+
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
56
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
57
|
+
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
58
|
+
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
59
|
+
onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void;
|
|
60
|
+
}
|
|
61
|
+
export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
62
|
+
export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
63
|
+
export interface EventManager<TTarget> {
|
|
64
|
+
/** Determines if the event layer is active */
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
|
|
67
|
+
priority: number;
|
|
68
|
+
/** The compute function needs to set up the raycaster and an xy- pointer */
|
|
69
|
+
compute?: ComputeFunction;
|
|
70
|
+
/** The filter can re-order or re-structure the intersections */
|
|
71
|
+
filter?: FilterFunction;
|
|
72
|
+
/** The target node the event layer is tied to */
|
|
73
|
+
connected?: TTarget;
|
|
74
|
+
/** All the pointer event handlers through which the host forwards native events */
|
|
75
|
+
handlers?: Events;
|
|
76
|
+
/** Allows re-connecting to another target */
|
|
77
|
+
connect?: (target: TTarget) => void;
|
|
78
|
+
/** Removes all existing events handlers from the target */
|
|
79
|
+
disconnect?: () => void;
|
|
80
|
+
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
81
|
+
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
82
|
+
*/
|
|
83
|
+
update?: () => void;
|
|
84
|
+
}
|
|
85
|
+
export interface PointerCaptureTarget {
|
|
86
|
+
intersection: Intersection;
|
|
87
|
+
target: Element;
|
|
88
|
+
}
|
|
89
|
+
/** This function transfers all interactivity state from one object instance to another. Used when swapping instances due to reconstruction. */
|
|
90
|
+
export declare function swapInteractivity(store: RootStore, object: THREE.Object3D, newObject: THREE.Object3D): void;
|
|
91
|
+
export declare function removeInteractivity(store: RootStore, object: THREE.Object3D): void;
|
|
92
|
+
export declare function createEvents(store: RootStore): {
|
|
93
|
+
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
94
|
+
};
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { RootState, RenderCallback, RootStore } from "./store.js";
|
|
4
|
-
import { ObjectMap } from "./utils.js";
|
|
5
|
-
import type { Instance, ConstructorRepresentation } from "./reconciler.js";
|
|
6
|
-
/**
|
|
7
|
-
* Exposes an object's {@link Instance}.
|
|
8
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
9
|
-
*
|
|
10
|
-
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
15
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
16
|
-
*/
|
|
17
|
-
export declare function useStore(): RootStore;
|
|
18
|
-
/**
|
|
19
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
20
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
21
|
-
*/
|
|
22
|
-
export declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
23
|
-
/**
|
|
24
|
-
* Executes a callback before render in a shared frame loop.
|
|
25
|
-
* Can order effects with render priority or manually render with a positive priority.
|
|
26
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
27
|
-
*/
|
|
28
|
-
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
29
|
-
/**
|
|
30
|
-
* Returns a node graph of an object with named nodes & materials.
|
|
31
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
32
|
-
*/
|
|
33
|
-
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
34
|
-
type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>;
|
|
35
|
-
type LoaderLike = THREE.Loader<any, InputLike>;
|
|
36
|
-
type GLTFLike = {
|
|
37
|
-
scene: THREE.Object3D;
|
|
38
|
-
};
|
|
39
|
-
type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T;
|
|
40
|
-
export type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = Awaited<ReturnType<LoaderInstance<T>['loadAsync']>> extends infer R ? R extends GLTFLike ? R & ObjectMap : R : never;
|
|
41
|
-
export type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (loader: LoaderInstance<T>) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Synchronously loads and caches assets with a three loader.
|
|
44
|
-
*
|
|
45
|
-
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
46
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
47
|
-
*/
|
|
48
|
-
export declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
49
|
-
export declare namespace useLoader {
|
|
50
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L> | undefined) => void;
|
|
51
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { RootState, RenderCallback, RootStore } from "./store.js";
|
|
4
|
+
import { ObjectMap } from "./utils.js";
|
|
5
|
+
import type { Instance, ConstructorRepresentation } from "./reconciler.js";
|
|
6
|
+
/**
|
|
7
|
+
* Exposes an object's {@link Instance}.
|
|
8
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
9
|
+
*
|
|
10
|
+
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
15
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
16
|
+
*/
|
|
17
|
+
export declare function useStore(): RootStore;
|
|
18
|
+
/**
|
|
19
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
20
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
21
|
+
*/
|
|
22
|
+
export declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
23
|
+
/**
|
|
24
|
+
* Executes a callback before render in a shared frame loop.
|
|
25
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
26
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
27
|
+
*/
|
|
28
|
+
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
31
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
32
|
+
*/
|
|
33
|
+
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
34
|
+
type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>;
|
|
35
|
+
type LoaderLike = THREE.Loader<any, InputLike>;
|
|
36
|
+
type GLTFLike = {
|
|
37
|
+
scene: THREE.Object3D;
|
|
38
|
+
};
|
|
39
|
+
type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T;
|
|
40
|
+
export type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = Awaited<ReturnType<LoaderInstance<T>['loadAsync']>> extends infer R ? R extends GLTFLike ? R & ObjectMap : R : never;
|
|
41
|
+
export type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (loader: LoaderInstance<T>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Synchronously loads and caches assets with a three loader.
|
|
44
|
+
*
|
|
45
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
46
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
47
|
+
*/
|
|
48
|
+
export declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
49
|
+
export declare namespace useLoader {
|
|
50
|
+
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L> | undefined) => void;
|
|
51
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export type { Intersection, ThreeEvent, DomEvent, Events, EventHandlers, FilterFunction, ComputeFunction, EventManager, } from "./events.js";
|
|
2
|
-
export { createEvents } from "./events.js";
|
|
3
|
-
export * from "./hooks.js";
|
|
4
|
-
export type { GlobalRenderCallback, GlobalEffectType } from "./loop.js";
|
|
5
|
-
export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from "./loop.js";
|
|
6
|
-
export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from "./reconciler.js";
|
|
7
|
-
export { extend, reconciler } from "./reconciler.js";
|
|
8
|
-
export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from "./renderer.js";
|
|
9
|
-
export { _roots, createRoot, unmountComponentAtNode, createPortal, flushSync } from "./renderer.js";
|
|
10
|
-
export type { Subscription, Dpr, Size, Viewport, RenderCallback, Frameloop, Performance, Renderer, XRManager, RootState, RootStore, } from "./store.js";
|
|
11
|
-
export { context } from "./store.js";
|
|
12
|
-
export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
|
|
13
|
-
export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
|
|
1
|
+
export type { Intersection, ThreeEvent, DomEvent, Events, EventHandlers, FilterFunction, ComputeFunction, EventManager, } from "./events.js";
|
|
2
|
+
export { createEvents } from "./events.js";
|
|
3
|
+
export * from "./hooks.js";
|
|
4
|
+
export type { GlobalRenderCallback, GlobalEffectType } from "./loop.js";
|
|
5
|
+
export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from "./loop.js";
|
|
6
|
+
export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from "./reconciler.js";
|
|
7
|
+
export { extend, reconciler } from "./reconciler.js";
|
|
8
|
+
export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from "./renderer.js";
|
|
9
|
+
export { _roots, createRoot, unmountComponentAtNode, createPortal, flushSync } from "./renderer.js";
|
|
10
|
+
export type { Subscription, Dpr, Size, Viewport, RenderCallback, Frameloop, Performance, Renderer, XRManager, RootState, RootStore, } from "./store.js";
|
|
11
|
+
export { context } from "./store.js";
|
|
12
|
+
export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
|
|
13
|
+
export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
|
|
14
|
+
export type { TrackedPromise } from "./promise.js";
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/// <reference types="webxr" />
|
|
2
|
-
import type { RootState } from "./store.js";
|
|
3
|
-
export type GlobalRenderCallback = (timestamp: number) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Adds a global render callback which is called each frame.
|
|
6
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
7
|
-
*/
|
|
8
|
-
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
9
|
-
/**
|
|
10
|
-
* Adds a global after-render callback which is called each frame.
|
|
11
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
12
|
-
*/
|
|
13
|
-
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
14
|
-
/**
|
|
15
|
-
* Adds a global callback which is called when rendering stops.
|
|
16
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
17
|
-
*/
|
|
18
|
-
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
19
|
-
export type GlobalEffectType = 'before' | 'after' | 'tail';
|
|
20
|
-
export declare function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
|
|
21
|
-
export declare function loop(timestamp: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
24
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
25
|
-
*/
|
|
26
|
-
export declare function invalidate(state?: RootState, frames?: number): void;
|
|
27
|
-
/**
|
|
28
|
-
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
29
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
30
|
-
*/
|
|
31
|
-
export declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
|
|
1
|
+
/// <reference types="webxr" />
|
|
2
|
+
import type { RootState } from "./store.js";
|
|
3
|
+
export type GlobalRenderCallback = (timestamp: number) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Adds a global render callback which is called each frame.
|
|
6
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
7
|
+
*/
|
|
8
|
+
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Adds a global after-render callback which is called each frame.
|
|
11
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
12
|
+
*/
|
|
13
|
+
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Adds a global callback which is called when rendering stops.
|
|
16
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
17
|
+
*/
|
|
18
|
+
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
19
|
+
export type GlobalEffectType = 'before' | 'after' | 'tail';
|
|
20
|
+
export declare function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
|
|
21
|
+
export declare function loop(timestamp: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
24
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
25
|
+
*/
|
|
26
|
+
export declare function invalidate(state?: RootState, frames?: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
29
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
30
|
+
*/
|
|
31
|
+
export declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const isPromiseLike: (value: unknown) => value is PromiseLike<unknown>;
|
|
2
|
+
/** A promise tagged with its state, the protocol React's `use` reads */
|
|
3
|
+
export type TrackedPromise<T> = Promise<T> & ({
|
|
4
|
+
status: 'pending';
|
|
5
|
+
} | {
|
|
6
|
+
status: 'fulfilled';
|
|
7
|
+
value: T;
|
|
8
|
+
} | {
|
|
9
|
+
status: 'rejected';
|
|
10
|
+
reason: unknown;
|
|
11
|
+
});
|
|
12
|
+
export declare const fulfilled: <T>(value: T) => TrackedPromise<T>;
|
|
13
|
+
export declare const rejected: <T>(reason: unknown) => TrackedPromise<T>;
|
|
14
|
+
/** Tags `promise` in place once it settles. */
|
|
15
|
+
export declare const tracked: <T>(promise: PromiseLike<T>) => TrackedPromise<T>;
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import Reconciler from '../../react-reconciler/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
args
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Reconciler from '../../react-reconciler/index.js';
|
|
4
|
+
import type { TrackedPromise } from "./promise.js";
|
|
5
|
+
import { IsAllOptional } from "./utils.js";
|
|
6
|
+
import type { RootStore } from "./store.js";
|
|
7
|
+
import { type EventHandlers } from "./events.js";
|
|
8
|
+
import type { ThreeElement } from "../three-types.js";
|
|
9
|
+
export interface Root {
|
|
10
|
+
fiber: Reconciler.FiberRoot;
|
|
11
|
+
store: RootStore;
|
|
12
|
+
unmountClaim: symbol | null;
|
|
13
|
+
/** Pending only while an async renderer is being created */
|
|
14
|
+
ready: TrackedPromise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
|
|
17
|
+
export type AttachType<O = any> = string | AttachFnType<O>;
|
|
18
|
+
export type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
|
|
19
|
+
export interface Catalogue {
|
|
20
|
+
[name: string]: ConstructorRepresentation;
|
|
21
|
+
}
|
|
22
|
+
export type Args<T> = T extends ConstructorRepresentation ? T extends typeof THREE.Color ? [r: number, g: number, b: number] | [color: THREE.ColorRepresentation] : ConstructorParameters<T> : any[];
|
|
23
|
+
type ArgsProp<P> = P extends ConstructorRepresentation ? IsAllOptional<ConstructorParameters<P>> extends true ? {
|
|
24
|
+
args?: Args<P>;
|
|
25
|
+
} : {
|
|
26
|
+
args: Args<P>;
|
|
27
|
+
} : {
|
|
28
|
+
args: unknown[];
|
|
29
|
+
};
|
|
30
|
+
export type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
31
|
+
object?: T;
|
|
32
|
+
dispose?: null;
|
|
33
|
+
attach?: AttachType<T>;
|
|
34
|
+
onUpdate?: (self: T) => void;
|
|
35
|
+
};
|
|
36
|
+
export interface Instance<O = any> {
|
|
37
|
+
root: RootStore;
|
|
38
|
+
type: string;
|
|
39
|
+
parent: Instance | null;
|
|
40
|
+
children: Instance[];
|
|
41
|
+
props: InstanceProps<O> & Record<string, unknown>;
|
|
42
|
+
object: O & {
|
|
43
|
+
__r3f?: Instance<O>;
|
|
44
|
+
};
|
|
45
|
+
eventCount: number;
|
|
46
|
+
handlers: Partial<EventHandlers>;
|
|
47
|
+
attach?: AttachType<O>;
|
|
48
|
+
previousAttach?: any;
|
|
49
|
+
isHidden: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
|
|
52
|
+
export declare function extend<T extends Catalogue>(objects: T): void;
|
|
53
|
+
export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
54
|
+
export {};
|