@react-three/fiber 8.0.0-alpha-07 → 8.0.0-beta-01
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 +67 -0
- package/dist/declarations/src/core/events.d.ts +63 -59
- package/dist/declarations/src/core/hooks.d.ts +21 -29
- package/dist/declarations/src/core/loop.d.ts +12 -12
- package/dist/declarations/src/core/renderer.d.ts +50 -52
- package/dist/declarations/src/core/store.d.ts +111 -106
- package/dist/declarations/src/core/utils.d.ts +43 -0
- package/dist/declarations/src/index.d.ts +7 -7
- package/dist/declarations/src/native/Canvas.d.ts +16 -0
- package/dist/declarations/src/native/events.d.ts +6 -0
- package/dist/declarations/src/native/hooks.d.ts +9 -0
- package/dist/declarations/src/native/index.d.ts +37 -0
- package/dist/declarations/src/native.d.ts +7 -0
- package/dist/declarations/src/three-types.d.ts +320 -319
- package/dist/declarations/src/web/Canvas.d.ts +13 -13
- package/dist/declarations/src/web/events.d.ts +5 -4
- package/dist/declarations/src/web/index.d.ts +34 -30
- package/dist/hooks-c89a6f88.esm.js +1455 -0
- package/dist/hooks-dd693347.cjs.dev.js +1501 -0
- package/dist/hooks-e01f12ec.cjs.prod.js +1501 -0
- package/dist/react-three-fiber.cjs.dev.js +142 -1554
- package/dist/react-three-fiber.cjs.prod.js +142 -1554
- package/dist/react-three-fiber.esm.js +123 -1532
- package/native/dist/react-three-fiber-native.cjs.d.ts +1 -0
- package/native/dist/react-three-fiber-native.cjs.dev.js +590 -0
- package/native/dist/react-three-fiber-native.cjs.js +7 -0
- package/native/dist/react-three-fiber-native.cjs.prod.js +590 -0
- package/native/dist/react-three-fiber-native.esm.js +538 -0
- package/native/package.json +5 -0
- package/package.json +15 -5
- package/__mocks__/react-use-measure/index.ts +0 -22
- package/dist/declarations/src/core/is.d.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# @react-three/fiber
|
|
2
2
|
|
|
3
|
+
## 7.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 894c550: fix: event count
|
|
8
|
+
|
|
9
|
+
## 7.0.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- c7a4220: patch: applyprops returns the same instance
|
|
14
|
+
|
|
15
|
+
## 7.0.15
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- c5645e8: fix primitve leftovers on switch
|
|
20
|
+
|
|
21
|
+
## 7.0.14
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 05af996: fix: revert the is function
|
|
26
|
+
|
|
27
|
+
## 7.0.13
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- f256558: fix(core): don't overwrite camera rotation
|
|
32
|
+
- 51e6fc9: fix(core): safely handle external instances
|
|
33
|
+
|
|
34
|
+
## 7.0.12
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- 0df6073: fix: missed events
|
|
39
|
+
|
|
40
|
+
## 7.0.11
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- 62b0a3a: fix: event order of missed pointers
|
|
45
|
+
|
|
46
|
+
## 7.0.10
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- e019dd4: fixes
|
|
51
|
+
|
|
52
|
+
## 7.0.9
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- cd266e4: Fix diffProps dashed keys
|
|
57
|
+
|
|
58
|
+
## 7.0.8
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- 6f68406: Allow getCurrentViewport to receive an array
|
|
63
|
+
|
|
64
|
+
## 7.0.7
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 0375896: Simplify useframe, support instanced event cancelation, silence disposal
|
|
69
|
+
|
|
3
70
|
## 7.0.6
|
|
4
71
|
|
|
5
72
|
### Patch Changes
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import type { UseStore } from 'zustand';
|
|
3
|
-
import type { RootState } from './store';
|
|
4
|
-
export interface Intersection extends THREE.Intersection {
|
|
5
|
-
eventObject: THREE.Object3D;
|
|
6
|
-
}
|
|
7
|
-
export interface IntesectionEvent<TSourceEvent> extends Intersection {
|
|
8
|
-
intersections: Intersection[];
|
|
9
|
-
stopped: boolean;
|
|
10
|
-
unprojectedPoint: THREE.Vector3;
|
|
11
|
-
ray: THREE.Ray;
|
|
12
|
-
camera: Camera;
|
|
13
|
-
stopPropagation: () => void;
|
|
14
|
-
sourceEvent: TSourceEvent;
|
|
15
|
-
nativeEvent: TSourceEvent;
|
|
16
|
-
delta: number;
|
|
17
|
-
spaceX: number;
|
|
18
|
-
spaceY: number;
|
|
19
|
-
}
|
|
20
|
-
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
21
|
-
export declare type ThreeEvent<TEvent> = TEvent & IntesectionEvent<TEvent>;
|
|
22
|
-
export declare type DomEvent = ThreeEvent<PointerEvent | MouseEvent | WheelEvent>;
|
|
23
|
-
export declare type Events = {
|
|
24
|
-
onClick: EventListener;
|
|
25
|
-
onContextMenu: EventListener;
|
|
26
|
-
onDoubleClick: EventListener;
|
|
27
|
-
onWheel: EventListener;
|
|
28
|
-
onPointerDown: EventListener;
|
|
29
|
-
onPointerUp: EventListener;
|
|
30
|
-
onPointerLeave: EventListener;
|
|
31
|
-
onPointerMove: EventListener;
|
|
32
|
-
onPointerCancel: EventListener;
|
|
33
|
-
onLostPointerCapture: EventListener;
|
|
34
|
-
};
|
|
35
|
-
export declare type EventHandlers = {
|
|
36
|
-
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
37
|
-
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
38
|
-
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
39
|
-
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
40
|
-
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
41
|
-
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
42
|
-
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
43
|
-
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
44
|
-
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
45
|
-
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
46
|
-
onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
|
|
47
|
-
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
48
|
-
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
49
|
-
};
|
|
50
|
-
export interface EventManager<TTarget> {
|
|
51
|
-
connected: TTarget | boolean;
|
|
52
|
-
handlers?: Events;
|
|
53
|
-
connect?: (target: TTarget) => void;
|
|
54
|
-
disconnect?: () => void;
|
|
55
|
-
}
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { UseStore } from 'zustand';
|
|
3
|
+
import type { RootState } from './store';
|
|
4
|
+
export interface Intersection extends THREE.Intersection {
|
|
5
|
+
eventObject: THREE.Object3D;
|
|
6
|
+
}
|
|
7
|
+
export interface IntesectionEvent<TSourceEvent> extends Intersection {
|
|
8
|
+
intersections: Intersection[];
|
|
9
|
+
stopped: boolean;
|
|
10
|
+
unprojectedPoint: THREE.Vector3;
|
|
11
|
+
ray: THREE.Ray;
|
|
12
|
+
camera: Camera;
|
|
13
|
+
stopPropagation: () => void;
|
|
14
|
+
sourceEvent: TSourceEvent;
|
|
15
|
+
nativeEvent: TSourceEvent;
|
|
16
|
+
delta: number;
|
|
17
|
+
spaceX: number;
|
|
18
|
+
spaceY: number;
|
|
19
|
+
}
|
|
20
|
+
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
21
|
+
export declare type ThreeEvent<TEvent> = TEvent & IntesectionEvent<TEvent>;
|
|
22
|
+
export declare type DomEvent = ThreeEvent<PointerEvent | MouseEvent | WheelEvent>;
|
|
23
|
+
export declare type Events = {
|
|
24
|
+
onClick: EventListener;
|
|
25
|
+
onContextMenu: EventListener;
|
|
26
|
+
onDoubleClick: EventListener;
|
|
27
|
+
onWheel: EventListener;
|
|
28
|
+
onPointerDown: EventListener;
|
|
29
|
+
onPointerUp: EventListener;
|
|
30
|
+
onPointerLeave: EventListener;
|
|
31
|
+
onPointerMove: EventListener;
|
|
32
|
+
onPointerCancel: EventListener;
|
|
33
|
+
onLostPointerCapture: EventListener;
|
|
34
|
+
};
|
|
35
|
+
export declare type EventHandlers = {
|
|
36
|
+
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
37
|
+
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
38
|
+
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
39
|
+
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
40
|
+
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
41
|
+
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
42
|
+
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
43
|
+
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
44
|
+
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
45
|
+
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
46
|
+
onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
|
|
47
|
+
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
48
|
+
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
49
|
+
};
|
|
50
|
+
export interface EventManager<TTarget> {
|
|
51
|
+
connected: TTarget | boolean;
|
|
52
|
+
handlers?: Events;
|
|
53
|
+
connect?: (target: TTarget) => void;
|
|
54
|
+
disconnect?: () => void;
|
|
55
|
+
}
|
|
56
|
+
export interface PointerCaptureTarget {
|
|
57
|
+
intersection: Intersection;
|
|
58
|
+
target: Element;
|
|
59
|
+
}
|
|
60
|
+
export declare function removeInteractivity(store: UseStore<RootState>, object: THREE.Object3D): void;
|
|
61
|
+
export declare function createEvents(store: UseStore<RootState>): {
|
|
62
|
+
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
63
|
+
};
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { StateSelector, EqualityChecker } from 'zustand';
|
|
3
|
-
import
|
|
4
|
-
import { RootState, RenderCallback } from './store';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare type
|
|
10
|
-
declare type
|
|
11
|
-
declare type
|
|
12
|
-
export declare type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
23
|
-
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
24
|
-
export declare function useLoader<T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<T, GLTF, GLTF & ObjectMap>[] : BranchingReturn<T, GLTF, GLTF & ObjectMap>;
|
|
25
|
-
export declare namespace useLoader {
|
|
26
|
-
var preload: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions | undefined) => undefined;
|
|
27
|
-
var clear: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U) => void;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { StateSelector, EqualityChecker } from 'zustand';
|
|
3
|
+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
4
|
+
import { RootState, RenderCallback } from './store';
|
|
5
|
+
import { ObjectMap } from './utils';
|
|
6
|
+
export interface Loader<T> extends THREE.Loader {
|
|
7
|
+
load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare type Extensions = (loader: THREE.Loader) => void;
|
|
10
|
+
export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
|
|
11
|
+
export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
12
|
+
export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
|
|
13
|
+
export declare function useStore(): import("zustand").UseStore<RootState>;
|
|
14
|
+
export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
|
|
15
|
+
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
16
|
+
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
17
|
+
export declare function useLoader<T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<T, GLTF, GLTF & ObjectMap>[] : BranchingReturn<T, GLTF, GLTF & ObjectMap>;
|
|
18
|
+
export declare namespace useLoader {
|
|
19
|
+
var preload: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions | undefined) => undefined;
|
|
20
|
+
var clear: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U) => void;
|
|
21
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Root } from './renderer';
|
|
2
|
-
import { RootState } from './store';
|
|
3
|
-
declare type GlobalRenderCallback = (timeStamp: number) => void;
|
|
4
|
-
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
5
|
-
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
6
|
-
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
7
|
-
export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
|
|
8
|
-
loop: (timestamp: number) => number | undefined;
|
|
9
|
-
invalidate: (state?: RootState | undefined) => void;
|
|
10
|
-
advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined) => void;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
1
|
+
import { Root } from './renderer';
|
|
2
|
+
import { RootState } from './store';
|
|
3
|
+
declare type GlobalRenderCallback = (timeStamp: number) => void;
|
|
4
|
+
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
5
|
+
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
6
|
+
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
7
|
+
export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
|
|
8
|
+
loop: (timestamp: number) => number | undefined;
|
|
9
|
+
invalidate: (state?: RootState | undefined) => void;
|
|
10
|
+
advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -1,52 +1,50 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export declare type AttachFnType = (self: Instance, parent: Instance) => void;
|
|
23
|
-
export declare type AttachFnsType = [attach: string | AttachFnType, detach: string | AttachFnType];
|
|
24
|
-
export declare type BaseInstance = Omit<THREE.Object3D, '
|
|
25
|
-
__r3f: LocalState;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
declare
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
export { prepare, createRenderer, extend };
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { UseStore } from 'zustand';
|
|
3
|
+
import Reconciler from 'react-reconciler';
|
|
4
|
+
import { prepare, applyProps } from './utils';
|
|
5
|
+
import { RootState } from './store';
|
|
6
|
+
import { EventHandlers } from './events';
|
|
7
|
+
export declare type Root = {
|
|
8
|
+
fiber: Reconciler.FiberRoot;
|
|
9
|
+
store: UseStore<RootState>;
|
|
10
|
+
};
|
|
11
|
+
export declare type LocalState = {
|
|
12
|
+
root: UseStore<RootState>;
|
|
13
|
+
objects: Instance[];
|
|
14
|
+
parent: Instance | null;
|
|
15
|
+
primitive?: boolean;
|
|
16
|
+
eventCount: number;
|
|
17
|
+
handlers: Partial<EventHandlers>;
|
|
18
|
+
memoizedProps: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare type AttachFnType = (self: Instance, parent: Instance) => void;
|
|
23
|
+
export declare type AttachFnsType = [attach: string | AttachFnType, detach: string | AttachFnType];
|
|
24
|
+
export declare type BaseInstance = Omit<THREE.Object3D, 'children' | 'attach' | 'add' | 'remove' | 'raycast'> & {
|
|
25
|
+
__r3f: LocalState;
|
|
26
|
+
children: Instance[];
|
|
27
|
+
attach?: string;
|
|
28
|
+
attachFns?: AttachFnsType;
|
|
29
|
+
remove: (...object: Instance[]) => Instance;
|
|
30
|
+
add: (...object: Instance[]) => Instance;
|
|
31
|
+
raycast?: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
32
|
+
};
|
|
33
|
+
export declare type Instance = BaseInstance & {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
export declare type InstanceProps = {
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
} & {
|
|
39
|
+
args?: any[];
|
|
40
|
+
object?: object;
|
|
41
|
+
visible?: boolean;
|
|
42
|
+
dispose?: null;
|
|
43
|
+
attach?: string;
|
|
44
|
+
};
|
|
45
|
+
declare let extend: (objects: object) => void;
|
|
46
|
+
declare function createRenderer<TCanvas>(roots: Map<TCanvas, Root>, getEventPriority?: () => any): {
|
|
47
|
+
reconciler: Reconciler.Reconciler<unknown, unknown, unknown, unknown, unknown>;
|
|
48
|
+
applyProps: typeof applyProps;
|
|
49
|
+
};
|
|
50
|
+
export { prepare, createRenderer, extend };
|
|
@@ -1,106 +1,111 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import * as ReactThreeFiber from '../three-types';
|
|
4
|
-
import { GetState, SetState, UseStore } from 'zustand';
|
|
5
|
-
import { Instance, InstanceProps } from './renderer';
|
|
6
|
-
import { DomEvent, EventManager, ThreeEvent } from './events';
|
|
7
|
-
export interface Intersection extends THREE.Intersection {
|
|
8
|
-
eventObject: THREE.Object3D;
|
|
9
|
-
}
|
|
10
|
-
export declare type Subscription = {
|
|
11
|
-
ref: React.MutableRefObject<RenderCallback>;
|
|
12
|
-
priority: number;
|
|
13
|
-
};
|
|
14
|
-
export declare type Dpr = number | [min: number, max: number];
|
|
15
|
-
export declare type Size = {
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
};
|
|
19
|
-
export declare type Viewport = Size & {
|
|
20
|
-
initialDpr: number;
|
|
21
|
-
dpr: number;
|
|
22
|
-
factor: number;
|
|
23
|
-
distance: number;
|
|
24
|
-
aspect: number;
|
|
25
|
-
};
|
|
26
|
-
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
27
|
-
export declare type Raycaster = THREE.Raycaster & {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
filter?: FilterFunction;
|
|
30
|
-
computeOffsets?: ComputeOffsetsFunction;
|
|
31
|
-
};
|
|
32
|
-
export declare type RenderCallback = (state: RootState, delta: number) => void;
|
|
33
|
-
export declare type Performance = {
|
|
34
|
-
current: number;
|
|
35
|
-
min: number;
|
|
36
|
-
max: number;
|
|
37
|
-
debounce: number;
|
|
38
|
-
regress: () => void;
|
|
39
|
-
};
|
|
40
|
-
export declare
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as ReactThreeFiber from '../three-types';
|
|
4
|
+
import { GetState, SetState, UseStore } from 'zustand';
|
|
5
|
+
import { Instance, InstanceProps } from './renderer';
|
|
6
|
+
import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
|
|
7
|
+
export interface Intersection extends THREE.Intersection {
|
|
8
|
+
eventObject: THREE.Object3D;
|
|
9
|
+
}
|
|
10
|
+
export declare type Subscription = {
|
|
11
|
+
ref: React.MutableRefObject<RenderCallback>;
|
|
12
|
+
priority: number;
|
|
13
|
+
};
|
|
14
|
+
export declare type Dpr = number | [min: number, max: number];
|
|
15
|
+
export declare type Size = {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type Viewport = Size & {
|
|
20
|
+
initialDpr: number;
|
|
21
|
+
dpr: number;
|
|
22
|
+
factor: number;
|
|
23
|
+
distance: number;
|
|
24
|
+
aspect: number;
|
|
25
|
+
};
|
|
26
|
+
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
27
|
+
export declare type Raycaster = THREE.Raycaster & {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
filter?: FilterFunction;
|
|
30
|
+
computeOffsets?: ComputeOffsetsFunction;
|
|
31
|
+
};
|
|
32
|
+
export declare type RenderCallback = (state: RootState, delta: number) => void;
|
|
33
|
+
export declare type Performance = {
|
|
34
|
+
current: number;
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
debounce: number;
|
|
38
|
+
regress: () => void;
|
|
39
|
+
};
|
|
40
|
+
export declare type Renderer = {
|
|
41
|
+
render: (scene: THREE.Scene, camera: THREE.Camera) => any;
|
|
42
|
+
};
|
|
43
|
+
export declare const isRenderer: (def: Renderer) => boolean;
|
|
44
|
+
export declare const isOrthographicCamera: (def: THREE.Camera) => def is THREE.OrthographicCamera;
|
|
45
|
+
export declare type InternalState = {
|
|
46
|
+
active: boolean;
|
|
47
|
+
priority: number;
|
|
48
|
+
frames: number;
|
|
49
|
+
lastProps: StoreProps;
|
|
50
|
+
interaction: THREE.Object3D[];
|
|
51
|
+
hovered: Map<string, DomEvent>;
|
|
52
|
+
subscribers: Subscription[];
|
|
53
|
+
capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
|
|
54
|
+
initialClick: [x: number, y: number];
|
|
55
|
+
initialHits: THREE.Object3D[];
|
|
56
|
+
xr: {
|
|
57
|
+
connect: () => void;
|
|
58
|
+
disconnect: () => void;
|
|
59
|
+
};
|
|
60
|
+
subscribe: (callback: React.MutableRefObject<RenderCallback>, priority?: number) => () => void;
|
|
61
|
+
};
|
|
62
|
+
export declare type RootState = {
|
|
63
|
+
gl: THREE.WebGLRenderer;
|
|
64
|
+
scene: THREE.Scene;
|
|
65
|
+
camera: Camera;
|
|
66
|
+
controls: THREE.EventDispatcher | null;
|
|
67
|
+
raycaster: Raycaster;
|
|
68
|
+
mouse: THREE.Vector2;
|
|
69
|
+
clock: THREE.Clock;
|
|
70
|
+
linear: boolean;
|
|
71
|
+
flat: boolean;
|
|
72
|
+
frameloop: 'always' | 'demand' | 'never';
|
|
73
|
+
performance: Performance;
|
|
74
|
+
size: Size;
|
|
75
|
+
viewport: Viewport & {
|
|
76
|
+
getCurrentViewport: (camera?: Camera, target?: THREE.Vector3, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
|
|
77
|
+
};
|
|
78
|
+
set: SetState<RootState>;
|
|
79
|
+
get: GetState<RootState>;
|
|
80
|
+
invalidate: () => void;
|
|
81
|
+
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
82
|
+
setSize: (width: number, height: number) => void;
|
|
83
|
+
setDpr: (dpr: Dpr) => void;
|
|
84
|
+
onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
|
|
85
|
+
events: EventManager<any>;
|
|
86
|
+
internal: InternalState;
|
|
87
|
+
};
|
|
88
|
+
export declare type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
89
|
+
export declare type ComputeOffsetsFunction = (event: any, state: RootState) => {
|
|
90
|
+
offsetX: number;
|
|
91
|
+
offsetY: number;
|
|
92
|
+
};
|
|
93
|
+
export declare type StoreProps = {
|
|
94
|
+
gl: THREE.WebGLRenderer;
|
|
95
|
+
size: Size;
|
|
96
|
+
shadows?: boolean | Partial<THREE.WebGLShadowMap>;
|
|
97
|
+
linear?: boolean;
|
|
98
|
+
flat?: boolean;
|
|
99
|
+
orthographic?: boolean;
|
|
100
|
+
frameloop?: 'always' | 'demand' | 'never';
|
|
101
|
+
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
102
|
+
dpr?: Dpr;
|
|
103
|
+
clock?: THREE.Clock;
|
|
104
|
+
raycaster?: Partial<Raycaster>;
|
|
105
|
+
camera?: Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>;
|
|
106
|
+
onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
|
|
107
|
+
};
|
|
108
|
+
export declare type ApplyProps = (instance: Instance, newProps: InstanceProps) => void;
|
|
109
|
+
declare const context: React.Context<UseStore<RootState>>;
|
|
110
|
+
declare const createStore: (applyProps: ApplyProps, invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined) => void, props: StoreProps) => UseStore<RootState>;
|
|
111
|
+
export { createStore, context };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Instance, InstanceProps, LocalState } from './renderer';
|
|
3
|
+
import { Dpr } from './store';
|
|
4
|
+
export declare const DEFAULT = "__default";
|
|
5
|
+
export declare type DiffSet = {
|
|
6
|
+
memoized: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
changes: [key: string, value: unknown, isEvent: boolean, keys: string[]][];
|
|
10
|
+
};
|
|
11
|
+
export declare const isDiffSet: (def: any) => def is DiffSet;
|
|
12
|
+
export declare type ClassConstructor = {
|
|
13
|
+
new (): void;
|
|
14
|
+
};
|
|
15
|
+
export declare type ObjectMap = {
|
|
16
|
+
nodes: {
|
|
17
|
+
[name: string]: THREE.Object3D;
|
|
18
|
+
};
|
|
19
|
+
materials: {
|
|
20
|
+
[name: string]: THREE.Material;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function calculateDpr(dpr: Dpr): number;
|
|
24
|
+
export declare const is: {
|
|
25
|
+
obj: (a: any) => boolean;
|
|
26
|
+
fun: (a: any) => a is Function;
|
|
27
|
+
str: (a: any) => a is string;
|
|
28
|
+
num: (a: any) => a is number;
|
|
29
|
+
und: (a: any) => boolean;
|
|
30
|
+
arr: (a: any) => boolean;
|
|
31
|
+
equ(a: any, b: any): boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare function buildGraph(object: THREE.Object3D): ObjectMap;
|
|
34
|
+
export declare function dispose<TObj extends {
|
|
35
|
+
dispose?: () => void;
|
|
36
|
+
type?: string;
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}>(obj: TObj): void;
|
|
39
|
+
export declare function prepare<T = THREE.Object3D>(object: T, state?: Partial<LocalState>): T;
|
|
40
|
+
export declare function diffProps(instance: Instance, { children: cN, key: kN, ref: rN, ...props }: InstanceProps, { children: cP, key: kP, ref: rP, ...previous }?: InstanceProps, remove?: boolean): DiffSet;
|
|
41
|
+
export declare function applyProps(instance: Instance, data: InstanceProps | DiffSet): void;
|
|
42
|
+
export declare function invalidateInstance(instance: Instance): void;
|
|
43
|
+
export declare function updateInstance(instance: Instance): void;
|