@react-three/fiber 9.1.1 → 9.1.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 +1148 -1136
- package/dist/declarations/src/core/events.d.ts +92 -92
- package/dist/declarations/src/core/hooks.d.ts +53 -53
- package/dist/declarations/src/core/index.d.ts +13 -13
- package/dist/declarations/src/core/loop.d.ts +31 -31
- package/dist/declarations/src/core/reconciler.d.ts +50 -50
- package/dist/declarations/src/core/renderer.d.ts +89 -89
- package/dist/declarations/src/core/store.d.ts +130 -130
- package/dist/declarations/src/core/utils.d.ts +191 -190
- 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 +67 -67
- package/dist/declarations/src/web/Canvas.d.ts +23 -23
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{events-b2f77bcf.cjs.dev.js → events-66111f5e.cjs.dev.js} +83 -85
- package/dist/{events-fed10990.cjs.prod.js → events-a96a0963.cjs.prod.js} +83 -85
- package/dist/{events-9ea6854d.esm.js → events-f681e724.esm.js} +83 -85
- package/dist/react-three-fiber.cjs.dev.js +4 -4
- package/dist/react-three-fiber.cjs.prod.js +4 -4
- package/dist/react-three-fiber.esm.js +5 -5
- package/native/dist/react-three-fiber-native.cjs.dev.js +12 -8
- package/native/dist/react-three-fiber-native.cjs.prod.js +12 -8
- package/native/dist/react-three-fiber-native.esm.js +14 -10
- package/native/package.json +5 -5
- package/package.json +2 -2
- package/readme.md +253 -253
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import type { 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 { type Properties, Camera } from "./utils.js";
|
|
8
|
-
interface OffscreenCanvas extends EventTarget {
|
|
9
|
-
}
|
|
10
|
-
export declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
11
|
-
export type DefaultGLProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
|
|
12
|
-
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
13
|
-
};
|
|
14
|
-
export type GLProps = Renderer | ((defaultProps: DefaultGLProps) => Renderer) | ((defaultProps: DefaultGLProps) => Promise<Renderer>) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>;
|
|
15
|
-
export type CameraProps = (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
|
|
16
|
-
/** Flags the camera as manual, putting projection into your own hands */
|
|
17
|
-
manual?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
20
|
-
/** A threejs renderer instance or props that go into the default renderer */
|
|
21
|
-
gl?: GLProps;
|
|
22
|
-
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
23
|
-
size?: Size;
|
|
24
|
-
/**
|
|
25
|
-
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
26
|
-
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
27
|
-
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
28
|
-
*/
|
|
29
|
-
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
|
|
30
|
-
/**
|
|
31
|
-
* Disables three r139 color management.
|
|
32
|
-
* @see https://threejs.org/docs/#manual/en/introduction/Color-management
|
|
33
|
-
*/
|
|
34
|
-
legacy?: boolean;
|
|
35
|
-
/** Switch off automatic sRGB encoding and gamma correction */
|
|
36
|
-
linear?: boolean;
|
|
37
|
-
/** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
|
|
38
|
-
flat?: boolean;
|
|
39
|
-
/** Creates an orthographic camera */
|
|
40
|
-
orthographic?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
43
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
44
|
-
*/
|
|
45
|
-
frameloop?: Frameloop;
|
|
46
|
-
/**
|
|
47
|
-
* R3F performance options for adaptive performance.
|
|
48
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
49
|
-
*/
|
|
50
|
-
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
51
|
-
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
52
|
-
dpr?: Dpr;
|
|
53
|
-
/** Props that go into the default raycaster */
|
|
54
|
-
raycaster?: Partial<THREE.Raycaster>;
|
|
55
|
-
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
56
|
-
scene?: THREE.Scene | Partial<THREE.Scene>;
|
|
57
|
-
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
58
|
-
camera?: CameraProps;
|
|
59
|
-
/** An R3F event manager to manage elements' pointer events */
|
|
60
|
-
events?: (store: RootStore) => EventManager<HTMLElement>;
|
|
61
|
-
/** Callback after the canvas has rendered (but not yet committed) */
|
|
62
|
-
onCreated?: (state: RootState) => void;
|
|
63
|
-
/** Response for pointer clicks that have missed any target */
|
|
64
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
65
|
-
}
|
|
66
|
-
export interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
67
|
-
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>;
|
|
68
|
-
render: (element: React.ReactNode) => RootStore;
|
|
69
|
-
unmount: () => void;
|
|
70
|
-
}
|
|
71
|
-
export declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
72
|
-
export declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
73
|
-
export type InjectState = Partial<Omit<RootState, 'events'> & {
|
|
74
|
-
events?: {
|
|
75
|
-
enabled?: boolean;
|
|
76
|
-
priority?: number;
|
|
77
|
-
compute?: ComputeFunction;
|
|
78
|
-
connected?: any;
|
|
79
|
-
};
|
|
80
|
-
}>;
|
|
81
|
-
export declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.JSX.Element;
|
|
82
|
-
/**
|
|
83
|
-
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
84
|
-
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
85
|
-
* Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
|
|
86
|
-
* having to revert to a non-React solution.
|
|
87
|
-
*/
|
|
88
|
-
export declare function flushSync<R>(fn: () => R): R;
|
|
89
|
-
export {};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { 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 { type Properties, Camera } from "./utils.js";
|
|
8
|
+
interface OffscreenCanvas extends EventTarget {
|
|
9
|
+
}
|
|
10
|
+
export declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
11
|
+
export type DefaultGLProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
|
|
12
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
13
|
+
};
|
|
14
|
+
export type GLProps = Renderer | ((defaultProps: DefaultGLProps) => Renderer) | ((defaultProps: DefaultGLProps) => Promise<Renderer>) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>;
|
|
15
|
+
export type CameraProps = (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
|
|
16
|
+
/** Flags the camera as manual, putting projection into your own hands */
|
|
17
|
+
manual?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
20
|
+
/** A threejs renderer instance or props that go into the default renderer */
|
|
21
|
+
gl?: GLProps;
|
|
22
|
+
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
23
|
+
size?: Size;
|
|
24
|
+
/**
|
|
25
|
+
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
26
|
+
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
27
|
+
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
28
|
+
*/
|
|
29
|
+
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
|
|
30
|
+
/**
|
|
31
|
+
* Disables three r139 color management.
|
|
32
|
+
* @see https://threejs.org/docs/#manual/en/introduction/Color-management
|
|
33
|
+
*/
|
|
34
|
+
legacy?: boolean;
|
|
35
|
+
/** Switch off automatic sRGB encoding and gamma correction */
|
|
36
|
+
linear?: boolean;
|
|
37
|
+
/** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
|
|
38
|
+
flat?: boolean;
|
|
39
|
+
/** Creates an orthographic camera */
|
|
40
|
+
orthographic?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
43
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
44
|
+
*/
|
|
45
|
+
frameloop?: Frameloop;
|
|
46
|
+
/**
|
|
47
|
+
* R3F performance options for adaptive performance.
|
|
48
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
49
|
+
*/
|
|
50
|
+
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
51
|
+
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
52
|
+
dpr?: Dpr;
|
|
53
|
+
/** Props that go into the default raycaster */
|
|
54
|
+
raycaster?: Partial<THREE.Raycaster>;
|
|
55
|
+
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
56
|
+
scene?: THREE.Scene | Partial<THREE.Scene>;
|
|
57
|
+
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
58
|
+
camera?: CameraProps;
|
|
59
|
+
/** An R3F event manager to manage elements' pointer events */
|
|
60
|
+
events?: (store: RootStore) => EventManager<HTMLElement>;
|
|
61
|
+
/** Callback after the canvas has rendered (but not yet committed) */
|
|
62
|
+
onCreated?: (state: RootState) => void;
|
|
63
|
+
/** Response for pointer clicks that have missed any target */
|
|
64
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
65
|
+
}
|
|
66
|
+
export interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
67
|
+
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>;
|
|
68
|
+
render: (element: React.ReactNode) => RootStore;
|
|
69
|
+
unmount: () => void;
|
|
70
|
+
}
|
|
71
|
+
export declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
72
|
+
export declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
73
|
+
export type InjectState = Partial<Omit<RootState, 'events'> & {
|
|
74
|
+
events?: {
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
priority?: number;
|
|
77
|
+
compute?: ComputeFunction;
|
|
78
|
+
connected?: any;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
export declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.JSX.Element;
|
|
82
|
+
/**
|
|
83
|
+
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
84
|
+
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
85
|
+
* Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
|
|
86
|
+
* having to revert to a non-React solution.
|
|
87
|
+
*/
|
|
88
|
+
export declare function flushSync<R>(fn: () => R): R;
|
|
89
|
+
export {};
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
/// <reference types="webxr" />
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { type StoreApi } from 'zustand';
|
|
5
|
-
import { type UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
6
|
-
import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from "./events.js";
|
|
7
|
-
import { type Camera } from "./utils.js";
|
|
8
|
-
export interface Intersection extends THREE.Intersection {
|
|
9
|
-
eventObject: THREE.Object3D;
|
|
10
|
-
}
|
|
11
|
-
export type Subscription = {
|
|
12
|
-
ref: React.RefObject<RenderCallback>;
|
|
13
|
-
priority: number;
|
|
14
|
-
store: RootStore;
|
|
15
|
-
};
|
|
16
|
-
export type Dpr = number | [min: number, max: number];
|
|
17
|
-
export interface Size {
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
top: number;
|
|
21
|
-
left: number;
|
|
22
|
-
}
|
|
23
|
-
export type Frameloop = 'always' | 'demand' | 'never';
|
|
24
|
-
export interface Viewport extends Size {
|
|
25
|
-
/** The initial pixel ratio */
|
|
26
|
-
initialDpr: number;
|
|
27
|
-
/** Current pixel ratio */
|
|
28
|
-
dpr: number;
|
|
29
|
-
/** size.width / viewport.width */
|
|
30
|
-
factor: number;
|
|
31
|
-
/** Camera distance */
|
|
32
|
-
distance: number;
|
|
33
|
-
/** Camera aspect ratio: width / height */
|
|
34
|
-
aspect: number;
|
|
35
|
-
}
|
|
36
|
-
export type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void;
|
|
37
|
-
export interface Performance {
|
|
38
|
-
/** Current performance normal, between min and max */
|
|
39
|
-
current: number;
|
|
40
|
-
/** How low the performance can go, between 0 and max */
|
|
41
|
-
min: number;
|
|
42
|
-
/** How high the performance can go, between min and max */
|
|
43
|
-
max: number;
|
|
44
|
-
/** Time until current returns to max in ms */
|
|
45
|
-
debounce: number;
|
|
46
|
-
/** Sets current to min, puts the system in regression */
|
|
47
|
-
regress: () => void;
|
|
48
|
-
}
|
|
49
|
-
export interface Renderer {
|
|
50
|
-
render: (scene: THREE.Scene, camera: THREE.Camera) => any;
|
|
51
|
-
}
|
|
52
|
-
export declare const isRenderer: (def: any) => boolean;
|
|
53
|
-
export interface InternalState {
|
|
54
|
-
interaction: THREE.Object3D[];
|
|
55
|
-
hovered: Map<string, ThreeEvent<DomEvent>>;
|
|
56
|
-
subscribers: Subscription[];
|
|
57
|
-
capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
|
|
58
|
-
initialClick: [x: number, y: number];
|
|
59
|
-
initialHits: THREE.Object3D[];
|
|
60
|
-
lastEvent: React.RefObject<DomEvent | null>;
|
|
61
|
-
active: boolean;
|
|
62
|
-
priority: number;
|
|
63
|
-
frames: number;
|
|
64
|
-
subscribe: (callback: React.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void;
|
|
65
|
-
}
|
|
66
|
-
export interface XRManager {
|
|
67
|
-
connect: () => void;
|
|
68
|
-
disconnect: () => void;
|
|
69
|
-
}
|
|
70
|
-
export interface RootState {
|
|
71
|
-
/** Set current state */
|
|
72
|
-
set: StoreApi<RootState>['setState'];
|
|
73
|
-
/** Get current state */
|
|
74
|
-
get: StoreApi<RootState>['getState'];
|
|
75
|
-
/** The instance of the renderer */
|
|
76
|
-
gl: THREE.WebGLRenderer;
|
|
77
|
-
/** Default camera */
|
|
78
|
-
camera: Camera;
|
|
79
|
-
/** Default scene */
|
|
80
|
-
scene: THREE.Scene;
|
|
81
|
-
/** Default raycaster */
|
|
82
|
-
raycaster: THREE.Raycaster;
|
|
83
|
-
/** Default clock */
|
|
84
|
-
clock: THREE.Clock;
|
|
85
|
-
/** Event layer interface, contains the event handler and the node they're connected to */
|
|
86
|
-
events: EventManager<any>;
|
|
87
|
-
/** XR interface */
|
|
88
|
-
xr: XRManager;
|
|
89
|
-
/** Currently used controls */
|
|
90
|
-
controls: THREE.EventDispatcher | null;
|
|
91
|
-
/** Normalized event coordinates */
|
|
92
|
-
pointer: THREE.Vector2;
|
|
93
|
-
/** @deprecated Normalized event coordinates, use "pointer" instead! */
|
|
94
|
-
mouse: THREE.Vector2;
|
|
95
|
-
legacy: boolean;
|
|
96
|
-
/** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
|
|
97
|
-
linear: boolean;
|
|
98
|
-
/** Shortcut to gl.toneMapping = NoTonemapping */
|
|
99
|
-
flat: boolean;
|
|
100
|
-
/** Render loop flags */
|
|
101
|
-
frameloop: Frameloop;
|
|
102
|
-
performance: Performance;
|
|
103
|
-
/** Reactive pixel-size of the canvas */
|
|
104
|
-
size: Size;
|
|
105
|
-
/** Reactive size of the viewport in threejs units */
|
|
106
|
-
viewport: Viewport & {
|
|
107
|
-
getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
|
|
108
|
-
};
|
|
109
|
-
/** Flags the canvas for render, but doesn't render in itself */
|
|
110
|
-
invalidate: (frames?: number) => void;
|
|
111
|
-
/** Advance (render) one step */
|
|
112
|
-
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
113
|
-
/** Shortcut to setting the event layer */
|
|
114
|
-
setEvents: (events: Partial<EventManager<any>>) => void;
|
|
115
|
-
/** Shortcut to manual sizing */
|
|
116
|
-
setSize: (width: number, height: number, top?: number, left?: number) => void;
|
|
117
|
-
/** Shortcut to manual setting the pixel ratio */
|
|
118
|
-
setDpr: (dpr: Dpr) => void;
|
|
119
|
-
/** Shortcut to setting frameloop flags */
|
|
120
|
-
setFrameloop: (frameloop: Frameloop) => void;
|
|
121
|
-
/** When the canvas was clicked but nothing was hit */
|
|
122
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
123
|
-
/** If this state model is layered (via createPortal) then this contains the previous layer */
|
|
124
|
-
previousRoot?: RootStore;
|
|
125
|
-
/** Internals */
|
|
126
|
-
internal: InternalState;
|
|
127
|
-
}
|
|
128
|
-
export type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>;
|
|
129
|
-
export declare const context: React.Context<RootStore>;
|
|
130
|
-
export declare const createStore: (invalidate: (state?: RootState, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
1
|
+
/// <reference types="webxr" />
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { type StoreApi } from 'zustand';
|
|
5
|
+
import { type UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
6
|
+
import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from "./events.js";
|
|
7
|
+
import { type Camera } from "./utils.js";
|
|
8
|
+
export interface Intersection extends THREE.Intersection {
|
|
9
|
+
eventObject: THREE.Object3D;
|
|
10
|
+
}
|
|
11
|
+
export type Subscription = {
|
|
12
|
+
ref: React.RefObject<RenderCallback>;
|
|
13
|
+
priority: number;
|
|
14
|
+
store: RootStore;
|
|
15
|
+
};
|
|
16
|
+
export type Dpr = number | [min: number, max: number];
|
|
17
|
+
export interface Size {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
}
|
|
23
|
+
export type Frameloop = 'always' | 'demand' | 'never';
|
|
24
|
+
export interface Viewport extends Size {
|
|
25
|
+
/** The initial pixel ratio */
|
|
26
|
+
initialDpr: number;
|
|
27
|
+
/** Current pixel ratio */
|
|
28
|
+
dpr: number;
|
|
29
|
+
/** size.width / viewport.width */
|
|
30
|
+
factor: number;
|
|
31
|
+
/** Camera distance */
|
|
32
|
+
distance: number;
|
|
33
|
+
/** Camera aspect ratio: width / height */
|
|
34
|
+
aspect: number;
|
|
35
|
+
}
|
|
36
|
+
export type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void;
|
|
37
|
+
export interface Performance {
|
|
38
|
+
/** Current performance normal, between min and max */
|
|
39
|
+
current: number;
|
|
40
|
+
/** How low the performance can go, between 0 and max */
|
|
41
|
+
min: number;
|
|
42
|
+
/** How high the performance can go, between min and max */
|
|
43
|
+
max: number;
|
|
44
|
+
/** Time until current returns to max in ms */
|
|
45
|
+
debounce: number;
|
|
46
|
+
/** Sets current to min, puts the system in regression */
|
|
47
|
+
regress: () => void;
|
|
48
|
+
}
|
|
49
|
+
export interface Renderer {
|
|
50
|
+
render: (scene: THREE.Scene, camera: THREE.Camera) => any;
|
|
51
|
+
}
|
|
52
|
+
export declare const isRenderer: (def: any) => boolean;
|
|
53
|
+
export interface InternalState {
|
|
54
|
+
interaction: THREE.Object3D[];
|
|
55
|
+
hovered: Map<string, ThreeEvent<DomEvent>>;
|
|
56
|
+
subscribers: Subscription[];
|
|
57
|
+
capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
|
|
58
|
+
initialClick: [x: number, y: number];
|
|
59
|
+
initialHits: THREE.Object3D[];
|
|
60
|
+
lastEvent: React.RefObject<DomEvent | null>;
|
|
61
|
+
active: boolean;
|
|
62
|
+
priority: number;
|
|
63
|
+
frames: number;
|
|
64
|
+
subscribe: (callback: React.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void;
|
|
65
|
+
}
|
|
66
|
+
export interface XRManager {
|
|
67
|
+
connect: () => void;
|
|
68
|
+
disconnect: () => void;
|
|
69
|
+
}
|
|
70
|
+
export interface RootState {
|
|
71
|
+
/** Set current state */
|
|
72
|
+
set: StoreApi<RootState>['setState'];
|
|
73
|
+
/** Get current state */
|
|
74
|
+
get: StoreApi<RootState>['getState'];
|
|
75
|
+
/** The instance of the renderer */
|
|
76
|
+
gl: THREE.WebGLRenderer;
|
|
77
|
+
/** Default camera */
|
|
78
|
+
camera: Camera;
|
|
79
|
+
/** Default scene */
|
|
80
|
+
scene: THREE.Scene;
|
|
81
|
+
/** Default raycaster */
|
|
82
|
+
raycaster: THREE.Raycaster;
|
|
83
|
+
/** Default clock */
|
|
84
|
+
clock: THREE.Clock;
|
|
85
|
+
/** Event layer interface, contains the event handler and the node they're connected to */
|
|
86
|
+
events: EventManager<any>;
|
|
87
|
+
/** XR interface */
|
|
88
|
+
xr: XRManager;
|
|
89
|
+
/** Currently used controls */
|
|
90
|
+
controls: THREE.EventDispatcher | null;
|
|
91
|
+
/** Normalized event coordinates */
|
|
92
|
+
pointer: THREE.Vector2;
|
|
93
|
+
/** @deprecated Normalized event coordinates, use "pointer" instead! */
|
|
94
|
+
mouse: THREE.Vector2;
|
|
95
|
+
legacy: boolean;
|
|
96
|
+
/** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
|
|
97
|
+
linear: boolean;
|
|
98
|
+
/** Shortcut to gl.toneMapping = NoTonemapping */
|
|
99
|
+
flat: boolean;
|
|
100
|
+
/** Render loop flags */
|
|
101
|
+
frameloop: Frameloop;
|
|
102
|
+
performance: Performance;
|
|
103
|
+
/** Reactive pixel-size of the canvas */
|
|
104
|
+
size: Size;
|
|
105
|
+
/** Reactive size of the viewport in threejs units */
|
|
106
|
+
viewport: Viewport & {
|
|
107
|
+
getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
|
|
108
|
+
};
|
|
109
|
+
/** Flags the canvas for render, but doesn't render in itself */
|
|
110
|
+
invalidate: (frames?: number) => void;
|
|
111
|
+
/** Advance (render) one step */
|
|
112
|
+
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
113
|
+
/** Shortcut to setting the event layer */
|
|
114
|
+
setEvents: (events: Partial<EventManager<any>>) => void;
|
|
115
|
+
/** Shortcut to manual sizing */
|
|
116
|
+
setSize: (width: number, height: number, top?: number, left?: number) => void;
|
|
117
|
+
/** Shortcut to manual setting the pixel ratio */
|
|
118
|
+
setDpr: (dpr: Dpr) => void;
|
|
119
|
+
/** Shortcut to setting frameloop flags */
|
|
120
|
+
setFrameloop: (frameloop: Frameloop) => void;
|
|
121
|
+
/** When the canvas was clicked but nothing was hit */
|
|
122
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
123
|
+
/** If this state model is layered (via createPortal) then this contains the previous layer */
|
|
124
|
+
previousRoot?: RootStore;
|
|
125
|
+
/** Internals */
|
|
126
|
+
internal: InternalState;
|
|
127
|
+
}
|
|
128
|
+
export type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>;
|
|
129
|
+
export declare const context: React.Context<RootStore>;
|
|
130
|
+
export declare const createStore: (invalidate: (state?: RootState, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|