@react-three/fiber 9.0.0-alpha.2 → 9.0.0-alpha.3
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 +962 -522
- package/dist/declarations/src/core/events.d.ts +91 -69
- package/dist/declarations/src/core/hooks.d.ts +53 -27
- package/dist/declarations/src/core/index.d.ts +15 -60
- package/dist/declarations/src/core/loop.d.ts +31 -15
- package/dist/declarations/src/core/reconciler.d.ts +43 -0
- package/dist/declarations/src/core/renderer.d.ts +85 -40
- package/dist/declarations/src/core/stages.d.ts +64 -59
- package/dist/declarations/src/core/store.d.ts +147 -109
- package/dist/declarations/src/core/utils.d.ts +128 -80
- package/dist/declarations/src/index.d.ts +6 -10
- package/dist/declarations/src/native/Canvas.d.ts +14 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native.d.ts +6 -8
- package/dist/declarations/src/three-types.d.ts +56 -47
- package/dist/declarations/src/web/Canvas.d.ts +24 -11
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-5bd4d3cf.cjs.dev.js → loop-0698c205.cjs.dev.js} +1469 -1268
- package/dist/{index-8128f248.cjs.prod.js → loop-a0ef8208.cjs.prod.js} +1469 -1268
- package/dist/{index-47b7622a.esm.js → loop-b2aca207.esm.js} +1466 -1268
- package/dist/react-three-fiber.cjs.d.ts +1 -0
- package/dist/react-three-fiber.cjs.dev.js +126 -115
- package/dist/react-three-fiber.cjs.prod.js +126 -115
- package/dist/react-three-fiber.esm.js +92 -84
- package/native/dist/react-three-fiber-native.cjs.d.ts +1 -0
- package/native/dist/react-three-fiber-native.cjs.dev.js +278 -211
- package/native/dist/react-three-fiber-native.cjs.prod.js +278 -211
- package/native/dist/react-three-fiber-native.esm.js +242 -180
- package/native/package.json +5 -5
- package/package.json +18 -12
- package/readme.md +253 -202
- package/dist/declarations/src/native/polyfills.d.ts +0 -1
|
@@ -1,69 +1,91 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
export interface Intersection extends THREE.Intersection {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { RootState, RootStore } from "./store.js";
|
|
3
|
+
import type { Properties } from "../three-types.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
|
+
}
|
|
60
|
+
export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
61
|
+
export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
62
|
+
export interface EventManager<TTarget> {
|
|
63
|
+
/** Determines if the event layer is active */
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
|
|
66
|
+
priority: number;
|
|
67
|
+
/** The compute function needs to set up the raycaster and an xy- pointer */
|
|
68
|
+
compute?: ComputeFunction;
|
|
69
|
+
/** The filter can re-order or re-structure the intersections */
|
|
70
|
+
filter?: FilterFunction;
|
|
71
|
+
/** The target node the event layer is tied to */
|
|
72
|
+
connected?: TTarget;
|
|
73
|
+
/** All the pointer event handlers through which the host forwards native events */
|
|
74
|
+
handlers?: Events;
|
|
75
|
+
/** Allows re-connecting to another target */
|
|
76
|
+
connect?: (target: TTarget) => void;
|
|
77
|
+
/** Removes all existing events handlers from the target */
|
|
78
|
+
disconnect?: () => void;
|
|
79
|
+
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
80
|
+
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
81
|
+
*/
|
|
82
|
+
update?: () => void;
|
|
83
|
+
}
|
|
84
|
+
export interface PointerCaptureTarget {
|
|
85
|
+
intersection: Intersection;
|
|
86
|
+
target: Element;
|
|
87
|
+
}
|
|
88
|
+
export declare function removeInteractivity(store: RootStore, object: THREE.Object3D): void;
|
|
89
|
+
export declare function createEvents(store: RootStore): {
|
|
90
|
+
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
91
|
+
};
|
|
@@ -1,27 +1,53 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { RootState, RenderCallback, UpdateCallback, StageTypes, RootStore } from "./store.js";
|
|
4
|
+
import { ObjectMap } from "./utils.js";
|
|
5
|
+
import type { Instance } 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<O>(ref: React.MutableRefObject<O>): React.MutableRefObject<Instance>;
|
|
13
|
+
export declare function useStore(): RootStore;
|
|
14
|
+
/**
|
|
15
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
16
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
17
|
+
*/
|
|
18
|
+
export declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
19
|
+
/**
|
|
20
|
+
* Executes a callback before render in a shared frame loop.
|
|
21
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
22
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
23
|
+
*/
|
|
24
|
+
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
25
|
+
/**
|
|
26
|
+
* Executes a callback in a given update stage.
|
|
27
|
+
* Uses the stage instance to indetify which stage to target in the lifecycle.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useUpdate(callback: UpdateCallback, stage?: StageTypes): void;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
32
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
33
|
+
*/
|
|
34
|
+
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
35
|
+
export interface Loader<T> extends THREE.Loader {
|
|
36
|
+
load(url: string | string[] | string[][], onLoad?: (result: T, ...args: any[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: unknown) => void): unknown;
|
|
37
|
+
}
|
|
38
|
+
export type LoaderProto<T> = new (...args: any[]) => Loader<T>;
|
|
39
|
+
export type LoaderResult<T> = T extends {
|
|
40
|
+
scene: THREE.Object3D;
|
|
41
|
+
} ? T & ObjectMap : T;
|
|
42
|
+
export type Extensions<T> = (loader: Loader<T>) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Synchronously loads and caches assets with a three loader.
|
|
45
|
+
*
|
|
46
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
47
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
48
|
+
*/
|
|
49
|
+
export declare function useLoader<T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U, extensions?: Extensions<T>, onProgress?: (event: ProgressEvent) => void): U extends any[] ? LoaderResult<T>[] : LoaderResult<T>;
|
|
50
|
+
export declare namespace useLoader {
|
|
51
|
+
var preload: <T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U, extensions?: Extensions<T> | undefined) => void;
|
|
52
|
+
var clear: <T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U) => void;
|
|
53
|
+
}
|
|
@@ -1,60 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}[keyof T]>;
|
|
17
|
-
declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
18
|
-
export declare type RenderProps<TCanvas extends Element> = {
|
|
19
|
-
gl?: GLProps;
|
|
20
|
-
size?: Size;
|
|
21
|
-
shadows?: boolean | Partial<THREE.WebGLShadowMap>;
|
|
22
|
-
legacy?: boolean;
|
|
23
|
-
linear?: boolean;
|
|
24
|
-
flat?: boolean;
|
|
25
|
-
orthographic?: boolean;
|
|
26
|
-
frameloop?: Frameloop;
|
|
27
|
-
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
28
|
-
dpr?: Dpr;
|
|
29
|
-
raycaster?: Partial<THREE.Raycaster>;
|
|
30
|
-
camera?: (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
|
|
31
|
-
manual?: boolean;
|
|
32
|
-
};
|
|
33
|
-
events?: (store: UseBoundStore<RootState>) => EventManager<HTMLElement>;
|
|
34
|
-
onCreated?: (state: RootState) => void;
|
|
35
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
36
|
-
stages?: Stage[];
|
|
37
|
-
render?: 'auto' | 'manual';
|
|
38
|
-
};
|
|
39
|
-
export declare type ReconcilerRoot<TCanvas extends Element> = {
|
|
40
|
-
configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
|
|
41
|
-
render: (element: React.ReactNode) => UseBoundStore<RootState>;
|
|
42
|
-
unmount: () => void;
|
|
43
|
-
};
|
|
44
|
-
declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
45
|
-
declare function render<TCanvas extends Element>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
46
|
-
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
47
|
-
export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
48
|
-
events?: {
|
|
49
|
-
enabled?: boolean;
|
|
50
|
-
priority?: number;
|
|
51
|
-
compute?: ComputeFunction;
|
|
52
|
-
connected?: any;
|
|
53
|
-
};
|
|
54
|
-
size?: Size;
|
|
55
|
-
}>;
|
|
56
|
-
declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.ReactNode;
|
|
57
|
-
declare type Act = <T = any>(cb: () => Promise<T>) => Promise<T>;
|
|
58
|
-
declare const act: Act;
|
|
59
|
-
export * from './hooks';
|
|
60
|
-
export { context, render, createRoot, unmountComponentAtNode, createPortal, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, getRootState, Act, act, roots as _roots, };
|
|
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, render, createRoot, unmountComponentAtNode, createPortal } from "./renderer.js";
|
|
10
|
+
export type { UpdateSubscription } from "./stages.js";
|
|
11
|
+
export { Stage, FixedStage, Stages } from "./stages.js";
|
|
12
|
+
export type { Subscription, Dpr, Size, Viewport, RenderCallback, UpdateCallback, LegacyAlways, FrameloopMode, FrameloopRender, FrameloopLegacy, Frameloop, Performance, Renderer, StageTypes, XRManager, RootState, RootStore, } from "./store.js";
|
|
13
|
+
export { context } from "./store.js";
|
|
14
|
+
export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
|
|
15
|
+
export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
/// <reference types="webxr" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,43 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Reconciler from 'react-reconciler';
|
|
4
|
+
import type { RootStore } from "./store.js";
|
|
5
|
+
import { type EventHandlers } from "./events.js";
|
|
6
|
+
import type { ThreeElement } from "../three-types.js";
|
|
7
|
+
export interface Root {
|
|
8
|
+
fiber: Reconciler.FiberRoot;
|
|
9
|
+
store: RootStore;
|
|
10
|
+
}
|
|
11
|
+
export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
|
|
12
|
+
export type AttachType<O = any> = string | AttachFnType<O>;
|
|
13
|
+
export type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
|
|
14
|
+
export interface Catalogue {
|
|
15
|
+
[name: string]: ConstructorRepresentation;
|
|
16
|
+
}
|
|
17
|
+
export type Args<T> = T extends ConstructorRepresentation ? T extends typeof THREE.Color ? [r: number, g: number, b: number] | [color: THREE.ColorRepresentation] : ConstructorParameters<T> : any[];
|
|
18
|
+
export interface InstanceProps<T = any, P = any> {
|
|
19
|
+
args?: Args<P>;
|
|
20
|
+
object?: T;
|
|
21
|
+
visible?: boolean;
|
|
22
|
+
dispose?: null;
|
|
23
|
+
attach?: AttachType<T>;
|
|
24
|
+
}
|
|
25
|
+
export interface Instance<O = any> {
|
|
26
|
+
root: RootStore;
|
|
27
|
+
type: string;
|
|
28
|
+
parent: Instance | null;
|
|
29
|
+
children: Instance[];
|
|
30
|
+
props: InstanceProps<O> & Record<string, unknown>;
|
|
31
|
+
object: O & {
|
|
32
|
+
__r3f?: Instance<O>;
|
|
33
|
+
};
|
|
34
|
+
eventCount: number;
|
|
35
|
+
handlers: Partial<EventHandlers>;
|
|
36
|
+
attach?: AttachType<O>;
|
|
37
|
+
previousAttach?: any;
|
|
38
|
+
isHidden: boolean;
|
|
39
|
+
autoRemovedBeforeAppend?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const catalogue: Catalogue;
|
|
42
|
+
export declare const extend: <T extends Catalogue | ConstructorRepresentation<any>>(objects: T) => T extends ConstructorRepresentation<any> ? React.ExoticComponent<import("../three-types.js").Mutable<import("../three-types.js").Overwrite<Partial<import("../three-types.js").Overwrite<import("../three-types.js").WithMathProps<InstanceType<T>>, import("../three-types.js").ReactProps<InstanceType<T>> & import("../three-types.js").EventProps<InstanceType<T>>>>, Omit<InstanceProps<InstanceType<T>, T>, "object">>>> : void;
|
|
43
|
+
export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, any>;
|
|
@@ -1,40 +1,85 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { Properties, ThreeElement } from "../three-types.js";
|
|
4
|
+
import { Renderer, RootState, Size, Dpr, Performance, Frameloop, RootStore } from "./store.js";
|
|
5
|
+
import { Root } from "./reconciler.js";
|
|
6
|
+
import { EventManager, ComputeFunction } from "./events.js";
|
|
7
|
+
import { Camera } from "./utils.js";
|
|
8
|
+
import { Stage } from "./stages.js";
|
|
9
|
+
declare var OffscreenCanvas: any;
|
|
10
|
+
type OffscreenCanvas = any;
|
|
11
|
+
type Canvas = HTMLCanvasElement | OffscreenCanvas;
|
|
12
|
+
export declare const _roots: Map<any, Root>;
|
|
13
|
+
export type GLProps = Renderer | ((canvas: Canvas) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>;
|
|
14
|
+
export type CameraProps = (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
|
|
15
|
+
/** Flags the camera as manual, putting projection into your own hands */
|
|
16
|
+
manual?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export interface RenderProps<TCanvas extends Canvas> {
|
|
19
|
+
/** A threejs renderer instance or props that go into the default renderer */
|
|
20
|
+
gl?: GLProps;
|
|
21
|
+
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
22
|
+
size?: Size;
|
|
23
|
+
/**
|
|
24
|
+
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
25
|
+
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
26
|
+
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
27
|
+
*/
|
|
28
|
+
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
|
|
29
|
+
/**
|
|
30
|
+
* Disables three r139 color management.
|
|
31
|
+
* @see https://threejs.org/docs/#manual/en/introduction/Color-management
|
|
32
|
+
*/
|
|
33
|
+
legacy?: boolean;
|
|
34
|
+
/** Switch off automatic sRGB encoding and gamma correction */
|
|
35
|
+
linear?: boolean;
|
|
36
|
+
/** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
|
|
37
|
+
flat?: boolean;
|
|
38
|
+
/** Creates an orthographic camera */
|
|
39
|
+
orthographic?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
42
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
43
|
+
*/
|
|
44
|
+
frameloop?: Frameloop;
|
|
45
|
+
/**
|
|
46
|
+
* R3F performance options for adaptive performance.
|
|
47
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
48
|
+
*/
|
|
49
|
+
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
50
|
+
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
51
|
+
dpr?: Dpr;
|
|
52
|
+
/** Props that go into the default raycaster */
|
|
53
|
+
raycaster?: Partial<THREE.Raycaster>;
|
|
54
|
+
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
55
|
+
scene?: THREE.Scene | Partial<THREE.Scene>;
|
|
56
|
+
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
57
|
+
camera?: CameraProps;
|
|
58
|
+
/** An R3F event manager to manage elements' pointer events */
|
|
59
|
+
events?: (store: RootStore) => EventManager<HTMLElement>;
|
|
60
|
+
/** Callback after the canvas has rendered (but not yet committed) */
|
|
61
|
+
onCreated?: (state: RootState) => void;
|
|
62
|
+
/** Response for pointer clicks that have missed any target */
|
|
63
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
64
|
+
/** Create a custom lifecycle of stages */
|
|
65
|
+
stages?: Stage[];
|
|
66
|
+
render?: 'auto' | 'manual';
|
|
67
|
+
}
|
|
68
|
+
export interface ReconcilerRoot<TCanvas extends Canvas> {
|
|
69
|
+
configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
|
|
70
|
+
render: (element: React.ReactNode) => RootStore;
|
|
71
|
+
unmount: () => void;
|
|
72
|
+
}
|
|
73
|
+
export declare function createRoot<TCanvas extends Canvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
74
|
+
export declare function render<TCanvas extends Canvas>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): RootStore;
|
|
75
|
+
export declare function unmountComponentAtNode<TCanvas extends Canvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
76
|
+
export type InjectState = Partial<Omit<RootState, 'events'> & {
|
|
77
|
+
events?: {
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
priority?: number;
|
|
80
|
+
compute?: ComputeFunction;
|
|
81
|
+
connected?: any;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
export declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): JSX.Element;
|
|
85
|
+
export {};
|