@react-three/fiber 9.0.0-alpha.1 → 9.0.0-alpha.2
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 +78 -0
- package/dist/declarations/src/core/hooks.d.ts +3 -0
- package/dist/declarations/src/core/index.d.ts +8 -9
- package/dist/declarations/src/core/loop.d.ts +2 -0
- package/dist/declarations/src/core/renderer.d.ts +30 -41
- package/dist/declarations/src/core/store.d.ts +1 -2
- package/dist/declarations/src/core/utils.d.ts +27 -28
- package/dist/declarations/src/index.d.ts +1 -3
- package/dist/declarations/src/native.d.ts +1 -3
- package/dist/declarations/src/three-types.d.ts +34 -318
- package/dist/declarations/src/web/Canvas.d.ts +2 -0
- package/dist/{index-a9c7a6cd.esm.js → index-47b7622a.esm.js} +792 -860
- package/dist/{index-65e750e4.cjs.dev.js → index-5bd4d3cf.cjs.dev.js} +793 -860
- package/dist/{index-2e1b7052.cjs.prod.js → index-8128f248.cjs.prod.js} +793 -860
- package/dist/react-three-fiber.cjs.dev.js +39 -11
- package/dist/react-three-fiber.cjs.prod.js +39 -11
- package/dist/react-three-fiber.esm.js +39 -11
- package/native/dist/react-three-fiber-native.cjs.dev.js +17 -9
- package/native/dist/react-three-fiber-native.cjs.prod.js +17 -9
- package/native/dist/react-three-fiber-native.esm.js +17 -9
- package/package.json +2 -1
- package/readme.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# @react-three/fiber
|
|
2
2
|
|
|
3
|
+
## 8.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 370d3ae5: refactor: pull context bridge from its-fine
|
|
8
|
+
|
|
9
|
+
## 8.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 46d8b440: bridge cross-container context
|
|
14
|
+
|
|
15
|
+
## 8.7.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 259c8895: fix: use self to get global context before window
|
|
20
|
+
|
|
21
|
+
## 8.7.3
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- eb5a3be4: fix: if there is an eventsource pointerevent will be set to none
|
|
26
|
+
|
|
27
|
+
## 8.7.2
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 7f801e60: fix: events in portals carry the wrong raycaster, camera, etc
|
|
32
|
+
|
|
33
|
+
## 8.7.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 962cc270: fix: allow canvas eventsource to be a ref
|
|
38
|
+
|
|
39
|
+
## 8.7.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- f5db1b78: feat: useInstanceHandle, flushGlobalEffects
|
|
44
|
+
|
|
45
|
+
## 8.6.2
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- 57c12e9c: fix(types): @react-three/drei declaration files
|
|
50
|
+
|
|
51
|
+
## 8.6.1
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 7a0b5670: fix(core): don't append to unmounted containers
|
|
56
|
+
|
|
57
|
+
## 8.6.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 85c80e70: eventsource and eventprefix on the canvas component
|
|
62
|
+
|
|
63
|
+
## 8.5.1
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 87821d9: fix: null-check instance.children on reconstruct
|
|
68
|
+
|
|
69
|
+
## 8.5.0
|
|
70
|
+
|
|
71
|
+
### Minor Changes
|
|
72
|
+
|
|
73
|
+
- edc8252: feat: handle primitive children, auto-attach via instanceof
|
|
74
|
+
|
|
75
|
+
## 8.3.1
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- aaeb2b8: fix(types): accept readonly arrays for vector props
|
|
80
|
+
|
|
3
81
|
## 8.3.0
|
|
4
82
|
|
|
5
83
|
### Minor Changes
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { StateSelector, EqualityChecker } from 'zustand';
|
|
3
4
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
4
5
|
import { RootState, RenderCallback, StageTypes } from './store';
|
|
5
6
|
import { ObjectMap } from './utils';
|
|
6
7
|
import { UpdateCallback } from './stages';
|
|
7
8
|
import { LoadingManager } from 'three';
|
|
9
|
+
import { Instance } from './renderer';
|
|
8
10
|
export interface Loader<T> extends THREE.Loader {
|
|
9
11
|
load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown;
|
|
10
12
|
}
|
|
@@ -12,6 +14,7 @@ export declare type Extensions = (loader: THREE.Loader) => void;
|
|
|
12
14
|
export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
|
|
13
15
|
export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
14
16
|
export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
|
|
17
|
+
export declare function useInstanceHandle<O>(ref: React.MutableRefObject<O>): React.MutableRefObject<Instance>;
|
|
15
18
|
export declare function useStore(): import("zustand").UseBoundStore<RootState, import("zustand").StoreApi<RootState>>;
|
|
16
19
|
export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
|
|
17
20
|
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/// <reference types="webxr" />
|
|
2
|
-
/// <reference types="react-reconciler" />
|
|
3
2
|
import * as THREE from 'three';
|
|
4
3
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
4
|
+
import { UseBoundStore } from 'zustand';
|
|
5
|
+
import { ThreeElement } from '../three-types';
|
|
7
6
|
import { Renderer, context, RootState, Size, Dpr, Performance, PrivateKeys, Frameloop } from './store';
|
|
8
|
-
import { extend, Root } from './renderer';
|
|
7
|
+
import { reconciler, extend, Root } from './renderer';
|
|
9
8
|
import { addEffect, addAfterEffect, addTail } from './loop';
|
|
10
9
|
import { EventManager, ComputeFunction } from './events';
|
|
11
|
-
import { dispose, getRootState, Camera } from './utils';
|
|
10
|
+
import { dispose, getRootState, Camera, applyProps } from './utils';
|
|
12
11
|
import { Stage } from './stages';
|
|
13
12
|
declare const roots: Map<Element, Root>;
|
|
14
13
|
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
14
|
declare type Properties<T> = Pick<T, {
|
|
17
15
|
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
18
16
|
}[keyof T]>;
|
|
@@ -29,7 +27,7 @@ export declare type RenderProps<TCanvas extends Element> = {
|
|
|
29
27
|
performance?: Partial<Omit<Performance, 'regress'>>;
|
|
30
28
|
dpr?: Dpr;
|
|
31
29
|
raycaster?: Partial<THREE.Raycaster>;
|
|
32
|
-
camera?: (Camera | Partial<
|
|
30
|
+
camera?: (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
|
|
33
31
|
manual?: boolean;
|
|
34
32
|
};
|
|
35
33
|
events?: (store: UseBoundStore<RootState>) => EventManager<HTMLElement>;
|
|
@@ -56,6 +54,7 @@ export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
|
56
54
|
size?: Size;
|
|
57
55
|
}>;
|
|
58
56
|
declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.ReactNode;
|
|
59
|
-
declare
|
|
57
|
+
declare type Act = <T = any>(cb: () => Promise<T>) => Promise<T>;
|
|
58
|
+
declare const act: Act;
|
|
60
59
|
export * from './hooks';
|
|
61
|
-
export { context, render, createRoot, unmountComponentAtNode, createPortal, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, getRootState, act, roots as _roots, };
|
|
60
|
+
export { context, render, createRoot, unmountComponentAtNode, createPortal, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, getRootState, Act, act, roots as _roots, };
|
|
@@ -5,6 +5,8 @@ declare type GlobalRenderCallback = (timeStamp: number) => void;
|
|
|
5
5
|
export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
|
|
6
6
|
export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
|
|
7
7
|
export declare const addTail: (callback: GlobalRenderCallback) => () => void;
|
|
8
|
+
export declare type GlobalEffectType = 'before' | 'after' | 'tail';
|
|
9
|
+
export declare function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
|
|
8
10
|
export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
|
|
9
11
|
loop: (timestamp: number) => void;
|
|
10
12
|
invalidate: (state?: RootState | undefined, frames?: number) => void;
|
|
@@ -1,51 +1,40 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
1
|
import { UseBoundStore } from 'zustand';
|
|
3
2
|
import Reconciler from 'react-reconciler';
|
|
4
|
-
import { prepare, applyProps } from './utils';
|
|
5
3
|
import { RootState } from './store';
|
|
6
4
|
import { EventHandlers } from './events';
|
|
7
|
-
export
|
|
5
|
+
export interface Root {
|
|
8
6
|
fiber: Reconciler.FiberRoot;
|
|
9
7
|
store: UseBoundStore<RootState>;
|
|
10
|
-
}
|
|
11
|
-
export declare type
|
|
12
|
-
|
|
8
|
+
}
|
|
9
|
+
export declare type AttachFnType<O = any> = (parent: any, self: O) => () => void;
|
|
10
|
+
export declare type AttachType<O = any> = string | AttachFnType<O>;
|
|
11
|
+
export declare type ConstructorRepresentation = new (...args: any[]) => any;
|
|
12
|
+
export interface Catalogue {
|
|
13
|
+
[name: string]: ConstructorRepresentation;
|
|
14
|
+
}
|
|
15
|
+
export declare type Args<T> = T extends ConstructorRepresentation ? ConstructorParameters<T> : any[];
|
|
16
|
+
export interface InstanceProps<T = any> {
|
|
17
|
+
args?: Args<T>;
|
|
18
|
+
object?: T;
|
|
19
|
+
visible?: boolean;
|
|
20
|
+
dispose?: null;
|
|
21
|
+
attach?: AttachType<T>;
|
|
22
|
+
}
|
|
23
|
+
export interface Instance<O = any> {
|
|
13
24
|
root: UseBoundStore<RootState>;
|
|
14
|
-
|
|
25
|
+
type: string;
|
|
15
26
|
parent: Instance | null;
|
|
16
|
-
|
|
27
|
+
children: Instance[];
|
|
28
|
+
props: InstanceProps<O> & Record<string, unknown>;
|
|
29
|
+
object: O & {
|
|
30
|
+
__r3f?: Instance<O>;
|
|
31
|
+
};
|
|
17
32
|
eventCount: number;
|
|
18
33
|
handlers: Partial<EventHandlers>;
|
|
19
|
-
attach?: AttachType
|
|
20
|
-
previousAttach
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export
|
|
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 };
|
|
34
|
+
attach?: AttachType<O>;
|
|
35
|
+
previousAttach?: any;
|
|
36
|
+
isHidden: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare const extend: (objects: Partial<Catalogue>) => void;
|
|
39
|
+
declare const reconciler: Reconciler.Reconciler<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>, Instance<any>, void, Instance<any>, any>;
|
|
40
|
+
export { extend, reconciler };
|
|
@@ -21,7 +21,6 @@ export declare type Size = {
|
|
|
21
21
|
height: number;
|
|
22
22
|
top: number;
|
|
23
23
|
left: number;
|
|
24
|
-
updateStyle?: boolean;
|
|
25
24
|
};
|
|
26
25
|
export declare type Viewport = Size & {
|
|
27
26
|
initialDpr: number;
|
|
@@ -98,7 +97,7 @@ export declare type RootState = {
|
|
|
98
97
|
invalidate: (frames?: number) => void;
|
|
99
98
|
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
100
99
|
setEvents: (events: Partial<EventManager<any>>) => void;
|
|
101
|
-
setSize: (width: number, height: number,
|
|
100
|
+
setSize: (width: number, height: number, top?: number, left?: number) => void;
|
|
102
101
|
setDpr: (dpr: Dpr) => void;
|
|
103
102
|
setFrameloop: (frameloop: Frameloop) => void;
|
|
104
103
|
onPointerMissed?: (event: MouseEvent) => void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { Fiber } from 'react-reconciler';
|
|
4
|
+
import type { UseBoundStore } from 'zustand';
|
|
5
|
+
import type { Dpr, RootState, Size } from './store';
|
|
6
|
+
import type { Instance } from './renderer';
|
|
5
7
|
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
6
8
|
export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
|
|
9
|
+
export declare const isRef: (obj: any) => obj is React.MutableRefObject<unknown>;
|
|
7
10
|
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
|
|
8
11
|
export declare function useMutableCallback<T>(fn: T): React.MutableRefObject<T>;
|
|
9
12
|
export declare type SetBlock = false | Promise<null> | null;
|
|
@@ -27,32 +30,21 @@ export declare class ErrorBoundary extends React.Component<{
|
|
|
27
30
|
componentDidCatch(err: Error): void;
|
|
28
31
|
render(): React.ReactNode;
|
|
29
32
|
}
|
|
30
|
-
export
|
|
31
|
-
export declare type DiffSet = {
|
|
32
|
-
memoized: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
changes: [key: string, value: unknown, isEvent: boolean, keys: string[]][];
|
|
36
|
-
};
|
|
37
|
-
export declare const isDiffSet: (def: any) => def is DiffSet;
|
|
38
|
-
export declare type ClassConstructor = {
|
|
39
|
-
new (): void;
|
|
40
|
-
};
|
|
41
|
-
export declare type ObjectMap = {
|
|
33
|
+
export interface ObjectMap {
|
|
42
34
|
nodes: {
|
|
43
35
|
[name: string]: THREE.Object3D;
|
|
44
36
|
};
|
|
45
37
|
materials: {
|
|
46
38
|
[name: string]: THREE.Material;
|
|
47
39
|
};
|
|
48
|
-
}
|
|
40
|
+
}
|
|
49
41
|
export declare function calculateDpr(dpr: Dpr): number;
|
|
50
|
-
export declare const getRootState: (obj:
|
|
51
|
-
export
|
|
42
|
+
export declare const getRootState: <T = THREE.Object3D<THREE.Event>>(obj: T) => RootState | undefined;
|
|
43
|
+
export interface EquConfig {
|
|
52
44
|
arrays?: 'reference' | 'shallow';
|
|
53
45
|
objects?: 'reference' | 'shallow';
|
|
54
46
|
strict?: boolean;
|
|
55
|
-
}
|
|
47
|
+
}
|
|
56
48
|
export declare const is: {
|
|
57
49
|
obj: (a: any) => boolean;
|
|
58
50
|
fun: (a: any) => a is Function;
|
|
@@ -64,18 +56,25 @@ export declare const is: {
|
|
|
64
56
|
equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
|
|
65
57
|
};
|
|
66
58
|
export declare function buildGraph(object: THREE.Object3D): ObjectMap;
|
|
67
|
-
export
|
|
68
|
-
dispose?: () => void;
|
|
59
|
+
export interface Disposable {
|
|
69
60
|
type?: string;
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
export declare function
|
|
73
|
-
export declare
|
|
74
|
-
export declare function
|
|
75
|
-
export declare function
|
|
76
|
-
export declare function
|
|
61
|
+
dispose?: () => void;
|
|
62
|
+
}
|
|
63
|
+
export declare function dispose<T extends Disposable>(obj: T): void;
|
|
64
|
+
export declare const REACT_INTERNAL_PROPS: string[];
|
|
65
|
+
export declare function getInstanceProps<T = any>(queue: Fiber['pendingProps']): Instance<T>['props'];
|
|
66
|
+
export declare function prepare<T = any>(target: T, root: UseBoundStore<RootState>, type: string, props: Instance<T>['props']): Instance<T>;
|
|
67
|
+
export declare function resolve(root: any, key: string): {
|
|
68
|
+
root: any;
|
|
69
|
+
key: string;
|
|
70
|
+
target: any;
|
|
71
|
+
};
|
|
72
|
+
export declare function attach(parent: Instance, child: Instance): void;
|
|
73
|
+
export declare function detach(parent: Instance, child: Instance): void;
|
|
74
|
+
export declare const RESERVED_PROPS: string[];
|
|
75
|
+
export declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props'], resetRemoved?: boolean): Instance<T>['props'];
|
|
76
|
+
export declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
|
|
77
77
|
export declare function invalidateInstance(instance: Instance): void;
|
|
78
|
-
export declare function updateInstance(instance: Instance): void;
|
|
79
78
|
export declare function updateCamera(camera: Camera & {
|
|
80
79
|
manual?: boolean;
|
|
81
80
|
}, size: Size): void;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './three-types';
|
|
2
|
-
|
|
3
|
-
export { ReactThreeFiber };
|
|
4
|
-
export type { BaseInstance, LocalState } from './core/renderer';
|
|
2
|
+
export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from './core/renderer';
|
|
5
3
|
export type { Intersection, Subscription, Dpr, Size, Viewport, RenderCallback, Performance, RootState, } from './core/store';
|
|
6
4
|
export type { ThreeEvent, Events, EventManager, ComputeFunction } from './core/events';
|
|
7
5
|
export type { ObjectMap, Camera } from './core/utils';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './three-types';
|
|
2
|
-
|
|
3
|
-
export { ReactThreeFiber };
|
|
4
|
-
export type { BaseInstance, LocalState } from './core/renderer';
|
|
2
|
+
export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from './core/renderer';
|
|
5
3
|
export type { Intersection, Subscription, Dpr, Size, Viewport, RenderCallback, Performance, RootState, } from './core/store';
|
|
6
4
|
export type { ThreeEvent, Events, EventManager, ComputeFunction } from './core/events';
|
|
7
5
|
export type { ObjectMap, Camera } from './core/utils';
|