@react-three/fiber 7.0.26 → 7.0.27
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 +0 -6
- package/dist/declarations/src/core/events.d.ts +63 -63
- package/dist/declarations/src/core/hooks.d.ts +32 -29
- package/dist/declarations/src/core/is.d.ts +9 -9
- package/dist/declarations/src/core/loop.d.ts +12 -12
- package/dist/declarations/src/core/renderer.d.ts +61 -61
- package/dist/declarations/src/core/store.d.ts +118 -118
- package/dist/declarations/src/index.d.ts +8 -7
- package/dist/declarations/src/three-types.d.ts +329 -311
- package/dist/declarations/src/web/Canvas.d.ts +13 -13
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/declarations/src/web/index.d.ts +36 -36
- package/dist/react-three-fiber.cjs.dev.js +38 -35
- package/dist/react-three-fiber.cjs.prod.js +38 -35
- package/dist/react-three-fiber.esm.js +32 -28
- package/native/dist/react-three-fiber-native.cjs.d.ts +11 -1
- package/native/dist/react-three-fiber-native.cjs.js +15 -6
- package/package.json +2 -1
- package/native/dist/react-three-fiber-native.cjs.dev.js +0 -358
- package/native/dist/react-three-fiber-native.cjs.prod.js +0 -358
- package/native/dist/react-three-fiber-native.esm.js +0 -306
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from './index';
|
|
4
|
-
import {
|
|
5
|
-
import { RootState } from '../core/store';
|
|
6
|
-
import { EventManager } from '../core/events';
|
|
7
|
-
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'events'>, React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
fallback?: React.ReactNode;
|
|
10
|
-
resize?: ResizeOptions;
|
|
11
|
-
events?: (store:
|
|
12
|
-
}
|
|
13
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from './index';
|
|
4
|
+
import { UseBoundStore } from 'zustand';
|
|
5
|
+
import { RootState } from '../core/store';
|
|
6
|
+
import { EventManager } from '../core/events';
|
|
7
|
+
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'events'>, React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
resize?: ResizeOptions;
|
|
11
|
+
events?: (store: UseBoundStore<RootState>) => EventManager<any>;
|
|
12
|
+
}
|
|
13
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import type { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store:
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import type { EventManager } from '../core/events';
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/// <reference types="react-reconciler" />
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { Renderer, StoreProps, context, RootState, Size } from '../core/store';
|
|
6
|
-
import { extend, Root } from '../core/renderer';
|
|
7
|
-
import { addEffect, addAfterEffect, addTail } from '../core/loop';
|
|
8
|
-
import { createPointerEvents as events } from './events';
|
|
9
|
-
import { Canvas } from './Canvas';
|
|
10
|
-
import { EventManager } from '../core/events';
|
|
11
|
-
declare const roots: Map<Element, Root>;
|
|
12
|
-
declare const modes: readonly ["legacy", "blocking", "concurrent"];
|
|
13
|
-
declare const invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined) => void;
|
|
14
|
-
declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: (instance: import("../core/renderer").Instance, data: import("../core/renderer").
|
|
15
|
-
declare type Properties<T> = Pick<T, {
|
|
16
|
-
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
17
|
-
}[keyof T]>;
|
|
18
|
-
declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
19
|
-
export declare type RenderProps<TCanvas extends Element> = Omit<StoreProps, 'gl' | 'events' | 'size'> & {
|
|
20
|
-
gl?: GLProps;
|
|
21
|
-
events?: (store:
|
|
22
|
-
size?: Size;
|
|
23
|
-
mode?: typeof modes[number];
|
|
24
|
-
onCreated?: (state: RootState) => void;
|
|
25
|
-
};
|
|
26
|
-
declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, { gl, size, mode, events, onCreated, ...props }?: RenderProps<TCanvas>):
|
|
27
|
-
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
28
|
-
declare function dispose<TObj extends {
|
|
29
|
-
dispose?: () => void;
|
|
30
|
-
type?: string;
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}>(obj: TObj): void;
|
|
33
|
-
declare const act: (callback: () => import("react-reconciler").Thenable<unknown>) => import("react-reconciler").Thenable<void>;
|
|
34
|
-
declare function createPortal(children: React.ReactNode, container: THREE.Object3D): React.ReactNode;
|
|
35
|
-
export * from '../core/hooks';
|
|
36
|
-
export { context, render, unmountComponentAtNode, createPortal, events, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, Canvas, act, roots as _roots, };
|
|
1
|
+
/// <reference types="react-reconciler" />
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { UseBoundStore } from 'zustand';
|
|
5
|
+
import { Renderer, StoreProps, context, RootState, Size } from '../core/store';
|
|
6
|
+
import { extend, Root } from '../core/renderer';
|
|
7
|
+
import { addEffect, addAfterEffect, addTail } from '../core/loop';
|
|
8
|
+
import { createPointerEvents as events } from './events';
|
|
9
|
+
import { Canvas } from './Canvas';
|
|
10
|
+
import { EventManager } from '../core/events';
|
|
11
|
+
declare const roots: Map<Element, Root>;
|
|
12
|
+
declare const modes: readonly ["legacy", "blocking", "concurrent"];
|
|
13
|
+
declare const invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined) => void;
|
|
14
|
+
declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: (instance: import("../core/renderer").Instance, data: import("../core/renderer").DiffSet | import("../core/renderer").InstanceProps) => import("../core/renderer").Instance;
|
|
15
|
+
declare type Properties<T> = Pick<T, {
|
|
16
|
+
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
17
|
+
}[keyof T]>;
|
|
18
|
+
declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
19
|
+
export declare type RenderProps<TCanvas extends Element> = Omit<StoreProps, 'gl' | 'events' | 'size'> & {
|
|
20
|
+
gl?: GLProps;
|
|
21
|
+
events?: (store: UseBoundStore<RootState>) => EventManager<TCanvas>;
|
|
22
|
+
size?: Size;
|
|
23
|
+
mode?: typeof modes[number];
|
|
24
|
+
onCreated?: (state: RootState) => void;
|
|
25
|
+
};
|
|
26
|
+
declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, { gl, size, mode, events, onCreated, ...props }?: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
27
|
+
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
28
|
+
declare function dispose<TObj extends {
|
|
29
|
+
dispose?: () => void;
|
|
30
|
+
type?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}>(obj: TObj): void;
|
|
33
|
+
declare const act: (callback: () => import("react-reconciler").Thenable<unknown>) => import("react-reconciler").Thenable<void>;
|
|
34
|
+
declare function createPortal(children: React.ReactNode, container: THREE.Object3D): React.ReactNode;
|
|
35
|
+
export * from '../core/hooks';
|
|
36
|
+
export { context, render, unmountComponentAtNode, createPortal, events, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, Canvas, act, roots as _roots, };
|
|
@@ -22,14 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
23
|
Object.defineProperty(n, k, d.get ? d : {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return e[k];
|
|
27
|
-
}
|
|
25
|
+
get: function () { return e[k]; }
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
n[
|
|
30
|
+
n["default"] = e;
|
|
33
31
|
return Object.freeze(n);
|
|
34
32
|
}
|
|
35
33
|
|
|
@@ -626,29 +624,29 @@ function createRenderer(roots) {
|
|
|
626
624
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
627
625
|
} // Special treatment for objects with support for set/copy, and layers
|
|
628
626
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
642
|
-
|
|
643
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
644
|
-
} // Else, just overwrite the value
|
|
645
|
-
|
|
646
|
-
} else {
|
|
647
|
-
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
627
|
+
// If value is an array
|
|
628
|
+
if (Array.isArray(value)) {
|
|
629
|
+
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
630
|
+
} // Test again target.copy(class) next ...
|
|
631
|
+
else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) targetProp.copy(value); // If nothing else fits, just set the single value, ignore undefined
|
|
632
|
+
// https://github.com/pmndrs/react-three-fiber/issues/274
|
|
633
|
+
else if (value !== undefined) {
|
|
634
|
+
const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
|
|
635
|
+
|
|
636
|
+
if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
|
|
637
|
+
else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
|
|
638
|
+
else targetProp.set(value); // Auto-convert sRGB colors, for now ...
|
|
648
639
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
649
640
|
|
|
650
|
-
if (!isLinear &&
|
|
651
|
-
}
|
|
641
|
+
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
642
|
+
} // Else, just overwrite the value
|
|
643
|
+
|
|
644
|
+
} else {
|
|
645
|
+
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
646
|
+
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
647
|
+
|
|
648
|
+
if (!isLinear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
|
|
649
|
+
}
|
|
652
650
|
|
|
653
651
|
invalidateInstance(instance);
|
|
654
652
|
});
|
|
@@ -942,7 +940,7 @@ function createRenderer(roots) {
|
|
|
942
940
|
});
|
|
943
941
|
}
|
|
944
942
|
|
|
945
|
-
const reconciler = Reconciler__default[
|
|
943
|
+
const reconciler = Reconciler__default["default"]({
|
|
946
944
|
now: scheduler.unstable_now,
|
|
947
945
|
createInstance,
|
|
948
946
|
removeChild,
|
|
@@ -1056,9 +1054,7 @@ function createRenderer(roots) {
|
|
|
1056
1054
|
return !!localState.handlers;
|
|
1057
1055
|
},
|
|
1058
1056
|
|
|
1059
|
-
commitMount(instance)
|
|
1060
|
-
/*, type, props*/
|
|
1061
|
-
{
|
|
1057
|
+
commitMount(instance) {
|
|
1062
1058
|
var _instance$__r3f8;
|
|
1063
1059
|
|
|
1064
1060
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1136,7 +1132,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
|
|
|
1136
1132
|
clock.elapsedTime = 0;
|
|
1137
1133
|
}
|
|
1138
1134
|
|
|
1139
|
-
const rootState = create__default[
|
|
1135
|
+
const rootState = create__default["default"]((set, get) => {
|
|
1140
1136
|
// Create custom raycaster
|
|
1141
1137
|
const raycaster = new THREE__namespace.Raycaster();
|
|
1142
1138
|
const {
|
|
@@ -1570,10 +1566,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1570
1566
|
events,
|
|
1571
1567
|
...props
|
|
1572
1568
|
}, forwardedRef) {
|
|
1569
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1573
1570
|
const [containerRef, {
|
|
1574
1571
|
width,
|
|
1575
1572
|
height
|
|
1576
|
-
}] = useMeasure__default[
|
|
1573
|
+
}] = useMeasure__default["default"]({
|
|
1577
1574
|
scroll: true,
|
|
1578
1575
|
debounce: {
|
|
1579
1576
|
scroll: 50,
|
|
@@ -1602,10 +1599,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1602
1599
|
width,
|
|
1603
1600
|
height
|
|
1604
1601
|
},
|
|
1602
|
+
onPointerMissed,
|
|
1605
1603
|
events: events || createPointerEvents
|
|
1606
1604
|
});
|
|
1607
1605
|
}
|
|
1608
|
-
}, [width, height, children]);
|
|
1606
|
+
}, [width, height, children, onPointerMissed]);
|
|
1609
1607
|
useIsomorphicLayoutEffect(() => {
|
|
1610
1608
|
const container = canvasRef.current;
|
|
1611
1609
|
return () => unmountComponentAtNode(container);
|
|
@@ -1623,7 +1621,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1623
1621
|
...style
|
|
1624
1622
|
}
|
|
1625
1623
|
}, /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
1626
|
-
ref: mergeRefs__default[
|
|
1624
|
+
ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
|
|
1627
1625
|
style: {
|
|
1628
1626
|
display: 'block'
|
|
1629
1627
|
}
|
|
@@ -1686,6 +1684,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1686
1684
|
};
|
|
1687
1685
|
}
|
|
1688
1686
|
|
|
1687
|
+
function useMemoizedFn(fn) {
|
|
1688
|
+
const fnRef = React__namespace.useRef(fn);
|
|
1689
|
+
React__namespace.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1690
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1691
|
+
}
|
|
1689
1692
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1690
1693
|
// Use suspense to load async assets
|
|
1691
1694
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1871,8 +1874,7 @@ function dispose(obj) {
|
|
|
1871
1874
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1872
1875
|
|
|
1873
1876
|
for (const p in obj) {
|
|
1874
|
-
|
|
1875
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1877
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1876
1878
|
delete obj[p];
|
|
1877
1879
|
}
|
|
1878
1880
|
}
|
|
@@ -1910,5 +1912,6 @@ exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
|
1910
1912
|
exports.useFrame = useFrame;
|
|
1911
1913
|
exports.useGraph = useGraph;
|
|
1912
1914
|
exports.useLoader = useLoader;
|
|
1915
|
+
exports.useMemoizedFn = useMemoizedFn;
|
|
1913
1916
|
exports.useStore = useStore;
|
|
1914
1917
|
exports.useThree = useThree;
|
|
@@ -22,14 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
23
|
Object.defineProperty(n, k, d.get ? d : {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return e[k];
|
|
27
|
-
}
|
|
25
|
+
get: function () { return e[k]; }
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
n[
|
|
30
|
+
n["default"] = e;
|
|
33
31
|
return Object.freeze(n);
|
|
34
32
|
}
|
|
35
33
|
|
|
@@ -626,29 +624,29 @@ function createRenderer(roots) {
|
|
|
626
624
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
627
625
|
} // Special treatment for objects with support for set/copy, and layers
|
|
628
626
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
642
|
-
|
|
643
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
644
|
-
} // Else, just overwrite the value
|
|
645
|
-
|
|
646
|
-
} else {
|
|
647
|
-
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
627
|
+
// If value is an array
|
|
628
|
+
if (Array.isArray(value)) {
|
|
629
|
+
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
630
|
+
} // Test again target.copy(class) next ...
|
|
631
|
+
else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) targetProp.copy(value); // If nothing else fits, just set the single value, ignore undefined
|
|
632
|
+
// https://github.com/pmndrs/react-three-fiber/issues/274
|
|
633
|
+
else if (value !== undefined) {
|
|
634
|
+
const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
|
|
635
|
+
|
|
636
|
+
if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
|
|
637
|
+
else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
|
|
638
|
+
else targetProp.set(value); // Auto-convert sRGB colors, for now ...
|
|
648
639
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
649
640
|
|
|
650
|
-
if (!isLinear &&
|
|
651
|
-
}
|
|
641
|
+
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
642
|
+
} // Else, just overwrite the value
|
|
643
|
+
|
|
644
|
+
} else {
|
|
645
|
+
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
646
|
+
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
647
|
+
|
|
648
|
+
if (!isLinear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
|
|
649
|
+
}
|
|
652
650
|
|
|
653
651
|
invalidateInstance(instance);
|
|
654
652
|
});
|
|
@@ -942,7 +940,7 @@ function createRenderer(roots) {
|
|
|
942
940
|
});
|
|
943
941
|
}
|
|
944
942
|
|
|
945
|
-
const reconciler = Reconciler__default[
|
|
943
|
+
const reconciler = Reconciler__default["default"]({
|
|
946
944
|
now: scheduler.unstable_now,
|
|
947
945
|
createInstance,
|
|
948
946
|
removeChild,
|
|
@@ -1056,9 +1054,7 @@ function createRenderer(roots) {
|
|
|
1056
1054
|
return !!localState.handlers;
|
|
1057
1055
|
},
|
|
1058
1056
|
|
|
1059
|
-
commitMount(instance)
|
|
1060
|
-
/*, type, props*/
|
|
1061
|
-
{
|
|
1057
|
+
commitMount(instance) {
|
|
1062
1058
|
var _instance$__r3f8;
|
|
1063
1059
|
|
|
1064
1060
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1136,7 +1132,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
|
|
|
1136
1132
|
clock.elapsedTime = 0;
|
|
1137
1133
|
}
|
|
1138
1134
|
|
|
1139
|
-
const rootState = create__default[
|
|
1135
|
+
const rootState = create__default["default"]((set, get) => {
|
|
1140
1136
|
// Create custom raycaster
|
|
1141
1137
|
const raycaster = new THREE__namespace.Raycaster();
|
|
1142
1138
|
const {
|
|
@@ -1570,10 +1566,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1570
1566
|
events,
|
|
1571
1567
|
...props
|
|
1572
1568
|
}, forwardedRef) {
|
|
1569
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1573
1570
|
const [containerRef, {
|
|
1574
1571
|
width,
|
|
1575
1572
|
height
|
|
1576
|
-
}] = useMeasure__default[
|
|
1573
|
+
}] = useMeasure__default["default"]({
|
|
1577
1574
|
scroll: true,
|
|
1578
1575
|
debounce: {
|
|
1579
1576
|
scroll: 50,
|
|
@@ -1602,10 +1599,11 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1602
1599
|
width,
|
|
1603
1600
|
height
|
|
1604
1601
|
},
|
|
1602
|
+
onPointerMissed,
|
|
1605
1603
|
events: events || createPointerEvents
|
|
1606
1604
|
});
|
|
1607
1605
|
}
|
|
1608
|
-
}, [width, height, children]);
|
|
1606
|
+
}, [width, height, children, onPointerMissed]);
|
|
1609
1607
|
useIsomorphicLayoutEffect(() => {
|
|
1610
1608
|
const container = canvasRef.current;
|
|
1611
1609
|
return () => unmountComponentAtNode(container);
|
|
@@ -1623,7 +1621,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
1623
1621
|
...style
|
|
1624
1622
|
}
|
|
1625
1623
|
}, /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
1626
|
-
ref: mergeRefs__default[
|
|
1624
|
+
ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
|
|
1627
1625
|
style: {
|
|
1628
1626
|
display: 'block'
|
|
1629
1627
|
}
|
|
@@ -1686,6 +1684,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1686
1684
|
};
|
|
1687
1685
|
}
|
|
1688
1686
|
|
|
1687
|
+
function useMemoizedFn(fn) {
|
|
1688
|
+
const fnRef = React__namespace.useRef(fn);
|
|
1689
|
+
React__namespace.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1690
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1691
|
+
}
|
|
1689
1692
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1690
1693
|
// Use suspense to load async assets
|
|
1691
1694
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1871,8 +1874,7 @@ function dispose(obj) {
|
|
|
1871
1874
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1872
1875
|
|
|
1873
1876
|
for (const p in obj) {
|
|
1874
|
-
|
|
1875
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1877
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1876
1878
|
delete obj[p];
|
|
1877
1879
|
}
|
|
1878
1880
|
}
|
|
@@ -1910,5 +1912,6 @@ exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
|
1910
1912
|
exports.useFrame = useFrame;
|
|
1911
1913
|
exports.useGraph = useGraph;
|
|
1912
1914
|
exports.useLoader = useLoader;
|
|
1915
|
+
exports.useMemoizedFn = useMemoizedFn;
|
|
1913
1916
|
exports.useStore = useStore;
|
|
1914
1917
|
exports.useThree = useThree;
|
|
@@ -593,29 +593,29 @@ function createRenderer(roots) {
|
|
|
593
593
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
594
594
|
} // Special treatment for objects with support for set/copy, and layers
|
|
595
595
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE.Layers)) {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
609
|
-
|
|
610
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
611
|
-
} // Else, just overwrite the value
|
|
612
|
-
|
|
613
|
-
} else {
|
|
614
|
-
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
596
|
+
// If value is an array
|
|
597
|
+
if (Array.isArray(value)) {
|
|
598
|
+
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
599
|
+
} // Test again target.copy(class) next ...
|
|
600
|
+
else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) targetProp.copy(value); // If nothing else fits, just set the single value, ignore undefined
|
|
601
|
+
// https://github.com/pmndrs/react-three-fiber/issues/274
|
|
602
|
+
else if (value !== undefined) {
|
|
603
|
+
const isColor = targetProp instanceof THREE.Color; // Allow setting array scalars
|
|
604
|
+
|
|
605
|
+
if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
|
|
606
|
+
else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) targetProp.mask = value.mask; // Otherwise just set ...
|
|
607
|
+
else targetProp.set(value); // Auto-convert sRGB colors, for now ...
|
|
615
608
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
616
609
|
|
|
617
|
-
if (!isLinear &&
|
|
618
|
-
}
|
|
610
|
+
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
611
|
+
} // Else, just overwrite the value
|
|
612
|
+
|
|
613
|
+
} else {
|
|
614
|
+
currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
|
|
615
|
+
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
616
|
+
|
|
617
|
+
if (!isLinear && currentInstance[key] instanceof THREE.Texture) currentInstance[key].encoding = THREE.sRGBEncoding;
|
|
618
|
+
}
|
|
619
619
|
|
|
620
620
|
invalidateInstance(instance);
|
|
621
621
|
});
|
|
@@ -1023,9 +1023,7 @@ function createRenderer(roots) {
|
|
|
1023
1023
|
return !!localState.handlers;
|
|
1024
1024
|
},
|
|
1025
1025
|
|
|
1026
|
-
commitMount(instance)
|
|
1027
|
-
/*, type, props*/
|
|
1028
|
-
{
|
|
1026
|
+
commitMount(instance) {
|
|
1029
1027
|
var _instance$__r3f8;
|
|
1030
1028
|
|
|
1031
1029
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1537,6 +1535,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1537
1535
|
events,
|
|
1538
1536
|
...props
|
|
1539
1537
|
}, forwardedRef) {
|
|
1538
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1540
1539
|
const [containerRef, {
|
|
1541
1540
|
width,
|
|
1542
1541
|
height
|
|
@@ -1569,10 +1568,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1569
1568
|
width,
|
|
1570
1569
|
height
|
|
1571
1570
|
},
|
|
1571
|
+
onPointerMissed,
|
|
1572
1572
|
events: events || createPointerEvents
|
|
1573
1573
|
});
|
|
1574
1574
|
}
|
|
1575
|
-
}, [width, height, children]);
|
|
1575
|
+
}, [width, height, children, onPointerMissed]);
|
|
1576
1576
|
useIsomorphicLayoutEffect(() => {
|
|
1577
1577
|
const container = canvasRef.current;
|
|
1578
1578
|
return () => unmountComponentAtNode(container);
|
|
@@ -1653,6 +1653,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1653
1653
|
};
|
|
1654
1654
|
}
|
|
1655
1655
|
|
|
1656
|
+
function useMemoizedFn(fn) {
|
|
1657
|
+
const fnRef = React.useRef(fn);
|
|
1658
|
+
React.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1659
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1660
|
+
}
|
|
1656
1661
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1657
1662
|
// Use suspense to load async assets
|
|
1658
1663
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1838,8 +1843,7 @@ function dispose(obj) {
|
|
|
1838
1843
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1839
1844
|
|
|
1840
1845
|
for (const p in obj) {
|
|
1841
|
-
|
|
1842
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1846
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1843
1847
|
delete obj[p];
|
|
1844
1848
|
}
|
|
1845
1849
|
}
|
|
@@ -1856,4 +1860,4 @@ reconciler.injectIntoDevTools({
|
|
|
1856
1860
|
version: '17.0.2'
|
|
1857
1861
|
});
|
|
1858
1862
|
|
|
1859
|
-
export { Canvas, threeTypes as ReactThreeFiber, roots as _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, context, createPortal, dispose, createPointerEvents as events, extend, invalidate, reconciler, render, unmountComponentAtNode, useFrame, useGraph, useLoader, useStore, useThree };
|
|
1863
|
+
export { Canvas, threeTypes as ReactThreeFiber, roots as _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, context, createPortal, dispose, createPointerEvents as events, extend, invalidate, reconciler, render, unmountComponentAtNode, useFrame, useGraph, useLoader, useMemoizedFn, useStore, useThree };
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../../src/native";
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../src/native.tsx");
|
|
15
|
+
|
|
16
|
+
unregister();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/fiber",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.27",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "^7.13.10",
|
|
45
|
+
"@types/react-reconciler": "^0.26.2",
|
|
45
46
|
"react-merge-refs": "^1.1.0",
|
|
46
47
|
"react-reconciler": "^0.26.2",
|
|
47
48
|
"react-three-fiber": "0.0.0-deprecated",
|