@react-three/fiber 8.0.0-beta.0 → 8.0.0-beta.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.
@@ -10,7 +10,7 @@ export declare type Extensions = (loader: THREE.Loader) => void;
10
10
  export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
11
11
  export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
12
12
  export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
13
- export declare function useStore(): import("zustand").UseStore<RootState>;
13
+ export declare function useStore(): import("zustand").UseStore<RootState, import("zustand").StoreApi<RootState>>;
14
14
  export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
15
15
  export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
16
16
  export declare function useGraph(object: THREE.Object3D): ObjectMap;
@@ -2,14 +2,14 @@
2
2
  import * as THREE from 'three';
3
3
  import * as React from 'react';
4
4
  import { UseStore } from 'zustand';
5
- import { dispose } from '../core/utils';
6
- import { Renderer, StoreProps, context, RootState, Size } from '../core/store';
7
- import { extend, Root } from '../core/renderer';
8
- import { addEffect, addAfterEffect, addTail } from '../core/loop';
5
+ import { Renderer, StoreProps, context, RootState, Size } from './store';
6
+ import { extend, Root } from './renderer';
7
+ import { addEffect, addAfterEffect, addTail } from './loop';
9
8
  import { EventManager } from './events';
9
+ import { dispose } from './utils';
10
10
  declare const roots: Map<Element, Root>;
11
11
  declare const invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
12
- declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: typeof import("../core/utils").applyProps;
12
+ declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: typeof import("./utils").applyProps;
13
13
  declare type Properties<T> = Pick<T, {
14
14
  [K in keyof T]: T[K] extends (_: any) => any ? never : K;
15
15
  }[keyof T]>;
@@ -20,10 +20,12 @@ export declare type RenderProps<TCanvas extends Element> = Omit<StoreProps, 'gl'
20
20
  size?: Size;
21
21
  onCreated?: (state: RootState) => void;
22
22
  };
23
- declare function createRoot<TCanvas extends Element>(canvas: TCanvas, config?: RenderProps<TCanvas>): {
23
+ export declare type ReconcilerRoot<TCanvas extends Element> = {
24
+ configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
24
25
  render: (element: React.ReactNode) => UseStore<RootState>;
25
26
  unmount: () => void;
26
27
  };
28
+ declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
27
29
  declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, config?: RenderProps<TCanvas>): UseStore<RootState>;
28
30
  declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
29
31
  declare const act: any;
@@ -6,7 +6,7 @@ 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
8
  export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
9
- loop: (timestamp: number) => number | undefined;
9
+ loop: (timestamp: number) => void;
10
10
  invalidate: (state?: RootState | undefined) => void;
11
11
  advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
12
12
  };
@@ -2,7 +2,6 @@ import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import * as ReactThreeFiber from '../three-types';
4
4
  import { GetState, SetState, UseStore } from 'zustand';
5
- import { Instance, InstanceProps } from './renderer';
6
5
  import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
7
6
  export interface Intersection extends THREE.Intersection {
8
7
  eventObject: THREE.Object3D;
@@ -40,13 +39,12 @@ export declare type Performance = {
40
39
  export declare type Renderer = {
41
40
  render: (scene: THREE.Scene, camera: THREE.Camera) => any;
42
41
  };
43
- export declare const isRenderer: (def: Renderer) => boolean;
44
- export declare const isOrthographicCamera: (def: THREE.Camera) => def is THREE.OrthographicCamera;
42
+ export declare const isRenderer: (def: any) => boolean;
43
+ export declare const isOrthographicCamera: (def: any) => def is THREE.OrthographicCamera;
45
44
  export declare type InternalState = {
46
45
  active: boolean;
47
46
  priority: number;
48
47
  frames: number;
49
- lastProps: StoreProps;
50
48
  lastEvent: React.MutableRefObject<DomEvent | null>;
51
49
  interaction: THREE.Object3D[];
52
50
  hovered: Map<string, ThreeEvent<DomEvent>>;
@@ -54,20 +52,21 @@ export declare type InternalState = {
54
52
  capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
55
53
  initialClick: [x: number, y: number];
56
54
  initialHits: THREE.Object3D[];
57
- xr: {
58
- connect: () => void;
59
- disconnect: () => void;
60
- };
61
55
  subscribe: (callback: React.MutableRefObject<RenderCallback>, priority?: number) => () => void;
62
56
  };
63
57
  export declare type RootState = {
64
58
  gl: THREE.WebGLRenderer;
65
- scene: THREE.Scene;
66
59
  camera: Camera & {
67
60
  manual?: boolean;
68
61
  };
69
- controls: THREE.EventDispatcher | null;
70
62
  raycaster: Raycaster;
63
+ events: EventManager<any>;
64
+ xr: {
65
+ connect: () => void;
66
+ disconnect: () => void;
67
+ };
68
+ scene: THREE.Scene;
69
+ controls: THREE.EventDispatcher | null;
71
70
  mouse: THREE.Vector2;
72
71
  clock: THREE.Clock;
73
72
  linear: boolean;
@@ -86,7 +85,6 @@ export declare type RootState = {
86
85
  setDpr: (dpr: Dpr) => void;
87
86
  setFrameloop: (frameloop?: 'always' | 'demand' | 'never') => void;
88
87
  onPointerMissed?: (event: MouseEvent) => void;
89
- events: EventManager<any>;
90
88
  internal: InternalState;
91
89
  };
92
90
  export declare type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
@@ -106,14 +104,12 @@ export declare type StoreProps = {
106
104
  frameloop?: 'always' | 'demand' | 'never';
107
105
  performance?: Partial<Omit<Performance, 'regress'>>;
108
106
  dpr?: Dpr;
109
- clock?: THREE.Clock;
110
107
  raycaster?: Partial<Raycaster>;
111
108
  camera?: (Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>) & {
112
109
  manual?: boolean;
113
110
  };
114
111
  onPointerMissed?: (event: MouseEvent) => void;
115
112
  };
116
- export declare type ApplyProps = (instance: Instance, newProps: InstanceProps) => void;
117
- declare const context: React.Context<UseStore<RootState>>;
118
- declare const createStore: (applyProps: ApplyProps, invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void, props: StoreProps) => UseStore<RootState>;
113
+ declare const context: React.Context<UseStore<RootState, import("zustand").StoreApi<RootState>>>;
114
+ declare const createStore: (invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseStore<RootState>;
119
115
  export { createStore, context };
@@ -26,14 +26,20 @@ export declare function filterKeys<TObj extends {
26
26
  }, TOmit extends boolean, TKey extends keyof TObj>(obj: TObj, omit: TOmit, ...keys: TKey[]): TOmit extends true ? Omit<TObj, TKey> : Pick<TObj, TKey>;
27
27
  export declare const pick: <TObj>(obj: Partial<TObj>, keys: (keyof TObj)[]) => Pick<Partial<TObj>, keyof TObj>;
28
28
  export declare const omit: <TObj>(obj: Partial<TObj>, keys: (keyof TObj)[]) => Omit<Partial<TObj>, keyof TObj>;
29
+ export declare type EquConfig = {
30
+ arrays?: 'reference' | 'shallow';
31
+ objects?: 'reference' | 'shallow';
32
+ strict?: boolean;
33
+ };
29
34
  export declare const is: {
30
35
  obj: (a: any) => boolean;
31
36
  fun: (a: any) => a is Function;
32
37
  str: (a: any) => a is string;
33
38
  num: (a: any) => a is number;
39
+ boo: (a: any) => a is boolean;
34
40
  und: (a: any) => boolean;
35
41
  arr: (a: any) => boolean;
36
- equ(a: any, b: any): boolean;
42
+ equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
37
43
  };
38
44
  export declare function buildGraph(object: THREE.Object3D): ObjectMap;
39
45
  export declare function dispose<TObj extends {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import * as THREE from 'three';
2
3
  import { EventHandlers } from './core/events';
3
4
  import { AttachType } from './core/renderer';
@@ -41,6 +42,7 @@ export declare type Object3DNode<T, P> = Overwrite<Node<T, P>, {
41
42
  export declare type BufferGeometryNode<T extends THREE.BufferGeometry, P> = Node<T, P>;
42
43
  export declare type MaterialNode<T extends THREE.Material, P> = Node<T, P>;
43
44
  export declare type LightNode<T extends THREE.Light, P> = Object3DNode<T, P>;
45
+ export declare type Object3DProps = Object3DNode<THREE.Object3D, typeof THREE.Object3D>;
44
46
  export declare type AudioListenerProps = Object3DNode<THREE.AudioListener, typeof THREE.AudioListener>;
45
47
  export declare type PositionalAudioProps = Object3DNode<THREE.PositionalAudio, typeof THREE.PositionalAudio>;
46
48
  export declare type MeshProps = Object3DNode<THREE.Mesh, typeof THREE.Mesh>;
@@ -166,7 +168,15 @@ export declare type Matrix3Props = Node<THREE.Matrix3, typeof THREE.Matrix3>;
166
168
  export declare type Matrix4Props = Node<THREE.Matrix4, typeof THREE.Matrix4>;
167
169
  export declare type QuaternionProps = Node<THREE.Quaternion, typeof THREE.Quaternion>;
168
170
  export declare type BufferAttributeProps = Node<THREE.BufferAttribute, typeof THREE.BufferAttribute>;
171
+ export declare type Float16BufferAttributeProps = Node<THREE.Float16BufferAttribute, typeof THREE.Float16BufferAttribute>;
169
172
  export declare type Float32BufferAttributeProps = Node<THREE.Float32BufferAttribute, typeof THREE.Float32BufferAttribute>;
173
+ export declare type Float64BufferAttributeProps = Node<THREE.Float64BufferAttribute, typeof THREE.Float64BufferAttribute>;
174
+ export declare type Int8BufferAttributeProps = Node<THREE.Int8BufferAttribute, typeof THREE.Int8BufferAttribute>;
175
+ export declare type Int16BufferAttributeProps = Node<THREE.Int16BufferAttribute, typeof THREE.Int16BufferAttribute>;
176
+ export declare type Int32BufferAttributeProps = Node<THREE.Int32BufferAttribute, typeof THREE.Int32BufferAttribute>;
177
+ export declare type Uint8BufferAttributeProps = Node<THREE.Uint8BufferAttribute, typeof THREE.Uint8BufferAttribute>;
178
+ export declare type Uint16BufferAttributeProps = Node<THREE.Uint16BufferAttribute, typeof THREE.Uint16BufferAttribute>;
179
+ export declare type Uint32BufferAttributeProps = Node<THREE.Uint32BufferAttribute, typeof THREE.Uint32BufferAttribute>;
170
180
  export declare type InstancedBufferAttributeProps = Node<THREE.InstancedBufferAttribute, typeof THREE.InstancedBufferAttribute>;
171
181
  export declare type ColorProps = Node<THREE.Color, ColorArray>;
172
182
  export declare type FogProps = Node<THREE.Fog, typeof THREE.Fog>;
@@ -175,6 +185,7 @@ export declare type ShapeProps = Node<THREE.Shape, typeof THREE.Shape>;
175
185
  declare global {
176
186
  namespace JSX {
177
187
  interface IntrinsicElements {
188
+ object3D: Object3DProps;
178
189
  audioListener: AudioListenerProps;
179
190
  positionalAudio: PositionalAudioProps;
180
191
  mesh: MeshProps;
@@ -296,7 +307,15 @@ declare global {
296
307
  matrix4: Matrix4Props;
297
308
  quaternion: QuaternionProps;
298
309
  bufferAttribute: BufferAttributeProps;
310
+ float16BufferAttribute: Float16BufferAttributeProps;
299
311
  float32BufferAttribute: Float32BufferAttributeProps;
312
+ float64BufferAttribute: Float64BufferAttributeProps;
313
+ int8BufferAttribute: Int8BufferAttributeProps;
314
+ int16BufferAttribute: Int16BufferAttributeProps;
315
+ int32BufferAttribute: Int32BufferAttributeProps;
316
+ uint8BufferAttribute: Uint8BufferAttributeProps;
317
+ uint16BufferAttribute: Uint16BufferAttributeProps;
318
+ uint32BufferAttribute: Uint32BufferAttributeProps;
300
319
  instancedBufferAttribute: InstancedBufferAttributeProps;
301
320
  color: ColorProps;
302
321
  fog: FogProps;