@react-three/fiber 9.0.0-alpha.2 → 9.0.0-alpha.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +962 -522
  2. package/dist/declarations/src/core/events.d.ts +91 -69
  3. package/dist/declarations/src/core/hooks.d.ts +53 -27
  4. package/dist/declarations/src/core/index.d.ts +15 -60
  5. package/dist/declarations/src/core/loop.d.ts +31 -15
  6. package/dist/declarations/src/core/reconciler.d.ts +43 -0
  7. package/dist/declarations/src/core/renderer.d.ts +85 -40
  8. package/dist/declarations/src/core/stages.d.ts +64 -59
  9. package/dist/declarations/src/core/store.d.ts +147 -109
  10. package/dist/declarations/src/core/utils.d.ts +128 -80
  11. package/dist/declarations/src/index.d.ts +6 -10
  12. package/dist/declarations/src/native/Canvas.d.ts +14 -8
  13. package/dist/declarations/src/native/events.d.ts +4 -4
  14. package/dist/declarations/src/native.d.ts +6 -8
  15. package/dist/declarations/src/three-types.d.ts +56 -47
  16. package/dist/declarations/src/web/Canvas.d.ts +24 -11
  17. package/dist/declarations/src/web/events.d.ts +4 -4
  18. package/dist/{index-5bd4d3cf.cjs.dev.js → loop-0698c205.cjs.dev.js} +1469 -1268
  19. package/dist/{index-8128f248.cjs.prod.js → loop-a0ef8208.cjs.prod.js} +1469 -1268
  20. package/dist/{index-47b7622a.esm.js → loop-b2aca207.esm.js} +1466 -1268
  21. package/dist/react-three-fiber.cjs.d.ts +1 -0
  22. package/dist/react-three-fiber.cjs.dev.js +126 -115
  23. package/dist/react-three-fiber.cjs.prod.js +126 -115
  24. package/dist/react-three-fiber.esm.js +92 -84
  25. package/native/dist/react-three-fiber-native.cjs.d.ts +1 -0
  26. package/native/dist/react-three-fiber-native.cjs.dev.js +278 -211
  27. package/native/dist/react-three-fiber-native.cjs.prod.js +278 -211
  28. package/native/dist/react-three-fiber-native.esm.js +242 -180
  29. package/native/package.json +5 -5
  30. package/package.json +18 -12
  31. package/readme.md +253 -202
  32. package/dist/declarations/src/native/polyfills.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import { UseBoundStore } from 'zustand';
2
- import { RootState } from '../core/store';
3
- import { EventManager } from '../core/events';
4
- export declare function createTouchEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
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,8 +1,6 @@
1
- export * from './three-types';
2
- export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from './core/renderer';
3
- export type { Intersection, Subscription, Dpr, Size, Viewport, RenderCallback, Performance, RootState, } from './core/store';
4
- export type { ThreeEvent, Events, EventManager, ComputeFunction } from './core/events';
5
- export type { ObjectMap, Camera } from './core/utils';
6
- export * from './native/Canvas';
7
- export { createTouchEvents as events } from './native/events';
8
- export * from './core';
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,47 +1,56 @@
1
- /// <reference types="react" />
2
- import type * as THREE from 'three';
3
- import type { EventHandlers } from './core/events';
4
- import type { InstanceProps, ConstructorRepresentation } from './core/renderer';
5
- declare type Mutable<P> = {
6
- [K in keyof P]: P[K] | Readonly<P[K]>;
7
- };
8
- declare type NonFunctionKeys<P> = {
9
- [K in keyof P]-?: P[K] extends Function ? never : K;
10
- }[keyof P];
11
- declare type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
12
- interface MathRepresentation {
13
- set(...args: any[]): any;
14
- }
15
- interface VectorRepresentation extends MathRepresentation {
16
- setScalar(s: number): any;
17
- }
18
- declare type MathProps<P> = {
19
- [K in keyof P]: P[K] extends infer M ? M extends THREE.Color ? ConstructorParameters<typeof THREE.Color> | THREE.ColorRepresentation : M extends MathRepresentation ? M extends VectorRepresentation ? M | Parameters<M['set']> | Parameters<M['setScalar']>[0] : M | Parameters<M['set']> : {} : {};
20
- };
21
- interface RaycastableRepresentation {
22
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
23
- }
24
- declare type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
25
- interface ReactProps<P> {
26
- children?: React.ReactNode;
27
- ref?: React.Ref<P>;
28
- key?: React.Key;
29
- }
30
- declare type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, ReactProps<P> & MathProps<P> & EventProps<P>>>;
31
- export declare type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>>, 'object'>>>;
32
- declare type ThreeExports = typeof THREE;
33
- declare type ThreeElementsImpl = {
34
- [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never;
35
- };
36
- export interface ThreeElements extends ThreeElementsImpl {
37
- primitive: Omit<ThreeElement<any>, 'args'> & {
38
- object: object;
39
- };
40
- }
41
- declare global {
42
- namespace JSX {
43
- interface IntrinsicElements extends ThreeElements {
44
- }
45
- }
46
- }
47
- export {};
1
+ import type * as THREE from 'three';
2
+ import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } from "./core/index.js";
3
+ type NonFunctionKeys<P> = {
4
+ [K in keyof P]-?: P[K] extends Function ? never : K;
5
+ }[keyof P];
6
+ export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
7
+ export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
8
+ export type Mutable<P> = {
9
+ [K in keyof P]: P[K] | Readonly<P[K]>;
10
+ };
11
+ export interface MathRepresentation {
12
+ set(...args: number[]): any;
13
+ }
14
+ export interface VectorRepresentation extends MathRepresentation {
15
+ setScalar(s: number): any;
16
+ }
17
+ export type MathType<T extends MathRepresentation | THREE.Euler> = 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']>;
18
+ export type Vector2 = MathType<THREE.Vector2>;
19
+ export type Vector3 = MathType<THREE.Vector3>;
20
+ export type Vector4 = MathType<THREE.Vector4>;
21
+ export type Color = MathType<THREE.Color>;
22
+ export type Layers = MathType<THREE.Layers>;
23
+ export type Quaternion = MathType<THREE.Quaternion>;
24
+ export type Euler = MathType<THREE.Euler>;
25
+ export type Matrix3 = MathType<THREE.Matrix3>;
26
+ export type Matrix4 = MathType<THREE.Matrix4>;
27
+ export type WithMathProps<P> = {
28
+ [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
29
+ };
30
+ export interface RaycastableRepresentation {
31
+ raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
32
+ }
33
+ export type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
34
+ export interface ReactProps<P> {
35
+ children?: React.ReactNode;
36
+ ref?: React.Ref<P>;
37
+ key?: React.Key;
38
+ }
39
+ export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<WithMathProps<P>, ReactProps<P> & EventProps<P>>>;
40
+ export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
41
+ type ThreeExports = typeof THREE;
42
+ type ThreeElementsImpl = {
43
+ [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never;
44
+ };
45
+ export interface ThreeElements extends ThreeElementsImpl {
46
+ primitive: Omit<ThreeElement<any>, 'args'> & {
47
+ object: object;
48
+ };
49
+ }
50
+ declare global {
51
+ namespace JSX {
52
+ interface IntrinsicElements extends ThreeElements {
53
+ }
54
+ }
55
+ }
56
+ export {};
@@ -1,11 +1,24 @@
1
- import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from '../core';
4
- export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- fallback?: React.ReactNode;
7
- resize?: ResizeOptions;
8
- eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
9
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
- }
11
- export declare const Canvas: React.ForwardRefExoticComponent<CanvasProps & React.RefAttributes<HTMLCanvasElement>>;
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.MutableRefObject<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 +1,4 @@
1
- import { UseBoundStore } from 'zustand';
2
- import { RootState } from '../core/store';
3
- import { EventManager } from '../core/events';
4
- export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
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>;