@react-three/fiber 9.0.0-beta.0 → 9.0.0-beta.1

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.16.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 4748b365: fix: update is.equ to compare booleans
8
+
9
+ ## 8.16.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 4d6408c7: fix(types): revert usage of future module JSX
14
+
3
15
  ## 8.16.6
4
16
 
5
17
  ### Patch Changes
@@ -546,7 +546,7 @@ const is = {
546
546
  // Wrong type or one of the two undefined, doesn't match
547
547
  if (typeof a !== typeof b || !!a !== !!b) return false;
548
548
  // Atomic, just compare a against b
549
- if (is.str(a) || is.num(a)) return a === b;
549
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
550
550
  const isObj = is.obj(a);
551
551
  if (isObj && objects === 'reference') return a === b;
552
552
  const isArr = is.arr(a);
@@ -754,7 +754,7 @@ function diffProps(instance, newProps) {
754
754
  }
755
755
  return changedProps;
756
756
  }
757
- const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
757
+ typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
758
758
 
759
759
  // const LinearEncoding = 3000
760
760
  const sRGBEncoding = 3001;
@@ -809,12 +809,7 @@ function applyProps(object, props) {
809
809
  }
810
810
 
811
811
  // Copy if properties match signatures
812
- if (target != null && target.copy && (
813
- // Some environments may break strict identity checks by duplicating versions of three.js.
814
- // Loosen to unminified names, ignoring descendents.
815
- // https://github.com/pmndrs/react-three-fiber/issues/2856
816
- // TODO: fix upstream and remove in v9
817
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
812
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
818
813
  target.copy(value);
819
814
  }
820
815
  // Layers have no copy function, we must therefore copy the mask property
@@ -572,7 +572,7 @@ const is = {
572
572
  // Wrong type or one of the two undefined, doesn't match
573
573
  if (typeof a !== typeof b || !!a !== !!b) return false;
574
574
  // Atomic, just compare a against b
575
- if (is.str(a) || is.num(a)) return a === b;
575
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
576
576
  const isObj = is.obj(a);
577
577
  if (isObj && objects === 'reference') return a === b;
578
578
  const isArr = is.arr(a);
@@ -780,7 +780,6 @@ function diffProps(instance, newProps) {
780
780
  }
781
781
  return changedProps;
782
782
  }
783
- const __DEV__ = typeof process !== 'undefined' && "production" !== 'production';
784
783
 
785
784
  // const LinearEncoding = 3000
786
785
  const sRGBEncoding = 3001;
@@ -835,12 +834,7 @@ function applyProps(object, props) {
835
834
  }
836
835
 
837
836
  // Copy if properties match signatures
838
- if (target != null && target.copy && (
839
- // Some environments may break strict identity checks by duplicating versions of three.js.
840
- // Loosen to unminified names, ignoring descendents.
841
- // https://github.com/pmndrs/react-three-fiber/issues/2856
842
- // TODO: fix upstream and remove in v9
843
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
837
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
844
838
  target.copy(value);
845
839
  }
846
840
  // Layers have no copy function, we must therefore copy the mask property
@@ -572,7 +572,7 @@ const is = {
572
572
  // Wrong type or one of the two undefined, doesn't match
573
573
  if (typeof a !== typeof b || !!a !== !!b) return false;
574
574
  // Atomic, just compare a against b
575
- if (is.str(a) || is.num(a)) return a === b;
575
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
576
576
  const isObj = is.obj(a);
577
577
  if (isObj && objects === 'reference') return a === b;
578
578
  const isArr = is.arr(a);
@@ -780,7 +780,7 @@ function diffProps(instance, newProps) {
780
780
  }
781
781
  return changedProps;
782
782
  }
783
- const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
783
+ typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
784
784
 
785
785
  // const LinearEncoding = 3000
786
786
  const sRGBEncoding = 3001;
@@ -835,12 +835,7 @@ function applyProps(object, props) {
835
835
  }
836
836
 
837
837
  // Copy if properties match signatures
838
- if (target != null && target.copy && (
839
- // Some environments may break strict identity checks by duplicating versions of three.js.
840
- // Loosen to unminified names, ignoring descendents.
841
- // https://github.com/pmndrs/react-three-fiber/issues/2856
842
- // TODO: fix upstream and remove in v9
843
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
838
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
844
839
  target.copy(value);
845
840
  }
846
841
  // Layers have no copy function, we must therefore copy the mask property
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('./loop-8dd3f5bb.cjs.dev.js');
5
+ var loop = require('./loop-eb3c7218.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('./loop-5012a96a.cjs.prod.js');
5
+ var loop = require('./loop-dfcc9ca9.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, d as createRoot, i as isRef, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from './loop-ed5edcdb.esm.js';
2
- export { t as ReactThreeFiber, _ as _roots, w as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, q as applyProps, x as buildGraph, p as context, c as createEvents, o as createPortal, d as createRoot, v as dispose, e as extend, g as flushGlobalEffects, s as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './loop-ed5edcdb.esm.js';
1
+ import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, d as createRoot, i as isRef, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from './loop-b00a3b86.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, w as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, q as applyProps, x as buildGraph, p as context, c as createEvents, o as createPortal, d as createRoot, v as dispose, e as extend, g as flushGlobalEffects, s as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './loop-b00a3b86.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import useMeasure from 'react-use-measure';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('../../dist/loop-8dd3f5bb.cjs.dev.js');
5
+ var loop = require('../../dist/loop-eb3c7218.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('../../dist/loop-5012a96a.cjs.prod.js');
5
+ var loop = require('../../dist/loop-dfcc9ca9.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, d as createRoot, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from '../../dist/loop-ed5edcdb.esm.js';
2
- export { t as ReactThreeFiber, _ as _roots, w as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, q as applyProps, x as buildGraph, p as context, c as createEvents, o as createPortal, d as createRoot, v as dispose, e as extend, g as flushGlobalEffects, s as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/loop-ed5edcdb.esm.js';
1
+ import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, d as createRoot, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from '../../dist/loop-b00a3b86.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, w as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, q as applyProps, x as buildGraph, p as context, c as createEvents, o as createPortal, d as createRoot, v as dispose, e as extend, g as flushGlobalEffects, s as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/loop-b00a3b86.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "9.0.0-beta.0",
3
+ "version": "9.0.0-beta.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -47,9 +47,9 @@
47
47
  "base64-js": "^1.5.1",
48
48
  "buffer": "^6.0.3",
49
49
  "its-fine": "^1.2.5",
50
- "react-reconciler": "0.31.0-rc-38e3b23483-20240529",
50
+ "react-reconciler": "0.31.0-rc.0",
51
51
  "react-use-measure": "^2.1.1",
52
- "scheduler": "0.25.0-rc-38e3b23483-20240529",
52
+ "scheduler": "0.25.0-rc.0",
53
53
  "suspend-react": "^0.1.3",
54
54
  "zustand": "^4.1.2"
55
55
  },
@@ -1,91 +0,0 @@
1
- import * as THREE from 'three';
2
- import { type Properties } from "./utils.js";
3
- import type { RootState, RootStore } from "./store.js";
4
- export interface Intersection extends THREE.Intersection {
5
- /** The event source (the object which registered the handler) */
6
- eventObject: THREE.Object3D;
7
- }
8
- export interface IntersectionEvent<TSourceEvent> extends Intersection {
9
- /** The event source (the object which registered the handler) */
10
- eventObject: THREE.Object3D;
11
- /** An array of intersections */
12
- intersections: Intersection[];
13
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
14
- unprojectedPoint: THREE.Vector3;
15
- /** Normalized event coordinates */
16
- pointer: THREE.Vector2;
17
- /** Delta between first click and this event */
18
- delta: number;
19
- /** The ray that pierced it */
20
- ray: THREE.Ray;
21
- /** The camera that was used by the raycaster */
22
- camera: Camera;
23
- /** stopPropagation will stop underlying handlers from firing */
24
- stopPropagation: () => void;
25
- /** The original host event */
26
- nativeEvent: TSourceEvent;
27
- /** If the event was stopped by calling stopPropagation */
28
- stopped: boolean;
29
- }
30
- export type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
31
- export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
32
- export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
33
- export interface Events {
34
- onClick: EventListener;
35
- onContextMenu: EventListener;
36
- onDoubleClick: EventListener;
37
- onWheel: EventListener;
38
- onPointerDown: EventListener;
39
- onPointerUp: EventListener;
40
- onPointerLeave: EventListener;
41
- onPointerMove: EventListener;
42
- onPointerCancel: EventListener;
43
- onLostPointerCapture: EventListener;
44
- }
45
- export interface EventHandlers {
46
- onClick?: (event: ThreeEvent<MouseEvent>) => void;
47
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
48
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
49
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
50
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
51
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
52
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
53
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
54
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
55
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
56
- onPointerMissed?: (event: MouseEvent) => void;
57
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
58
- onWheel?: (event: ThreeEvent<WheelEvent>) => void;
59
- }
60
- export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
61
- export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
62
- export interface EventManager<TTarget> {
63
- /** Determines if the event layer is active */
64
- enabled: boolean;
65
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
66
- priority: number;
67
- /** The compute function needs to set up the raycaster and an xy- pointer */
68
- compute?: ComputeFunction;
69
- /** The filter can re-order or re-structure the intersections */
70
- filter?: FilterFunction;
71
- /** The target node the event layer is tied to */
72
- connected?: TTarget;
73
- /** All the pointer event handlers through which the host forwards native events */
74
- handlers?: Events;
75
- /** Allows re-connecting to another target */
76
- connect?: (target: TTarget) => void;
77
- /** Removes all existing events handlers from the target */
78
- disconnect?: () => void;
79
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
80
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
81
- */
82
- update?: () => void;
83
- }
84
- export interface PointerCaptureTarget {
85
- intersection: Intersection;
86
- target: Element;
87
- }
88
- export declare function removeInteractivity(store: RootStore, object: THREE.Object3D): void;
89
- export declare function createEvents(store: RootStore): {
90
- handlePointer: (name: string) => (event: DomEvent) => void;
91
- };
@@ -1,52 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as React from 'react';
3
- import { RootState, RenderCallback, RootStore } from "./store.js";
4
- import { ObjectMap } from "./utils.js";
5
- import type { Instance } from "./reconciler.js";
6
- /**
7
- * Exposes an object's {@link Instance}.
8
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useinstancehandle
9
- *
10
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
11
- */
12
- export declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
13
- /**
14
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
15
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
16
- */
17
- export declare function useStore(): RootStore;
18
- /**
19
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
20
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
21
- */
22
- export declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
23
- /**
24
- * Executes a callback before render in a shared frame loop.
25
- * Can order effects with render priority or manually render with a positive priority.
26
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
27
- */
28
- export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
29
- /**
30
- * Returns a node graph of an object with named nodes & materials.
31
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
32
- */
33
- export declare function useGraph(object: THREE.Object3D): ObjectMap;
34
- export interface Loader<T> extends THREE.Loader {
35
- load(url: string | string[] | string[][], onLoad?: (result: T, ...args: any[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: unknown) => void): unknown;
36
- }
37
- export type LoaderProto<T> = new (...args: any[]) => Loader<T>;
38
- export type LoaderResult<T> = T extends {
39
- scene: THREE.Object3D;
40
- } ? T & ObjectMap : T;
41
- export type Extensions<T> = (loader: Loader<T>) => void;
42
- /**
43
- * Synchronously loads and caches assets with a three loader.
44
- *
45
- * Note: this hook's caller must be wrapped with `React.Suspense`
46
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
47
- */
48
- export declare function useLoader<T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U, extensions?: Extensions<T>, onProgress?: (event: ProgressEvent) => void): U extends any[] ? LoaderResult<T>[] : LoaderResult<T>;
49
- export declare namespace useLoader {
50
- var preload: <T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U, extensions?: Extensions<T> | undefined) => void;
51
- var clear: <T, U extends string | string[] | string[][]>(loader: Loader<T> | LoaderProto<T>, input: U) => void;
52
- }
@@ -1,13 +0,0 @@
1
- export type { Intersection, ThreeEvent, DomEvent, Events, EventHandlers, FilterFunction, ComputeFunction, EventManager, } from "./events.js";
2
- export { createEvents } from "./events.js";
3
- export * from "./hooks.js";
4
- export type { GlobalRenderCallback, GlobalEffectType } from "./loop.js";
5
- export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from "./loop.js";
6
- export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from "./reconciler.js";
7
- export { extend, reconciler } from "./reconciler.js";
8
- export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from "./renderer.js";
9
- export { _roots, render, createRoot, unmountComponentAtNode, createPortal } from "./renderer.js";
10
- export type { Subscription, Dpr, Size, Viewport, RenderCallback, Frameloop, Performance, Renderer, XRManager, RootState, RootStore, } from "./store.js";
11
- export { context } from "./store.js";
12
- export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
13
- export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
@@ -1,31 +0,0 @@
1
- /// <reference types="webxr" />
2
- import type { RootState } from "./store.js";
3
- export 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
- */
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
- */
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
- */
18
- export declare const addTail: (callback: GlobalRenderCallback) => () => void;
19
- export type GlobalEffectType = 'before' | 'after' | 'tail';
20
- export declare function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
21
- export declare function loop(timestamp: number): void;
22
- /**
23
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
24
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
25
- */
26
- export declare function invalidate(state?: RootState, frames?: number): void;
27
- /**
28
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
29
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
30
- */
31
- export declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
@@ -1,55 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as React from 'react';
3
- import Reconciler from 'react-reconciler';
4
- import { IsAllOptional } from "./utils.js";
5
- import type { RootStore } from "./store.js";
6
- import { type EventHandlers } from "./events.js";
7
- import type { ThreeElement } from "../three-types.js";
8
- declare module 'react-reconciler/constants' {
9
- const NoEventPriority = 0;
10
- }
11
- export interface Root {
12
- fiber: Reconciler.FiberRoot;
13
- store: RootStore;
14
- }
15
- export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
16
- export type AttachType<O = any> = string | AttachFnType<O>;
17
- export type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
18
- export interface Catalogue {
19
- [name: string]: ConstructorRepresentation;
20
- }
21
- export type Args<T> = T extends ConstructorRepresentation ? T extends typeof THREE.Color ? [r: number, g: number, b: number] | [color: THREE.ColorRepresentation] : ConstructorParameters<T> : any[];
22
- type ArgsProp<P> = P extends ConstructorRepresentation ? IsAllOptional<ConstructorParameters<P>> extends true ? {
23
- args?: Args<P>;
24
- } : {
25
- args: Args<P>;
26
- } : {
27
- args: unknown[];
28
- };
29
- export type InstanceProps<T = any, P = any> = ArgsProp<P> & {
30
- object?: T;
31
- visible?: boolean;
32
- dispose?: null;
33
- attach?: AttachType<T>;
34
- onUpdate?: (self: T) => void;
35
- };
36
- export interface Instance<O = any> {
37
- root: RootStore;
38
- type: string;
39
- parent: Instance | null;
40
- children: Instance[];
41
- props: InstanceProps<O> & Record<string, unknown>;
42
- object: O & {
43
- __r3f?: Instance<O>;
44
- };
45
- eventCount: number;
46
- handlers: Partial<EventHandlers>;
47
- attach?: AttachType<O>;
48
- previousAttach?: any;
49
- isHidden: boolean;
50
- }
51
- export declare const catalogue: Catalogue;
52
- export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
53
- export declare function extend<T extends Catalogue>(objects: T): void;
54
- export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, any>;
55
- export {};
@@ -1,80 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as React from 'react';
3
- import type { ThreeElement } from "../three-types.js";
4
- import { Renderer, RootState, Size, Dpr, Performance, Frameloop, RootStore } from "./store.js";
5
- import { Root } from "./reconciler.js";
6
- import { EventManager, ComputeFunction } from "./events.js";
7
- import { type Properties, Camera } from "./utils.js";
8
- interface OffscreenCanvas extends EventTarget {
9
- }
10
- export declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
11
- export type GLProps = Renderer | ((canvas: HTMLCanvasElement | OffscreenCanvas) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>;
12
- export type CameraProps = (Camera | Partial<ThreeElement<typeof THREE.Camera> & ThreeElement<typeof THREE.PerspectiveCamera> & ThreeElement<typeof THREE.OrthographicCamera>>) & {
13
- /** Flags the camera as manual, putting projection into your own hands */
14
- manual?: boolean;
15
- };
16
- export interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
17
- /** A threejs renderer instance or props that go into the default renderer */
18
- gl?: GLProps;
19
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
20
- size?: Size;
21
- /**
22
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
23
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
24
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
25
- */
26
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
27
- /**
28
- * Disables three r139 color management.
29
- * @see https://threejs.org/docs/#manual/en/introduction/Color-management
30
- */
31
- legacy?: boolean;
32
- /** Switch off automatic sRGB encoding and gamma correction */
33
- linear?: boolean;
34
- /** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
35
- flat?: boolean;
36
- /** Creates an orthographic camera */
37
- orthographic?: boolean;
38
- /**
39
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
40
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
41
- */
42
- frameloop?: Frameloop;
43
- /**
44
- * R3F performance options for adaptive performance.
45
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
46
- */
47
- performance?: Partial<Omit<Performance, 'regress'>>;
48
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
49
- dpr?: Dpr;
50
- /** Props that go into the default raycaster */
51
- raycaster?: Partial<THREE.Raycaster>;
52
- /** A `THREE.Scene` instance or props that go into the default scene */
53
- scene?: THREE.Scene | Partial<THREE.Scene>;
54
- /** A `THREE.Camera` instance or props that go into the default camera */
55
- camera?: CameraProps;
56
- /** An R3F event manager to manage elements' pointer events */
57
- events?: (store: RootStore) => EventManager<HTMLElement>;
58
- /** Callback after the canvas has rendered (but not yet committed) */
59
- onCreated?: (state: RootState) => void;
60
- /** Response for pointer clicks that have missed any target */
61
- onPointerMissed?: (event: MouseEvent) => void;
62
- }
63
- export interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
64
- configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
65
- render: (element: React.ReactNode) => RootStore;
66
- unmount: () => void;
67
- }
68
- export declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
69
- export declare function render<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): RootStore;
70
- export declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
71
- export type InjectState = Partial<Omit<RootState, 'events'> & {
72
- events?: {
73
- enabled?: boolean;
74
- priority?: number;
75
- compute?: ComputeFunction;
76
- connected?: any;
77
- };
78
- }>;
79
- export declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.JSX.Element;
80
- export {};
@@ -1,130 +0,0 @@
1
- /// <reference types="webxr" />
2
- import * as THREE from 'three';
3
- import * as React from 'react';
4
- import { type StoreApi } from 'zustand';
5
- import { type UseBoundStoreWithEqualityFn } from 'zustand/traditional';
6
- import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from "./events.js";
7
- import { type Camera } from "./utils.js";
8
- export interface Intersection extends THREE.Intersection {
9
- eventObject: THREE.Object3D;
10
- }
11
- export type Subscription = {
12
- ref: React.RefObject<RenderCallback>;
13
- priority: number;
14
- store: RootStore;
15
- };
16
- export type Dpr = number | [min: number, max: number];
17
- export interface Size {
18
- width: number;
19
- height: number;
20
- top: number;
21
- left: number;
22
- }
23
- export type Frameloop = 'always' | 'demand' | 'never';
24
- export interface Viewport extends Size {
25
- /** The initial pixel ratio */
26
- initialDpr: number;
27
- /** Current pixel ratio */
28
- dpr: number;
29
- /** size.width / viewport.width */
30
- factor: number;
31
- /** Camera distance */
32
- distance: number;
33
- /** Camera aspect ratio: width / height */
34
- aspect: number;
35
- }
36
- export type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void;
37
- export interface Performance {
38
- /** Current performance normal, between min and max */
39
- current: number;
40
- /** How low the performance can go, between 0 and max */
41
- min: number;
42
- /** How high the performance can go, between min and max */
43
- max: number;
44
- /** Time until current returns to max in ms */
45
- debounce: number;
46
- /** Sets current to min, puts the system in regression */
47
- regress: () => void;
48
- }
49
- export interface Renderer {
50
- render: (scene: THREE.Scene, camera: THREE.Camera) => any;
51
- }
52
- export declare const isRenderer: (def: any) => boolean;
53
- export interface InternalState {
54
- interaction: THREE.Object3D[];
55
- hovered: Map<string, ThreeEvent<DomEvent>>;
56
- subscribers: Subscription[];
57
- capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
58
- initialClick: [x: number, y: number];
59
- initialHits: THREE.Object3D[];
60
- lastEvent: React.RefObject<DomEvent | null>;
61
- active: boolean;
62
- priority: number;
63
- frames: number;
64
- subscribe: (callback: React.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void;
65
- }
66
- export interface XRManager {
67
- connect: () => void;
68
- disconnect: () => void;
69
- }
70
- export interface RootState {
71
- /** Set current state */
72
- set: StoreApi<RootState>['setState'];
73
- /** Get current state */
74
- get: StoreApi<RootState>['getState'];
75
- /** The instance of the renderer */
76
- gl: THREE.WebGLRenderer;
77
- /** Default camera */
78
- camera: Camera;
79
- /** Default scene */
80
- scene: THREE.Scene;
81
- /** Default raycaster */
82
- raycaster: THREE.Raycaster;
83
- /** Default clock */
84
- clock: THREE.Clock;
85
- /** Event layer interface, contains the event handler and the node they're connected to */
86
- events: EventManager<any>;
87
- /** XR interface */
88
- xr: XRManager;
89
- /** Currently used controls */
90
- controls: THREE.EventDispatcher | null;
91
- /** Normalized event coordinates */
92
- pointer: THREE.Vector2;
93
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
94
- mouse: THREE.Vector2;
95
- legacy: boolean;
96
- /** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
97
- linear: boolean;
98
- /** Shortcut to gl.toneMapping = NoTonemapping */
99
- flat: boolean;
100
- /** Render loop flags */
101
- frameloop: Frameloop;
102
- performance: Performance;
103
- /** Reactive pixel-size of the canvas */
104
- size: Size;
105
- /** Reactive size of the viewport in threejs units */
106
- viewport: Viewport & {
107
- getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
108
- };
109
- /** Flags the canvas for render, but doesn't render in itself */
110
- invalidate: (frames?: number) => void;
111
- /** Advance (render) one step */
112
- advance: (timestamp: number, runGlobalEffects?: boolean) => void;
113
- /** Shortcut to setting the event layer */
114
- setEvents: (events: Partial<EventManager<any>>) => void;
115
- /** Shortcut to manual sizing */
116
- setSize: (width: number, height: number, top?: number, left?: number) => void;
117
- /** Shortcut to manual setting the pixel ratio */
118
- setDpr: (dpr: Dpr) => void;
119
- /** Shortcut to setting frameloop flags */
120
- setFrameloop: (frameloop: Frameloop) => void;
121
- /** When the canvas was clicked but nothing was hit */
122
- onPointerMissed?: (event: MouseEvent) => void;
123
- /** If this state model is layered (via createPortal) then this contains the previous layer */
124
- previousRoot?: RootStore;
125
- /** Internals */
126
- internal: InternalState;
127
- }
128
- export type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>;
129
- export declare const context: React.Context<RootStore>;
130
- export declare const createStore: (invalidate: (state?: RootState, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
@@ -1,138 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as React from 'react';
3
- import { Instance } from "./reconciler.js";
4
- import type { Fiber } from 'react-reconciler';
5
- import type { Dpr, Renderer, RootStore, Size } from "./store.js";
6
- export type NonFunctionKeys<P> = {
7
- [K in keyof P]-?: P[K] extends Function ? never : K;
8
- }[keyof P];
9
- export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
10
- export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
11
- export type Mutable<P> = {
12
- [K in keyof P]: P[K] | Readonly<P[K]>;
13
- };
14
- export type IsOptional<T> = undefined extends T ? true : false;
15
- export type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest] ? IsOptional<First> extends true ? IsAllOptional<Rest> : false : true;
16
- /**
17
- * Returns the instance's initial (outmost) root.
18
- */
19
- export declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
20
- /**
21
- * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
22
- */
23
- export declare const hasColorSpace: <T extends object | THREE.Texture | Renderer, P = T extends Renderer ? {
24
- outputColorSpace: string;
25
- } : {
26
- colorSpace: string;
27
- }>(object: T) => object is T & P;
28
- export type ColorManagementRepresentation = {
29
- enabled: boolean | never;
30
- } | {
31
- legacyMode: boolean | never;
32
- };
33
- /**
34
- * The current THREE.ColorManagement instance, if present.
35
- */
36
- export declare const getColorManagement: () => ColorManagementRepresentation | null;
37
- export type Act = <T = any>(cb: () => Promise<T>) => Promise<T>;
38
- /**
39
- * Safely flush async effects when testing, simulating a legacy root.
40
- */
41
- export declare const act: Act;
42
- export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & {
43
- manual?: boolean;
44
- };
45
- export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
46
- export declare const isRef: (obj: any) => obj is React.RefObject<unknown>;
47
- /**
48
- * An SSR-friendly useLayoutEffect.
49
- *
50
- * React currently throws a warning when using useLayoutEffect on the server.
51
- * To get around it, we can conditionally useEffect on the server (no-op) and
52
- * useLayoutEffect elsewhere.
53
- *
54
- * @see https://github.com/facebook/react/issues/14927
55
- */
56
- export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
57
- export declare function useMutableCallback<T>(fn: T): React.RefObject<T>;
58
- export type Bridge = React.FC<{
59
- children?: React.ReactNode;
60
- }>;
61
- /**
62
- * Bridges renderer Context and StrictMode from a primary renderer.
63
- */
64
- export declare function useBridge(): Bridge;
65
- export type SetBlock = false | Promise<null> | null;
66
- export type UnblockProps = {
67
- set: React.Dispatch<React.SetStateAction<SetBlock>>;
68
- children: React.ReactNode;
69
- };
70
- export declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
71
- export declare class ErrorBoundary extends React.Component<{
72
- set: React.Dispatch<Error | undefined>;
73
- children: React.ReactNode;
74
- }, {
75
- error: boolean;
76
- }> {
77
- state: {
78
- error: boolean;
79
- };
80
- static getDerivedStateFromError: () => {
81
- error: boolean;
82
- };
83
- componentDidCatch(err: Error): void;
84
- render(): React.ReactNode;
85
- }
86
- export interface ObjectMap {
87
- nodes: {
88
- [name: string]: THREE.Object3D;
89
- };
90
- materials: {
91
- [name: string]: THREE.Material;
92
- };
93
- }
94
- export declare function calculateDpr(dpr: Dpr): number;
95
- /**
96
- * Returns instance root state
97
- */
98
- export declare function getRootState<T extends THREE.Object3D = THREE.Object3D>(obj: T): import("./store.js").RootState | undefined;
99
- export interface EquConfig {
100
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
101
- arrays?: 'reference' | 'shallow';
102
- /** Compare objects by reference equality a === b (default), or by shallow equality */
103
- objects?: 'reference' | 'shallow';
104
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
105
- strict?: boolean;
106
- }
107
- export declare const is: {
108
- obj: (a: any) => boolean;
109
- fun: (a: any) => a is Function;
110
- str: (a: any) => a is string;
111
- num: (a: any) => a is number;
112
- boo: (a: any) => a is boolean;
113
- und: (a: any) => boolean;
114
- arr: (a: any) => boolean;
115
- equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
116
- };
117
- export declare function buildGraph(object: THREE.Object3D): ObjectMap;
118
- export interface Disposable {
119
- type?: string;
120
- dispose?: () => void;
121
- }
122
- export declare function dispose<T extends Disposable>(obj: T): void;
123
- export declare const REACT_INTERNAL_PROPS: string[];
124
- export declare function getInstanceProps<T = any>(queue: Fiber['pendingProps']): Instance<T>['props'];
125
- export declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
126
- export declare function resolve(root: any, key: string): {
127
- root: any;
128
- key: string;
129
- target: any;
130
- };
131
- export declare function attach(parent: Instance, child: Instance): void;
132
- export declare function detach(parent: Instance, child: Instance): void;
133
- export declare const RESERVED_PROPS: string[];
134
- export declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
135
- export declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
136
- export declare function invalidateInstance(instance: Instance): void;
137
- export declare function updateCamera(camera: Camera, size: Size): void;
138
- export declare const isObject3D: (object: any) => object is THREE.Object3D<THREE.Event>;
@@ -1,6 +0,0 @@
1
- import * as ReactThreeFiber from "./three-types.js";
2
- export { ReactThreeFiber };
3
- export * from "./three-types.js";
4
- export * from "./core/index.js";
5
- export * from "./web/Canvas.js";
6
- export { createPointerEvents as events } from "./web/events.js";
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- import { View, ViewProps, ViewStyle } from 'react-native';
3
- import { RenderProps } from "../core/index.js";
4
- export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'dpr'>, Omit<ViewProps, 'children'> {
5
- children: React.ReactNode;
6
- style?: ViewStyle;
7
- }
8
- export interface Props extends CanvasProps {
9
- }
10
- /**
11
- * A native canvas which accepts threejs elements as children.
12
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
13
- */
14
- export declare const Canvas: React.ForwardRefExoticComponent<CanvasProps & React.RefAttributes<View>>;
@@ -1,4 +0,0 @@
1
- import { RootStore } from "../core/store.js";
2
- import { EventManager } from "../core/events.js";
3
- /** Default R3F event manager for react-native */
4
- export declare function createTouchEvents(store: RootStore): EventManager<HTMLElement>;
@@ -1,6 +0,0 @@
1
- import * as ReactThreeFiber from "./three-types.js";
2
- export { ReactThreeFiber };
3
- export * from "./three-types.js";
4
- export * from "./core/index.js";
5
- export * from "./native/Canvas.js";
6
- export { createTouchEvents as events } from "./native/events.js";
@@ -1,62 +0,0 @@
1
- import type * as THREE from 'three';
2
- import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } from "./core/index.js";
3
- import type { Overwrite, Mutable } from "./core/utils.js";
4
- export interface MathRepresentation {
5
- set(...args: number[]): any;
6
- }
7
- export interface VectorRepresentation extends MathRepresentation {
8
- setScalar(value: number): any;
9
- }
10
- export type MathTypes = MathRepresentation | THREE.Euler | THREE.Color;
11
- export type MathType<T extends MathTypes> = T extends THREE.Color ? Args<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number : T | Parameters<T['set']>;
12
- export type MathProps<P> = {
13
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never;
14
- };
15
- export type Vector2 = MathType<THREE.Vector2>;
16
- export type Vector3 = MathType<THREE.Vector3>;
17
- export type Vector4 = MathType<THREE.Vector4>;
18
- export type Color = MathType<THREE.Color>;
19
- export type Layers = MathType<THREE.Layers>;
20
- export type Quaternion = MathType<THREE.Quaternion>;
21
- export type Euler = MathType<THREE.Euler>;
22
- export type Matrix3 = MathType<THREE.Matrix3>;
23
- export type Matrix4 = MathType<THREE.Matrix4>;
24
- export interface RaycastableRepresentation {
25
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
26
- }
27
- export type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
28
- export interface ReactProps<P> {
29
- children?: React.ReactNode;
30
- ref?: React.Ref<P>;
31
- key?: React.Key;
32
- }
33
- export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
34
- export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
35
- type ThreeExports = typeof THREE;
36
- type ThreeElementsImpl = {
37
- [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never;
38
- };
39
- export interface ThreeElements extends ThreeElementsImpl {
40
- primitive: Omit<ThreeElement<any>, 'args'> & {
41
- object: object;
42
- };
43
- }
44
- declare module 'react' {
45
- namespace JSX {
46
- interface IntrinsicElements extends ThreeElements {
47
- }
48
- }
49
- }
50
- declare module 'react/jsx-runtime' {
51
- namespace JSX {
52
- interface IntrinsicElements extends ThreeElements {
53
- }
54
- }
55
- }
56
- declare module 'react/jsx-dev-runtime' {
57
- namespace JSX {
58
- interface IntrinsicElements extends ThreeElements {
59
- }
60
- }
61
- }
62
- export {};
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from "../core/index.js";
4
- export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- /** Canvas fallback content, similar to img's alt prop */
7
- fallback?: React.ReactNode;
8
- /**
9
- * Options to pass to useMeasure.
10
- * @see https://github.com/pmndrs/react-use-measure#api
11
- */
12
- resize?: ResizeOptions;
13
- /** The target where events are being subscribed to, default: the div that wraps canvas */
14
- eventSource?: HTMLElement | React.RefObject<HTMLElement>;
15
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
16
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
17
- }
18
- export interface Props extends CanvasProps {
19
- }
20
- /**
21
- * A DOM canvas which accepts threejs elements as children.
22
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
23
- */
24
- export declare const Canvas: React.ForwardRefExoticComponent<CanvasProps & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +0,0 @@
1
- import { RootStore } from "../core/store.js";
2
- import { EventManager } from "../core/events.js";
3
- /** Default R3F event manager for web */
4
- export declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;