@react-three/fiber 8.2.0 → 9.0.0-alpha.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 +12 -0
- package/dist/declarations/src/core/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +23 -21
- package/dist/declarations/src/core/index.d.ts +61 -57
- package/dist/declarations/src/core/loop.d.ts +13 -13
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/stages.d.ts +59 -0
- package/dist/declarations/src/core/store.d.ts +110 -95
- package/dist/declarations/src/core/utils.d.ts +81 -82
- package/dist/declarations/src/index.d.ts +12 -11
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +10 -10
- package/dist/declarations/src/three-types.d.ts +331 -331
- package/dist/declarations/src/web/Canvas.d.ts +9 -9
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-ca47b633.cjs.prod.js → index-b12f488b.cjs.prod.js} +290 -69
- package/dist/{index-0499a96a.cjs.dev.js → index-b3be5a63.cjs.dev.js} +290 -69
- package/dist/{index-6279214a.esm.js → index-e27d4a05.esm.js} +287 -70
- package/dist/react-three-fiber.cjs.dev.js +7 -1
- package/dist/react-three-fiber.cjs.prod.js +7 -1
- package/dist/react-three-fiber.esm.js +4 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +4 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +4 -1
- package/native/dist/react-three-fiber-native.esm.js +4 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import type { UseBoundStore } from 'zustand';
|
|
3
|
-
import type { RootState } from './store';
|
|
4
|
-
export interface Intersection extends THREE.Intersection {
|
|
5
|
-
eventObject: THREE.Object3D;
|
|
6
|
-
}
|
|
7
|
-
export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
8
|
-
eventObject: THREE.Object3D;
|
|
9
|
-
intersections: Intersection[];
|
|
10
|
-
unprojectedPoint: THREE.Vector3;
|
|
11
|
-
pointer: THREE.Vector2;
|
|
12
|
-
delta: number;
|
|
13
|
-
ray: THREE.Ray;
|
|
14
|
-
camera: Camera;
|
|
15
|
-
stopPropagation: () => void;
|
|
16
|
-
nativeEvent: TSourceEvent;
|
|
17
|
-
stopped: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
20
|
-
export declare type ThreeEvent<TEvent> = IntersectionEvent<TEvent>;
|
|
21
|
-
export declare type DomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
22
|
-
export declare type Events = {
|
|
23
|
-
onClick: EventListener;
|
|
24
|
-
onContextMenu: EventListener;
|
|
25
|
-
onDoubleClick: EventListener;
|
|
26
|
-
onWheel: EventListener;
|
|
27
|
-
onPointerDown: EventListener;
|
|
28
|
-
onPointerUp: EventListener;
|
|
29
|
-
onPointerLeave: EventListener;
|
|
30
|
-
onPointerMove: EventListener;
|
|
31
|
-
onPointerCancel: EventListener;
|
|
32
|
-
onLostPointerCapture: EventListener;
|
|
33
|
-
};
|
|
34
|
-
export declare type EventHandlers = {
|
|
35
|
-
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
36
|
-
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
37
|
-
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
38
|
-
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
39
|
-
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
40
|
-
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
41
|
-
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
42
|
-
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
43
|
-
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
44
|
-
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
45
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
46
|
-
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
47
|
-
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
48
|
-
};
|
|
49
|
-
export declare type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
50
|
-
export declare type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
51
|
-
export interface EventManager<TTarget> {
|
|
52
|
-
enabled: boolean;
|
|
53
|
-
priority: number;
|
|
54
|
-
compute?: ComputeFunction;
|
|
55
|
-
filter?: FilterFunction;
|
|
56
|
-
connected?: TTarget;
|
|
57
|
-
handlers?: Events;
|
|
58
|
-
connect?: (target: TTarget) => void;
|
|
59
|
-
disconnect?: () => void;
|
|
60
|
-
}
|
|
61
|
-
export interface PointerCaptureTarget {
|
|
62
|
-
intersection: Intersection;
|
|
63
|
-
target: Element;
|
|
64
|
-
}
|
|
65
|
-
export declare function getEventPriority(): 1 | 4 | 16;
|
|
66
|
-
export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
|
|
67
|
-
export declare function createEvents(store: UseBoundStore<RootState>): {
|
|
68
|
-
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
69
|
-
};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { UseBoundStore } from 'zustand';
|
|
3
|
+
import type { RootState } from './store';
|
|
4
|
+
export interface Intersection extends THREE.Intersection {
|
|
5
|
+
eventObject: THREE.Object3D;
|
|
6
|
+
}
|
|
7
|
+
export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
8
|
+
eventObject: THREE.Object3D;
|
|
9
|
+
intersections: Intersection[];
|
|
10
|
+
unprojectedPoint: THREE.Vector3;
|
|
11
|
+
pointer: THREE.Vector2;
|
|
12
|
+
delta: number;
|
|
13
|
+
ray: THREE.Ray;
|
|
14
|
+
camera: Camera;
|
|
15
|
+
stopPropagation: () => void;
|
|
16
|
+
nativeEvent: TSourceEvent;
|
|
17
|
+
stopped: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
20
|
+
export declare type ThreeEvent<TEvent> = IntersectionEvent<TEvent>;
|
|
21
|
+
export declare type DomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
22
|
+
export declare type Events = {
|
|
23
|
+
onClick: EventListener;
|
|
24
|
+
onContextMenu: EventListener;
|
|
25
|
+
onDoubleClick: EventListener;
|
|
26
|
+
onWheel: EventListener;
|
|
27
|
+
onPointerDown: EventListener;
|
|
28
|
+
onPointerUp: EventListener;
|
|
29
|
+
onPointerLeave: EventListener;
|
|
30
|
+
onPointerMove: EventListener;
|
|
31
|
+
onPointerCancel: EventListener;
|
|
32
|
+
onLostPointerCapture: EventListener;
|
|
33
|
+
};
|
|
34
|
+
export declare type EventHandlers = {
|
|
35
|
+
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
36
|
+
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
37
|
+
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
38
|
+
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
39
|
+
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
40
|
+
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
41
|
+
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
42
|
+
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
43
|
+
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
44
|
+
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
45
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
46
|
+
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
47
|
+
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
48
|
+
};
|
|
49
|
+
export declare type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
50
|
+
export declare type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
51
|
+
export interface EventManager<TTarget> {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
priority: number;
|
|
54
|
+
compute?: ComputeFunction;
|
|
55
|
+
filter?: FilterFunction;
|
|
56
|
+
connected?: TTarget;
|
|
57
|
+
handlers?: Events;
|
|
58
|
+
connect?: (target: TTarget) => void;
|
|
59
|
+
disconnect?: () => void;
|
|
60
|
+
}
|
|
61
|
+
export interface PointerCaptureTarget {
|
|
62
|
+
intersection: Intersection;
|
|
63
|
+
target: Element;
|
|
64
|
+
}
|
|
65
|
+
export declare function getEventPriority(): 1 | 4 | 16;
|
|
66
|
+
export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
|
|
67
|
+
export declare function createEvents(store: UseBoundStore<RootState>): {
|
|
68
|
+
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
69
|
+
};
|
|
@@ -1,21 +1,23 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare type
|
|
11
|
-
export declare type
|
|
12
|
-
export declare type
|
|
13
|
-
export declare
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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, StageTypes } from './store';
|
|
5
|
+
import { ObjectMap } from './utils';
|
|
6
|
+
import { UpdateCallback } from './stages';
|
|
7
|
+
export interface Loader<T> extends THREE.Loader {
|
|
8
|
+
load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare type Extensions = (loader: THREE.Loader) => void;
|
|
11
|
+
export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
|
|
12
|
+
export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
13
|
+
export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
|
|
14
|
+
export declare function useStore(): import("zustand").UseBoundStore<RootState, import("zustand").StoreApi<RootState>>;
|
|
15
|
+
export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
|
|
16
|
+
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
17
|
+
export declare function useUpdate(callback: UpdateCallback, stage?: StageTypes): void;
|
|
18
|
+
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
19
|
+
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>;
|
|
20
|
+
export declare namespace useLoader {
|
|
21
|
+
var preload: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions | undefined) => undefined;
|
|
22
|
+
var clear: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U) => void;
|
|
23
|
+
}
|
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
/// <reference types="
|
|
2
|
-
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare const
|
|
14
|
-
declare
|
|
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
|
-
render
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
/// <reference types="webxr" />
|
|
2
|
+
/// <reference types="react-reconciler" />
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { StoreApi, UseBoundStore } from 'zustand';
|
|
6
|
+
import * as ReactThreeFiber from '../three-types';
|
|
7
|
+
import { Renderer, context, RootState, Size, Dpr, Performance, PrivateKeys, Frameloop } from './store';
|
|
8
|
+
import { extend, Root } from './renderer';
|
|
9
|
+
import { addEffect, addAfterEffect, addTail } from './loop';
|
|
10
|
+
import { EventManager, ComputeFunction } from './events';
|
|
11
|
+
import { dispose, getRootState, Camera } from './utils';
|
|
12
|
+
import { Stage } from './stages';
|
|
13
|
+
declare const roots: Map<Element, Root>;
|
|
14
|
+
declare const invalidate: (state?: RootState | undefined, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: XRFrame | undefined) => void;
|
|
15
|
+
declare const reconciler: import("react-reconciler").Reconciler<UseBoundStore<RootState, StoreApi<RootState>>, import("./renderer").Instance, void, import("./renderer").Instance, import("./renderer").Instance>, applyProps: typeof import("./utils").applyProps;
|
|
16
|
+
declare type Properties<T> = Pick<T, {
|
|
17
|
+
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
18
|
+
}[keyof T]>;
|
|
19
|
+
declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
20
|
+
export declare type RenderProps<TCanvas extends Element> = {
|
|
21
|
+
gl?: GLProps;
|
|
22
|
+
size?: Size;
|
|
23
|
+
shadows?: boolean | Partial<THREE.WebGLShadowMap>;
|
|
24
|
+
legacy?: boolean;
|
|
25
|
+
linear?: boolean;
|
|
26
|
+
flat?: boolean;
|
|
27
|
+
orthographic?: boolean;
|
|
28
|
+
frameloop?: Frameloop;
|
|
29
|
+
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
30
|
+
dpr?: Dpr;
|
|
31
|
+
raycaster?: Partial<THREE.Raycaster>;
|
|
32
|
+
camera?: (Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>) & {
|
|
33
|
+
manual?: boolean;
|
|
34
|
+
};
|
|
35
|
+
events?: (store: UseBoundStore<RootState>) => EventManager<HTMLElement>;
|
|
36
|
+
onCreated?: (state: RootState) => void;
|
|
37
|
+
onPointerMissed?: (event: MouseEvent) => void;
|
|
38
|
+
stages?: Stage[];
|
|
39
|
+
render?: 'auto' | 'manual';
|
|
40
|
+
};
|
|
41
|
+
export declare type ReconcilerRoot<TCanvas extends Element> = {
|
|
42
|
+
configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
|
|
43
|
+
render: (element: React.ReactNode) => UseBoundStore<RootState>;
|
|
44
|
+
unmount: () => void;
|
|
45
|
+
};
|
|
46
|
+
declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
47
|
+
declare function render<TCanvas extends Element>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
48
|
+
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
49
|
+
export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
50
|
+
events?: {
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
priority?: number;
|
|
53
|
+
compute?: ComputeFunction;
|
|
54
|
+
connected?: any;
|
|
55
|
+
};
|
|
56
|
+
size?: Size;
|
|
57
|
+
}>;
|
|
58
|
+
declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.ReactNode;
|
|
59
|
+
declare const act: any;
|
|
60
|
+
export * from './hooks';
|
|
61
|
+
export { context, render, createRoot, unmountComponentAtNode, createPortal, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, getRootState, act, roots as _roots, };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import { Root } from './renderer';
|
|
3
|
-
import { RootState } from './store';
|
|
4
|
-
declare type GlobalRenderCallback = (timeStamp: number) => void;
|
|
5
|
-
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
6
|
-
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
7
|
-
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
8
|
-
export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
|
|
9
|
-
loop: (timestamp: number) => void;
|
|
10
|
-
invalidate: (state?: RootState | undefined, frames?: number) => void;
|
|
11
|
-
advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?:
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
1
|
+
/// <reference types="webxr" />
|
|
2
|
+
import { Root } from './renderer';
|
|
3
|
+
import { RootState } from './store';
|
|
4
|
+
declare type GlobalRenderCallback = (timeStamp: number) => void;
|
|
5
|
+
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
6
|
+
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
7
|
+
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
8
|
+
export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
|
|
9
|
+
loop: (timestamp: number) => void;
|
|
10
|
+
invalidate: (state?: RootState | undefined, frames?: number) => void;
|
|
11
|
+
advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: XRFrame | undefined) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { UseBoundStore } 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: UseBoundStore<RootState>;
|
|
10
|
-
};
|
|
11
|
-
export declare type LocalState = {
|
|
12
|
-
type: string;
|
|
13
|
-
root: UseBoundStore<RootState>;
|
|
14
|
-
objects: Instance[];
|
|
15
|
-
parent: Instance | null;
|
|
16
|
-
primitive?: boolean;
|
|
17
|
-
eventCount: number;
|
|
18
|
-
handlers: Partial<EventHandlers>;
|
|
19
|
-
attach?: AttachType;
|
|
20
|
-
previousAttach: any;
|
|
21
|
-
memoizedProps: {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export declare type AttachFnType = (parent: Instance, self: Instance) => () => void;
|
|
26
|
-
export declare type AttachType = string | AttachFnType;
|
|
27
|
-
export declare type BaseInstance = Omit<THREE.Object3D, 'children' | 'attach' | 'add' | 'remove' | 'raycast'> & {
|
|
28
|
-
__r3f: LocalState;
|
|
29
|
-
children: Instance[];
|
|
30
|
-
remove: (...object: Instance[]) => Instance;
|
|
31
|
-
add: (...object: Instance[]) => Instance;
|
|
32
|
-
raycast?: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
33
|
-
};
|
|
34
|
-
export declare type Instance = BaseInstance & {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
};
|
|
37
|
-
export declare type InstanceProps = {
|
|
38
|
-
[key: string]: unknown;
|
|
39
|
-
} & {
|
|
40
|
-
args?: any[];
|
|
41
|
-
object?: object;
|
|
42
|
-
visible?: boolean;
|
|
43
|
-
dispose?: null;
|
|
44
|
-
attach?: AttachType;
|
|
45
|
-
};
|
|
46
|
-
declare let extend: (objects: object) => void;
|
|
47
|
-
declare function createRenderer<TCanvas>(_roots: Map<TCanvas, Root>, _getEventPriority?: () => any): {
|
|
48
|
-
reconciler: Reconciler.Reconciler<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>, Instance,
|
|
49
|
-
applyProps: typeof applyProps;
|
|
50
|
-
};
|
|
51
|
-
export { prepare, createRenderer, extend };
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { UseBoundStore } 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: UseBoundStore<RootState>;
|
|
10
|
+
};
|
|
11
|
+
export declare type LocalState = {
|
|
12
|
+
type: string;
|
|
13
|
+
root: UseBoundStore<RootState>;
|
|
14
|
+
objects: Instance[];
|
|
15
|
+
parent: Instance | null;
|
|
16
|
+
primitive?: boolean;
|
|
17
|
+
eventCount: number;
|
|
18
|
+
handlers: Partial<EventHandlers>;
|
|
19
|
+
attach?: AttachType;
|
|
20
|
+
previousAttach: any;
|
|
21
|
+
memoizedProps: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare type AttachFnType = (parent: Instance, self: Instance) => () => void;
|
|
26
|
+
export declare type AttachType = string | AttachFnType;
|
|
27
|
+
export declare type BaseInstance = Omit<THREE.Object3D, 'children' | 'attach' | 'add' | 'remove' | 'raycast'> & {
|
|
28
|
+
__r3f: LocalState;
|
|
29
|
+
children: Instance[];
|
|
30
|
+
remove: (...object: Instance[]) => Instance;
|
|
31
|
+
add: (...object: Instance[]) => Instance;
|
|
32
|
+
raycast?: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
33
|
+
};
|
|
34
|
+
export declare type Instance = BaseInstance & {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
export declare type InstanceProps = {
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
} & {
|
|
40
|
+
args?: any[];
|
|
41
|
+
object?: object;
|
|
42
|
+
visible?: boolean;
|
|
43
|
+
dispose?: null;
|
|
44
|
+
attach?: AttachType;
|
|
45
|
+
};
|
|
46
|
+
declare let extend: (objects: object) => void;
|
|
47
|
+
declare function createRenderer<TCanvas>(_roots: Map<TCanvas, Root>, _getEventPriority?: () => any): {
|
|
48
|
+
reconciler: Reconciler.Reconciler<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>, Instance, void, Instance, Instance>;
|
|
49
|
+
applyProps: typeof applyProps;
|
|
50
|
+
};
|
|
51
|
+
export { prepare, createRenderer, extend };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="webxr" />
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
3
|
+
import { StoreApi, UseBoundStore } from 'zustand';
|
|
4
|
+
import { RootState } from './store';
|
|
5
|
+
export interface UpdateCallback {
|
|
6
|
+
(state: RootState, delta: number, frame?: XRFrame): void;
|
|
7
|
+
}
|
|
8
|
+
export declare type UpdateCallbackRef = MutableRefObject<UpdateCallback>;
|
|
9
|
+
declare type Store = UseBoundStore<RootState, StoreApi<RootState>>;
|
|
10
|
+
export declare type UpdateSubscription = {
|
|
11
|
+
ref: UpdateCallbackRef;
|
|
12
|
+
store: Store;
|
|
13
|
+
};
|
|
14
|
+
export declare type FixedStageOptions = {
|
|
15
|
+
fixedStep?: number;
|
|
16
|
+
maxSubsteps?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare type FixedStageProps = {
|
|
19
|
+
fixedStep: number;
|
|
20
|
+
maxSubsteps: number;
|
|
21
|
+
accumulator: number;
|
|
22
|
+
alpha: number;
|
|
23
|
+
};
|
|
24
|
+
export declare class Stage {
|
|
25
|
+
private subscribers;
|
|
26
|
+
private _frameTime;
|
|
27
|
+
constructor();
|
|
28
|
+
frame(delta: number, frame?: XRFrame): void;
|
|
29
|
+
add(ref: UpdateCallbackRef, store: Store): () => void;
|
|
30
|
+
get frameTime(): number;
|
|
31
|
+
}
|
|
32
|
+
export declare class FixedStage extends Stage {
|
|
33
|
+
private _fixedStep;
|
|
34
|
+
private _maxSubsteps;
|
|
35
|
+
private _accumulator;
|
|
36
|
+
private _alpha;
|
|
37
|
+
private _fixedFrameTime;
|
|
38
|
+
private _substepTimes;
|
|
39
|
+
constructor(fixedStep?: number, maxSubSteps?: number);
|
|
40
|
+
frame(delta: number, frame?: XRFrame): void;
|
|
41
|
+
get frameTime(): number;
|
|
42
|
+
get substepTimes(): number[];
|
|
43
|
+
get fixedStep(): number;
|
|
44
|
+
set fixedStep(fixedStep: number);
|
|
45
|
+
get maxSubsteps(): number;
|
|
46
|
+
set maxSubsteps(maxSubsteps: number);
|
|
47
|
+
get accumulator(): number;
|
|
48
|
+
get alpha(): number;
|
|
49
|
+
}
|
|
50
|
+
export declare const Stages: {
|
|
51
|
+
Early: Stage;
|
|
52
|
+
Fixed: FixedStage;
|
|
53
|
+
Update: Stage;
|
|
54
|
+
Late: Stage;
|
|
55
|
+
Render: Stage;
|
|
56
|
+
After: Stage;
|
|
57
|
+
};
|
|
58
|
+
export declare const Lifecycle: Stage[];
|
|
59
|
+
export {};
|