@react-three/fiber 8.15.4 → 8.15.6

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.15.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bb2950b: experiment: stable object sort
8
+
9
+ ## 8.15.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 0e44fd8b: fix(types): preserve deprecated JSX annotations
14
+
3
15
  ## 8.15.4
4
16
 
5
17
  ### Patch Changes
@@ -3,18 +3,29 @@ import type { UseBoundStore } from 'zustand';
3
3
  import type { RootState } from './store';
4
4
  import type { Properties } from '../three-types';
5
5
  export interface Intersection extends THREE.Intersection {
6
+ /** The event source (the object which registered the handler) */
6
7
  eventObject: THREE.Object3D;
7
8
  }
8
9
  export interface IntersectionEvent<TSourceEvent> extends Intersection {
10
+ /** The event source (the object which registered the handler) */
9
11
  eventObject: THREE.Object3D;
12
+ /** An array of intersections */
10
13
  intersections: Intersection[];
14
+ /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
11
15
  unprojectedPoint: THREE.Vector3;
16
+ /** Normalized event coordinates */
12
17
  pointer: THREE.Vector2;
18
+ /** Delta between first click and this event */
13
19
  delta: number;
20
+ /** The ray that pierced it */
14
21
  ray: THREE.Ray;
22
+ /** The camera that was used by the raycaster */
15
23
  camera: Camera;
24
+ /** stopPropagation will stop underlying handlers from firing */
16
25
  stopPropagation: () => void;
26
+ /** The original host event */
17
27
  nativeEvent: TSourceEvent;
28
+ /** If the event was stopped by calling stopPropagation */
18
29
  stopped: boolean;
19
30
  }
20
31
  export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
@@ -50,14 +61,25 @@ export declare type EventHandlers = {
50
61
  export declare type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
51
62
  export declare type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
52
63
  export interface EventManager<TTarget> {
64
+ /** Determines if the event layer is active */
53
65
  enabled: boolean;
66
+ /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
54
67
  priority: number;
68
+ /** The compute function needs to set up the raycaster and an xy- pointer */
55
69
  compute?: ComputeFunction;
70
+ /** The filter can re-order or re-structure the intersections */
56
71
  filter?: FilterFunction;
72
+ /** The target node the event layer is tied to */
57
73
  connected?: TTarget;
74
+ /** All the pointer event handlers through which the host forwards native events */
58
75
  handlers?: Events;
76
+ /** Allows re-connecting to another target */
59
77
  connect?: (target: TTarget) => void;
78
+ /** Removes all existing events handlers from the target */
60
79
  disconnect?: () => void;
80
+ /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
81
+ * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
82
+ */
61
83
  update?: () => void;
62
84
  }
63
85
  export interface PointerCaptureTarget {
@@ -17,11 +17,36 @@ export declare type Extensions<T extends {
17
17
  }> = (loader: T['prototype']) => void;
18
18
  export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
19
19
  export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
20
+ /**
21
+ * Exposes an object's {@link LocalState}.
22
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
23
+ *
24
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
25
+ */
20
26
  export declare function useInstanceHandle<O>(ref: React.MutableRefObject<O>): React.MutableRefObject<LocalState>;
21
27
  export declare function useStore(): import("zustand").UseBoundStore<RootState, import("zustand").StoreApi<RootState>>;
28
+ /**
29
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
30
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
31
+ */
22
32
  export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
33
+ /**
34
+ * Executes a callback before render in a shared frame loop.
35
+ * Can order effects with render priority or manually render with a positive priority.
36
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
37
+ */
23
38
  export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
39
+ /**
40
+ * Returns a node graph of an object with named nodes & materials.
41
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
42
+ */
24
43
  export declare function useGraph(object: THREE.Object3D): ObjectMap;
44
+ /**
45
+ * Synchronously loads and caches assets with a three loader.
46
+ *
47
+ * Note: this hook's caller must be wrapped with `React.Suspense`
48
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
49
+ */
25
50
  export declare function useLoader<T, U extends string | string[], L extends LoaderProto<T>, R = LoaderReturnType<T, L>>(Proto: L, input: U, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<R, GLTF, GLTF & ObjectMap>[] : BranchingReturn<R, GLTF, GLTF & ObjectMap>;
26
51
  export declare namespace useLoader {
27
52
  var preload: <T, U extends string | string[], L extends LoaderProto<T>>(Proto: L, input: U, extensions?: Extensions<L> | undefined) => undefined;
@@ -15,23 +15,53 @@ declare const invalidate: (state?: RootState | undefined, frames?: number) => vo
15
15
  declare const reconciler: import("react-reconciler").Reconciler<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>, import("./renderer").Instance, void, import("./renderer").Instance, import("./renderer").Instance>, applyProps: typeof import("./utils").applyProps;
16
16
  declare type GLProps = Renderer | ((canvas: Canvas) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
17
17
  export declare type RenderProps<TCanvas extends Canvas> = {
18
+ /** A threejs renderer instance or props that go into the default renderer */
18
19
  gl?: GLProps;
20
+ /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
19
21
  size?: Size;
22
+ /**
23
+ * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
24
+ * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
25
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
26
+ */
20
27
  shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
28
+ /**
29
+ * Disables three r139 color management.
30
+ * @see https://threejs.org/docs/#manual/en/introduction/Color-management
31
+ */
21
32
  legacy?: boolean;
33
+ /** Switch off automatic sRGB color space and gamma correction */
22
34
  linear?: boolean;
35
+ /** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
23
36
  flat?: boolean;
37
+ /** Creates an orthographic camera */
24
38
  orthographic?: boolean;
39
+ /**
40
+ * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
41
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
42
+ */
25
43
  frameloop?: 'always' | 'demand' | 'never';
44
+ /**
45
+ * R3F performance options for adaptive performance.
46
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
47
+ */
26
48
  performance?: Partial<Omit<Performance, 'regress'>>;
49
+ /** Target pixel ratio. Can clamp between a range: `[min, max]` */
27
50
  dpr?: Dpr;
51
+ /** Props that go into the default raycaster */
28
52
  raycaster?: Partial<THREE.Raycaster>;
53
+ /** A `THREE.Scene` instance or props that go into the default scene */
29
54
  scene?: THREE.Scene | Partial<ReactThreeFiber.Object3DNode<THREE.Scene, typeof THREE.Scene>>;
55
+ /** A `THREE.Camera` instance or props that go into the default camera */
30
56
  camera?: (Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>) & {
57
+ /** Flags the camera as manual, putting projection into your own hands */
31
58
  manual?: boolean;
32
59
  };
60
+ /** An R3F event manager to manage elements' pointer events */
33
61
  events?: (store: UseBoundStore<RootState>) => EventManager<HTMLElement>;
62
+ /** Callback after the canvas has rendered (but not yet committed) */
34
63
  onCreated?: (state: RootState) => void;
64
+ /** Response for pointer clicks that have missed any target */
35
65
  onPointerMissed?: (event: MouseEvent) => void;
36
66
  };
37
67
  export declare type ReconcilerRoot<TCanvas extends Canvas> = {
@@ -1,13 +1,33 @@
1
1
  import { Root } from './renderer';
2
2
  import { RootState } from './store';
3
3
  export declare type GlobalRenderCallback = (timeStamp: number) => void;
4
+ /**
5
+ * Adds a global render callback which is called each frame.
6
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
7
+ */
4
8
  export declare const addEffect: (callback: GlobalRenderCallback) => () => void;
9
+ /**
10
+ * Adds a global after-render callback which is called each frame.
11
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
12
+ */
5
13
  export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
14
+ /**
15
+ * Adds a global callback which is called when rendering stops.
16
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
17
+ */
6
18
  export declare const addTail: (callback: GlobalRenderCallback) => () => void;
7
19
  export declare type GlobalEffectType = 'before' | 'after' | 'tail';
8
20
  export declare function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
9
21
  export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
10
22
  loop: (timestamp: number) => void;
23
+ /**
24
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
25
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
26
+ */
11
27
  invalidate: (state?: RootState | undefined, frames?: number) => void;
28
+ /**
29
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
30
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
31
+ */
12
32
  advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: import("three").XRFrame | undefined) => void;
13
33
  };
@@ -19,21 +19,32 @@ export declare type Size = {
19
19
  height: number;
20
20
  top: number;
21
21
  left: number;
22
+ /** @deprecated `updateStyle` is now disabled for OffscreenCanvas and will be removed in v9. */
22
23
  updateStyle?: boolean;
23
24
  };
24
25
  export declare type Viewport = Size & {
26
+ /** The initial pixel ratio */
25
27
  initialDpr: number;
28
+ /** Current pixel ratio */
26
29
  dpr: number;
30
+ /** size.width / viewport.width */
27
31
  factor: number;
32
+ /** Camera distance */
28
33
  distance: number;
34
+ /** Camera aspect ratio: width / height */
29
35
  aspect: number;
30
36
  };
31
37
  export declare type RenderCallback = (state: RootState, delta: number, frame?: _XRFrame) => void;
32
38
  export declare type Performance = {
39
+ /** Current performance normal, between min and max */
33
40
  current: number;
41
+ /** How low the performance can go, between 0 and max */
34
42
  min: number;
43
+ /** How high the performance can go, between min and max */
35
44
  max: number;
45
+ /** Time until current returns to max in ms */
36
46
  debounce: number;
47
+ /** Sets current to min, puts the system in regression */
37
48
  regress: () => void;
38
49
  };
39
50
  export declare type Renderer = {
@@ -54,40 +65,71 @@ export declare type InternalState = {
54
65
  subscribe: (callback: React.MutableRefObject<RenderCallback>, priority: number, store: UseBoundStore<RootState, StoreApi<RootState>>) => () => void;
55
66
  };
56
67
  export declare type RootState = {
68
+ /** Set current state */
57
69
  set: SetState<RootState>;
70
+ /** Get current state */
58
71
  get: GetState<RootState>;
72
+ /** The instance of the renderer */
59
73
  gl: THREE.WebGLRenderer;
74
+ /** Default camera */
60
75
  camera: Camera & {
61
76
  manual?: boolean;
62
77
  };
78
+ /** Default scene */
63
79
  scene: THREE.Scene;
80
+ /** Default raycaster */
64
81
  raycaster: THREE.Raycaster;
82
+ /** Default clock */
65
83
  clock: THREE.Clock;
84
+ /** Event layer interface, contains the event handler and the node they're connected to */
66
85
  events: EventManager<any>;
86
+ /** XR interface */
67
87
  xr: {
68
88
  connect: () => void;
69
89
  disconnect: () => void;
70
90
  };
91
+ /** Currently used controls */
71
92
  controls: THREE.EventDispatcher | null;
93
+ /** Normalized event coordinates */
72
94
  pointer: THREE.Vector2;
95
+ /** @deprecated Normalized event coordinates, use "pointer" instead! */
73
96
  mouse: THREE.Vector2;
74
97
  legacy: boolean;
98
+ /** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
75
99
  linear: boolean;
100
+ /** Shortcut to gl.toneMapping = NoTonemapping */
76
101
  flat: boolean;
102
+ /** Render loop flags */
77
103
  frameloop: 'always' | 'demand' | 'never';
104
+ /** Adaptive performance interface */
78
105
  performance: Performance;
106
+ /** Reactive pixel-size of the canvas */
79
107
  size: Size;
108
+ /** Reactive size of the viewport in threejs units */
80
109
  viewport: Viewport & {
81
110
  getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
82
111
  };
112
+ /** Flags the canvas for render, but doesn't render in itself */
83
113
  invalidate: (frames?: number) => void;
114
+ /** Advance (render) one step */
84
115
  advance: (timestamp: number, runGlobalEffects?: boolean) => void;
116
+ /** Shortcut to setting the event layer */
85
117
  setEvents: (events: Partial<EventManager<any>>) => void;
86
- setSize: (width: number, height: number, updateStyle?: boolean, top?: number, left?: number) => void;
118
+ /**
119
+ * Shortcut to manual sizing
120
+ */
121
+ setSize: (width: number, height: number,
122
+ /** @deprecated `updateStyle` is now disabled for OffscreenCanvas and will be removed in v9. */
123
+ updateStyle?: boolean, top?: number, left?: number) => void;
124
+ /** Shortcut to manual setting the pixel ratio */
87
125
  setDpr: (dpr: Dpr) => void;
126
+ /** Shortcut to frameloop flags */
88
127
  setFrameloop: (frameloop?: 'always' | 'demand' | 'never') => void;
128
+ /** When the canvas was clicked but nothing was hit */
89
129
  onPointerMissed?: (event: MouseEvent) => void;
130
+ /** If this state model is layerd (via createPortal) then this contains the previous layer */
90
131
  previousRoot?: UseBoundStore<RootState, StoreApi<RootState>>;
132
+ /** Internals */
91
133
  internal: InternalState;
92
134
  };
93
135
  declare const context: React.Context<UseBoundStore<RootState, StoreApi<RootState>>>;
@@ -7,6 +7,9 @@ declare type _DeprecatedXRFrame = THREE.XRFrame;
7
7
  export declare type _XRFrame = THREE.WebGLRenderTargetOptions extends {
8
8
  samples?: number;
9
9
  } ? XRFrame : _DeprecatedXRFrame;
10
+ /**
11
+ * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
12
+ */
10
13
  export declare const hasColorSpace: <T extends object | Renderer | THREE.Texture, P = T extends Renderer ? {
11
14
  outputColorSpace: string;
12
15
  } : {
@@ -17,10 +20,22 @@ export declare type ColorManagementRepresentation = {
17
20
  } | {
18
21
  legacyMode: boolean | never;
19
22
  };
23
+ /**
24
+ * The current THREE.ColorManagement instance, if present.
25
+ */
20
26
  export declare const getColorManagement: () => ColorManagementRepresentation | null;
21
27
  export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
22
28
  export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
23
29
  export declare const isRef: (obj: any) => obj is React.MutableRefObject<unknown>;
30
+ /**
31
+ * An SSR-friendly useLayoutEffect.
32
+ *
33
+ * React currently throws a warning when using useLayoutEffect on the server.
34
+ * To get around it, we can conditionally useEffect on the server (no-op) and
35
+ * useLayoutEffect elsewhere.
36
+ *
37
+ * @see https://github.com/facebook/react/issues/14927
38
+ */
24
39
  export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
25
40
  export declare function useMutableCallback<T>(fn: T): React.MutableRefObject<T>;
26
41
  export declare type SetBlock = false | Promise<null> | null;
@@ -65,10 +80,16 @@ export declare type ObjectMap = {
65
80
  };
66
81
  };
67
82
  export declare function calculateDpr(dpr: Dpr): number;
83
+ /**
84
+ * Returns instance root state
85
+ */
68
86
  export declare const getRootState: (obj: THREE.Object3D) => RootState | undefined;
69
87
  export declare type EquConfig = {
88
+ /** Compare arrays by reference equality a === b (default), or by shallow equality */
70
89
  arrays?: 'reference' | 'shallow';
90
+ /** Compare objects by reference equality a === b (default), or by shallow equality */
71
91
  objects?: 'reference' | 'shallow';
92
+ /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
72
93
  strict?: boolean;
73
94
  };
74
95
  export declare const is: {
@@ -81,6 +102,9 @@ export declare const is: {
81
102
  arr: (a: any) => boolean;
82
103
  equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
83
104
  };
105
+ /**
106
+ * Collects nodes and materials from a THREE.Object3D.
107
+ */
84
108
  export declare function buildGraph(object: THREE.Object3D): ObjectMap;
85
109
  export declare function dispose<TObj extends {
86
110
  dispose?: () => void;
@@ -7,4 +7,8 @@ export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'
7
7
  }
8
8
  export interface Props extends CanvasProps {
9
9
  }
10
+ /**
11
+ * A native canvas which accepts threejs elements as children.
12
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
13
+ */
10
14
  export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<View>>;
@@ -1,4 +1,5 @@
1
1
  import { UseBoundStore } from 'zustand';
2
2
  import { RootState } from '../core/store';
3
3
  import { EventManager } from '../core/events';
4
+ /** Default R3F event manager for react-native */
4
5
  export declare function createTouchEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
@@ -8,9 +8,15 @@ export declare type NonFunctionKeys<T> = {
8
8
  [K in keyof T]-?: T[K] extends Function ? never : K;
9
9
  }[keyof T];
10
10
  export declare type Overwrite<T, O> = Omit<T, NonFunctionKeys<O>> & O;
11
+ /**
12
+ * If **T** contains a constructor, @see ConstructorParameters must be used, otherwise **T**.
13
+ */
11
14
  declare type Args<T> = T extends new (...args: any) => any ? ConstructorParameters<T> : T;
12
15
  export declare type Euler = THREE.Euler | Parameters<THREE.Euler['set']>;
13
16
  export declare type Matrix4 = THREE.Matrix4 | Parameters<THREE.Matrix4['set']> | Readonly<THREE.Matrix4['set']>;
17
+ /**
18
+ * Turn an implementation of THREE.Vector in to the type that an r3f component would accept as a prop.
19
+ */
14
20
  declare type VectorLike<VectorClass extends THREE.Vector> = VectorClass | Parameters<VectorClass['set']> | Readonly<Parameters<VectorClass['set']>> | Parameters<VectorClass['setScalar']>[0];
15
21
  export declare type Vector2 = VectorLike<THREE.Vector2>;
16
22
  export declare type Vector3 = VectorLike<THREE.Vector3>;
@@ -22,6 +28,7 @@ export declare type Quaternion = THREE.Quaternion | Parameters<THREE.Quaternion[
22
28
  export declare type AttachCallback = string | ((child: any, parentInstance: any) => void);
23
29
  export interface NodeProps<T, P> {
24
30
  attach?: AttachType;
31
+ /** Constructor arguments */
25
32
  args?: Args<P>;
26
33
  children?: React.ReactNode;
27
34
  ref?: React.Ref<T>;
@@ -67,23 +74,71 @@ export declare type CubeCameraProps = Object3DNode<THREE.CubeCamera, typeof THRE
67
74
  export declare type ArrayCameraProps = Object3DNode<THREE.ArrayCamera, typeof THREE.ArrayCamera>;
68
75
  export declare type InstancedBufferGeometryProps = BufferGeometryNode<THREE.InstancedBufferGeometry, typeof THREE.InstancedBufferGeometry>;
69
76
  export declare type BufferGeometryProps = BufferGeometryNode<THREE.BufferGeometry, typeof THREE.BufferGeometry>;
77
+ /** @ts-ignore */
70
78
  export declare type BoxBufferGeometryProps = BufferGeometryNode<THREE.BoxBufferGeometry, typeof THREE.BoxBufferGeometry>;
71
- export declare type CircleBufferGeometryProps = BufferGeometryNode<THREE.CircleBufferGeometry, typeof THREE.CircleBufferGeometry>;
79
+ export declare type CircleBufferGeometryProps = BufferGeometryNode<
80
+ /** @ts-ignore */
81
+ THREE.CircleBufferGeometry,
82
+ /** @ts-ignore */
83
+ typeof THREE.CircleBufferGeometry>;
84
+ /** @ts-ignore */
72
85
  export declare type ConeBufferGeometryProps = BufferGeometryNode<THREE.ConeBufferGeometry, typeof THREE.ConeBufferGeometry>;
73
- export declare type CylinderBufferGeometryProps = BufferGeometryNode<THREE.CylinderBufferGeometry, typeof THREE.CylinderBufferGeometry>;
74
- export declare type DodecahedronBufferGeometryProps = BufferGeometryNode<THREE.DodecahedronBufferGeometry, typeof THREE.DodecahedronBufferGeometry>;
75
- export declare type ExtrudeBufferGeometryProps = BufferGeometryNode<THREE.ExtrudeBufferGeometry, typeof THREE.ExtrudeBufferGeometry>;
76
- export declare type IcosahedronBufferGeometryProps = BufferGeometryNode<THREE.IcosahedronBufferGeometry, typeof THREE.IcosahedronBufferGeometry>;
86
+ export declare type CylinderBufferGeometryProps = BufferGeometryNode<
87
+ /** @ts-ignore */
88
+ THREE.CylinderBufferGeometry,
89
+ /** @ts-ignore */
90
+ typeof THREE.CylinderBufferGeometry>;
91
+ export declare type DodecahedronBufferGeometryProps = BufferGeometryNode<
92
+ /** @ts-ignore */
93
+ THREE.DodecahedronBufferGeometry,
94
+ /** @ts-ignore */
95
+ typeof THREE.DodecahedronBufferGeometry>;
96
+ export declare type ExtrudeBufferGeometryProps = BufferGeometryNode<
97
+ /** @ts-ignore */
98
+ THREE.ExtrudeBufferGeometry,
99
+ /** @ts-ignore */
100
+ typeof THREE.ExtrudeBufferGeometry>;
101
+ export declare type IcosahedronBufferGeometryProps = BufferGeometryNode<
102
+ /** @ts-ignore */
103
+ THREE.IcosahedronBufferGeometry,
104
+ /** @ts-ignore */
105
+ typeof THREE.IcosahedronBufferGeometry>;
106
+ /** @ts-ignore */
77
107
  export declare type LatheBufferGeometryProps = BufferGeometryNode<THREE.LatheBufferGeometry, typeof THREE.LatheBufferGeometry>;
78
- export declare type OctahedronBufferGeometryProps = BufferGeometryNode<THREE.OctahedronBufferGeometry, typeof THREE.OctahedronBufferGeometry>;
108
+ export declare type OctahedronBufferGeometryProps = BufferGeometryNode<
109
+ /** @ts-ignore */
110
+ THREE.OctahedronBufferGeometry,
111
+ /** @ts-ignore */
112
+ typeof THREE.OctahedronBufferGeometry>;
113
+ /** @ts-ignore */
79
114
  export declare type PlaneBufferGeometryProps = BufferGeometryNode<THREE.PlaneBufferGeometry, typeof THREE.PlaneBufferGeometry>;
80
- export declare type PolyhedronBufferGeometryProps = BufferGeometryNode<THREE.PolyhedronBufferGeometry, typeof THREE.PolyhedronBufferGeometry>;
115
+ export declare type PolyhedronBufferGeometryProps = BufferGeometryNode<
116
+ /** @ts-ignore */
117
+ THREE.PolyhedronBufferGeometry,
118
+ /** @ts-ignore */
119
+ typeof THREE.PolyhedronBufferGeometry>;
120
+ /** @ts-ignore */
81
121
  export declare type RingBufferGeometryProps = BufferGeometryNode<THREE.RingBufferGeometry, typeof THREE.RingBufferGeometry>;
122
+ /** @ts-ignore */
82
123
  export declare type ShapeBufferGeometryProps = BufferGeometryNode<THREE.ShapeBufferGeometry, typeof THREE.ShapeBufferGeometry>;
83
- export declare type SphereBufferGeometryProps = BufferGeometryNode<THREE.SphereBufferGeometry, typeof THREE.SphereBufferGeometry>;
84
- export declare type TetrahedronBufferGeometryProps = BufferGeometryNode<THREE.TetrahedronBufferGeometry, typeof THREE.TetrahedronBufferGeometry>;
124
+ export declare type SphereBufferGeometryProps = BufferGeometryNode<
125
+ /** @ts-ignore */
126
+ THREE.SphereBufferGeometry,
127
+ /** @ts-ignore */
128
+ typeof THREE.SphereBufferGeometry>;
129
+ export declare type TetrahedronBufferGeometryProps = BufferGeometryNode<
130
+ /** @ts-ignore */
131
+ THREE.TetrahedronBufferGeometry,
132
+ /** @ts-ignore */
133
+ typeof THREE.TetrahedronBufferGeometry>;
134
+ /** @ts-ignore */
85
135
  export declare type TorusBufferGeometryProps = BufferGeometryNode<THREE.TorusBufferGeometry, typeof THREE.TorusBufferGeometry>;
86
- export declare type TorusKnotBufferGeometryProps = BufferGeometryNode<THREE.TorusKnotBufferGeometry, typeof THREE.TorusKnotBufferGeometry>;
136
+ export declare type TorusKnotBufferGeometryProps = BufferGeometryNode<
137
+ /** @ts-ignore */
138
+ THREE.TorusKnotBufferGeometry,
139
+ /** @ts-ignore */
140
+ typeof THREE.TorusKnotBufferGeometry>;
141
+ /** @ts-ignore */
87
142
  export declare type TubeBufferGeometryProps = BufferGeometryNode<THREE.TubeBufferGeometry, typeof THREE.TubeBufferGeometry>;
88
143
  export declare type WireframeGeometryProps = BufferGeometryNode<THREE.WireframeGeometry, typeof THREE.WireframeGeometry>;
89
144
  export declare type TetrahedronGeometryProps = BufferGeometryNode<THREE.TetrahedronGeometry, typeof THREE.TetrahedronGeometry>;
@@ -139,7 +194,9 @@ export declare type DirectionalLightShadowProps = Node<THREE.DirectionalLightSha
139
194
  export declare type DirectionalLightProps = LightNode<THREE.DirectionalLight, typeof THREE.DirectionalLight>;
140
195
  export declare type AmbientLightProps = LightNode<THREE.AmbientLight, typeof THREE.AmbientLight>;
141
196
  export declare type LightShadowProps = Node<THREE.LightShadow, typeof THREE.LightShadow>;
197
+ /** @ts-ignore */
142
198
  export declare type AmbientLightProbeProps = LightNode<THREE.AmbientLightProbe, typeof THREE.AmbientLightProbe>;
199
+ /** @ts-ignore */
143
200
  export declare type HemisphereLightProbeProps = LightNode<THREE.HemisphereLightProbe, typeof THREE.HemisphereLightProbe>;
144
201
  export declare type LightProbeProps = LightNode<THREE.LightProbe, typeof THREE.LightProbe>;
145
202
  export declare type SpotLightHelperProps = Object3DNode<THREE.SpotLightHelper, typeof THREE.SpotLightHelper>;
@@ -158,6 +215,7 @@ export declare type AxesHelperProps = Object3DNode<THREE.AxesHelper, typeof THRE
158
215
  export declare type TextureProps = Node<THREE.Texture, typeof THREE.Texture>;
159
216
  export declare type VideoTextureProps = Node<THREE.VideoTexture, typeof THREE.VideoTexture>;
160
217
  export declare type DataTextureProps = Node<THREE.DataTexture, typeof THREE.DataTexture>;
218
+ /** @ts-ignore */
161
219
  export declare type DataTexture3DProps = Node<THREE.DataTexture3D, typeof THREE.DataTexture3D>;
162
220
  export declare type CompressedTextureProps = Node<THREE.CompressedTexture, typeof THREE.CompressedTexture>;
163
221
  export declare type CubeTextureProps = Node<THREE.CubeTexture, typeof THREE.CubeTexture>;
@@ -3,11 +3,22 @@ import type { Options as ResizeOptions } from 'react-use-measure';
3
3
  import { RenderProps } from '../core';
4
4
  export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
5
  children: React.ReactNode;
6
+ /** Canvas fallback content, similar to img's alt prop */
6
7
  fallback?: React.ReactNode;
8
+ /**
9
+ * Options to pass to useMeasure.
10
+ * @see https://github.com/pmndrs/react-use-measure#api
11
+ */
7
12
  resize?: ResizeOptions;
13
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
8
14
  eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
15
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
9
16
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
17
  }
11
18
  export interface Props extends CanvasProps {
12
19
  }
20
+ /**
21
+ * A DOM canvas which accepts threejs elements as children.
22
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
23
+ */
13
24
  export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +1,5 @@
1
1
  import { UseBoundStore } from 'zustand';
2
2
  import { RootState } from '../core/store';
3
3
  import { EventManager } from '../core/events';
4
+ /** Default R3F event manager for web */
4
5
  export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
@@ -127,7 +127,11 @@ function createRenderer(_roots, _getEventPriority) {
127
127
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
128
128
  added = true;
129
129
  }
130
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
130
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
131
+ if (!added && objects) {
132
+ const index = objects.indexOf(beforeChild);
133
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
134
+ }
131
135
  if (!child.__r3f) prepare(child, {});
132
136
  child.__r3f.parent = parentInstance;
133
137
  updateInstance(child);
@@ -143,7 +147,11 @@ function createRenderer(_roots, _getEventPriority) {
143
147
  // Clear the parent reference
144
148
  if (child.__r3f) child.__r3f.parent = null;
145
149
  // Remove child from the parents objects
146
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
150
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
151
+ if (objects) {
152
+ const index = objects.indexOf(child);
153
+ if (index !== -1) objects.splice(index, 1);
154
+ }
147
155
  // Remove attachment
148
156
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
149
157
  detach(parentInstance, child, child.__r3f.attach);
@@ -209,13 +217,14 @@ function createRenderer(_roots, _getEventPriority) {
209
217
  }
210
218
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
211
219
  instance.__r3f.objects = [];
220
+ const autoRemovedBeforeAppend = !!newInstance.parent;
212
221
  if (!instance.__r3f.autoRemovedBeforeAppend) {
222
+ insertBefore(parent, newInstance, instance);
213
223
  removeChild(parent, instance);
224
+ } else {
225
+ appendChild(parent, newInstance);
214
226
  }
215
- if (newInstance.parent) {
216
- newInstance.__r3f.autoRemovedBeforeAppend = true;
217
- }
218
- appendChild(parent, newInstance);
227
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
219
228
 
220
229
  // Re-bind event handlers
221
230
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -127,7 +127,11 @@ function createRenderer(_roots, _getEventPriority) {
127
127
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
128
128
  added = true;
129
129
  }
130
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
130
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
131
+ if (!added && objects) {
132
+ const index = objects.indexOf(beforeChild);
133
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
134
+ }
131
135
  if (!child.__r3f) prepare(child, {});
132
136
  child.__r3f.parent = parentInstance;
133
137
  updateInstance(child);
@@ -143,7 +147,11 @@ function createRenderer(_roots, _getEventPriority) {
143
147
  // Clear the parent reference
144
148
  if (child.__r3f) child.__r3f.parent = null;
145
149
  // Remove child from the parents objects
146
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
150
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
151
+ if (objects) {
152
+ const index = objects.indexOf(child);
153
+ if (index !== -1) objects.splice(index, 1);
154
+ }
147
155
  // Remove attachment
148
156
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
149
157
  detach(parentInstance, child, child.__r3f.attach);
@@ -209,13 +217,14 @@ function createRenderer(_roots, _getEventPriority) {
209
217
  }
210
218
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
211
219
  instance.__r3f.objects = [];
220
+ const autoRemovedBeforeAppend = !!newInstance.parent;
212
221
  if (!instance.__r3f.autoRemovedBeforeAppend) {
222
+ insertBefore(parent, newInstance, instance);
213
223
  removeChild(parent, instance);
224
+ } else {
225
+ appendChild(parent, newInstance);
214
226
  }
215
- if (newInstance.parent) {
216
- newInstance.__r3f.autoRemovedBeforeAppend = true;
217
- }
218
- appendChild(parent, newInstance);
227
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
219
228
 
220
229
  // Re-bind event handlers
221
230
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -100,7 +100,11 @@ function createRenderer(_roots, _getEventPriority) {
100
100
  parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
101
101
  added = true;
102
102
  }
103
- if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
103
+ const objects = (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects;
104
+ if (!added && objects) {
105
+ const index = objects.indexOf(beforeChild);
106
+ if (index !== -1) objects.splice(index, 0, child);else objects.push(child);
107
+ }
104
108
  if (!child.__r3f) prepare(child, {});
105
109
  child.__r3f.parent = parentInstance;
106
110
  updateInstance(child);
@@ -116,7 +120,11 @@ function createRenderer(_roots, _getEventPriority) {
116
120
  // Clear the parent reference
117
121
  if (child.__r3f) child.__r3f.parent = null;
118
122
  // Remove child from the parents objects
119
- if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
123
+ const objects = (_parentInstance$__r3f3 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f3.objects;
124
+ if (objects) {
125
+ const index = objects.indexOf(child);
126
+ if (index !== -1) objects.splice(index, 1);
127
+ }
120
128
  // Remove attachment
121
129
  if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
122
130
  detach(parentInstance, child, child.__r3f.attach);
@@ -182,13 +190,14 @@ function createRenderer(_roots, _getEventPriority) {
182
190
  }
183
191
  instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
184
192
  instance.__r3f.objects = [];
193
+ const autoRemovedBeforeAppend = !!newInstance.parent;
185
194
  if (!instance.__r3f.autoRemovedBeforeAppend) {
195
+ insertBefore(parent, newInstance, instance);
186
196
  removeChild(parent, instance);
197
+ } else {
198
+ appendChild(parent, newInstance);
187
199
  }
188
- if (newInstance.parent) {
189
- newInstance.__r3f.autoRemovedBeforeAppend = true;
190
- }
191
- appendChild(parent, newInstance);
200
+ newInstance.__r3f.autoRemovedBeforeAppend = autoRemovedBeforeAppend;
192
201
 
193
202
  // Re-bind event handlers
194
203
  if (newInstance.raycast && newInstance.__r3f.eventCount) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-d26c5c57.cjs.dev.js');
5
+ var index = require('./index-9bf2e8aa.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-e6d64601.cjs.prod.js');
5
+ var index = require('./index-66b6e976.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-594193f5.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-594193f5.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-a2103d81.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-a2103d81.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-d26c5c57.cjs.dev.js');
5
+ var index = require('../../dist/index-9bf2e8aa.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -345,7 +345,7 @@ async function getAsset(input) {
345
345
  }
346
346
  function polyfills() {
347
347
  // Patch Blob for ArrayBuffer and URL if unsupported
348
- // https://github.com/pmndrs/react-three-fiber/pull/3059
348
+ // https://github.com/facebook/react-native/pull/39276
349
349
  // https://github.com/pmndrs/react-three-fiber/issues/3058
350
350
  if (reactNative.Platform.OS !== 'web') {
351
351
  try {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-e6d64601.cjs.prod.js');
5
+ var index = require('../../dist/index-66b6e976.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -345,7 +345,7 @@ async function getAsset(input) {
345
345
  }
346
346
  function polyfills() {
347
347
  // Patch Blob for ArrayBuffer and URL if unsupported
348
- // https://github.com/pmndrs/react-three-fiber/pull/3059
348
+ // https://github.com/facebook/react-native/pull/39276
349
349
  // https://github.com/pmndrs/react-three-fiber/issues/3058
350
350
  if (reactNative.Platform.OS !== 'web') {
351
351
  try {
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-594193f5.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-594193f5.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-a2103d81.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-a2103d81.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
@@ -320,7 +320,7 @@ async function getAsset(input) {
320
320
  }
321
321
  function polyfills() {
322
322
  // Patch Blob for ArrayBuffer and URL if unsupported
323
- // https://github.com/pmndrs/react-three-fiber/pull/3059
323
+ // https://github.com/facebook/react-native/pull/39276
324
324
  // https://github.com/pmndrs/react-three-fiber/issues/3058
325
325
  if (Platform.OS !== 'web') {
326
326
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.15.4",
3
+ "version": "8.15.6",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",