@react-three/fiber 8.15.12 → 8.15.13
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 +913 -907
- package/dist/declarations/src/core/events.d.ts +93 -93
- package/dist/declarations/src/core/hooks.d.ts +57 -57
- package/dist/declarations/src/core/index.d.ts +87 -87
- package/dist/declarations/src/core/loop.d.ts +33 -33
- package/dist/declarations/src/core/renderer.d.ts +58 -58
- package/dist/declarations/src/core/store.d.ts +137 -137
- package/dist/declarations/src/core/utils.d.ts +125 -125
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +14 -14
- package/dist/declarations/src/native/events.d.ts +5 -5
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +392 -392
- package/dist/declarations/src/web/Canvas.d.ts +24 -24
- package/dist/declarations/src/web/events.d.ts +5 -5
- package/dist/{index-e9909912.cjs.dev.js → index-0ee5ddc9.cjs.dev.js} +75 -75
- package/dist/{index-710e63a4.cjs.prod.js → index-2003c0bb.cjs.prod.js} +75 -75
- package/dist/{index-5bde93f1.esm.js → index-710fb441.esm.js} +75 -75
- package/dist/react-three-fiber.cjs.dev.js +4 -4
- package/dist/react-three-fiber.cjs.prod.js +4 -4
- package/dist/react-three-fiber.esm.js +5 -5
- package/native/dist/react-three-fiber-native.cjs.dev.js +15 -9
- package/native/dist/react-three-fiber-native.cjs.prod.js +15 -9
- package/native/dist/react-three-fiber-native.esm.js +16 -10
- package/native/package.json +5 -5
- package/package.json +1 -1
- package/readme.md +253 -253
|
@@ -1,24 +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
|
-
/** 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<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
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
|
+
/** 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<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
/** Default R3F event manager for web */
|
|
5
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
/** Default R3F event manager for web */
|
|
5
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -381,12 +381,12 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
var _window$document, _window$navigator;
|
|
384
|
-
/**
|
|
385
|
-
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
384
|
+
/**
|
|
385
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
386
386
|
*/
|
|
387
387
|
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
388
|
-
/**
|
|
389
|
-
* The current THREE.ColorManagement instance, if present.
|
|
388
|
+
/**
|
|
389
|
+
* The current THREE.ColorManagement instance, if present.
|
|
390
390
|
*/
|
|
391
391
|
const getColorManagement = () => {
|
|
392
392
|
var _ColorManagement;
|
|
@@ -395,14 +395,14 @@ const getColorManagement = () => {
|
|
|
395
395
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
396
396
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
397
397
|
|
|
398
|
-
/**
|
|
399
|
-
* An SSR-friendly useLayoutEffect.
|
|
400
|
-
*
|
|
401
|
-
* React currently throws a warning when using useLayoutEffect on the server.
|
|
402
|
-
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
403
|
-
* useLayoutEffect elsewhere.
|
|
404
|
-
*
|
|
405
|
-
* @see https://github.com/facebook/react/issues/14927
|
|
398
|
+
/**
|
|
399
|
+
* An SSR-friendly useLayoutEffect.
|
|
400
|
+
*
|
|
401
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
402
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
403
|
+
* useLayoutEffect elsewhere.
|
|
404
|
+
*
|
|
405
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
406
406
|
*/
|
|
407
407
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
408
408
|
function useMutableCallback(fn) {
|
|
@@ -447,8 +447,8 @@ function calculateDpr(dpr) {
|
|
|
447
447
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
/**
|
|
451
|
-
* Returns instance root state
|
|
450
|
+
/**
|
|
451
|
+
* Returns instance root state
|
|
452
452
|
*/
|
|
453
453
|
const getRootState = obj => {
|
|
454
454
|
var _r3f;
|
|
@@ -504,8 +504,8 @@ const is = {
|
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
-
/**
|
|
508
|
-
* Collects nodes and materials from a THREE.Object3D.
|
|
507
|
+
/**
|
|
508
|
+
* Collects nodes and materials from a THREE.Object3D.
|
|
509
509
|
*/
|
|
510
510
|
function buildGraph(object) {
|
|
511
511
|
const data = {
|
|
@@ -845,9 +845,9 @@ function getEventPriority() {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
-
/**
|
|
849
|
-
* Release pointer captures.
|
|
850
|
-
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
848
|
+
/**
|
|
849
|
+
* Release pointer captures.
|
|
850
|
+
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
851
851
|
*/
|
|
852
852
|
function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
|
|
853
853
|
const captureData = captures.get(obj);
|
|
@@ -1182,19 +1182,19 @@ function createEvents(store) {
|
|
|
1182
1182
|
// Check presence of handlers
|
|
1183
1183
|
if (!(instance != null && instance.eventCount)) return;
|
|
1184
1184
|
|
|
1185
|
-
/*
|
|
1186
|
-
MAYBE TODO, DELETE IF NOT:
|
|
1187
|
-
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1188
|
-
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1189
|
-
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1190
|
-
|
|
1191
|
-
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1192
|
-
if (pointerId !== undefined) {
|
|
1193
|
-
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1194
|
-
if (capturedMeshSet) {
|
|
1195
|
-
const captured = capturedMeshSet.get(eventObject)
|
|
1196
|
-
if (captured && captured.localState.stopped) return
|
|
1197
|
-
}
|
|
1185
|
+
/*
|
|
1186
|
+
MAYBE TODO, DELETE IF NOT:
|
|
1187
|
+
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1188
|
+
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1189
|
+
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1190
|
+
|
|
1191
|
+
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1192
|
+
if (pointerId !== undefined) {
|
|
1193
|
+
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1194
|
+
if (capturedMeshSet) {
|
|
1195
|
+
const captured = capturedMeshSet.get(eventObject)
|
|
1196
|
+
if (captured && captured.localState.stopped) return
|
|
1197
|
+
}
|
|
1198
1198
|
}*/
|
|
1199
1199
|
|
|
1200
1200
|
if (isPointerMove) {
|
|
@@ -1500,21 +1500,21 @@ let globalEffects = new Set();
|
|
|
1500
1500
|
let globalAfterEffects = new Set();
|
|
1501
1501
|
let globalTailEffects = new Set();
|
|
1502
1502
|
|
|
1503
|
-
/**
|
|
1504
|
-
* Adds a global render callback which is called each frame.
|
|
1505
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1503
|
+
/**
|
|
1504
|
+
* Adds a global render callback which is called each frame.
|
|
1505
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1506
1506
|
*/
|
|
1507
1507
|
const addEffect = callback => createSubs(callback, globalEffects);
|
|
1508
1508
|
|
|
1509
|
-
/**
|
|
1510
|
-
* Adds a global after-render callback which is called each frame.
|
|
1511
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1509
|
+
/**
|
|
1510
|
+
* Adds a global after-render callback which is called each frame.
|
|
1511
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1512
1512
|
*/
|
|
1513
1513
|
const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
1514
1514
|
|
|
1515
|
-
/**
|
|
1516
|
-
* Adds a global callback which is called when rendering stops.
|
|
1517
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1515
|
+
/**
|
|
1516
|
+
* Adds a global callback which is called when rendering stops.
|
|
1517
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1518
1518
|
*/
|
|
1519
1519
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1520
1520
|
function run(effects, timestamp) {
|
|
@@ -1613,24 +1613,24 @@ function createLoop(roots) {
|
|
|
1613
1613
|
}
|
|
1614
1614
|
return {
|
|
1615
1615
|
loop,
|
|
1616
|
-
/**
|
|
1617
|
-
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1618
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1616
|
+
/**
|
|
1617
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1618
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1619
1619
|
*/
|
|
1620
1620
|
invalidate,
|
|
1621
|
-
/**
|
|
1622
|
-
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1623
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1621
|
+
/**
|
|
1622
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1623
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1624
1624
|
*/
|
|
1625
1625
|
advance
|
|
1626
1626
|
};
|
|
1627
1627
|
}
|
|
1628
1628
|
|
|
1629
|
-
/**
|
|
1630
|
-
* Exposes an object's {@link LocalState}.
|
|
1631
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1632
|
-
*
|
|
1633
|
-
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1629
|
+
/**
|
|
1630
|
+
* Exposes an object's {@link LocalState}.
|
|
1631
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1632
|
+
*
|
|
1633
|
+
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1634
1634
|
*/
|
|
1635
1635
|
function useInstanceHandle(ref) {
|
|
1636
1636
|
const instance = React__namespace.useRef(null);
|
|
@@ -1643,18 +1643,18 @@ function useStore() {
|
|
|
1643
1643
|
return store;
|
|
1644
1644
|
}
|
|
1645
1645
|
|
|
1646
|
-
/**
|
|
1647
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1648
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1646
|
+
/**
|
|
1647
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1648
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1649
1649
|
*/
|
|
1650
1650
|
function useThree(selector = state => state, equalityFn) {
|
|
1651
1651
|
return useStore()(selector, equalityFn);
|
|
1652
1652
|
}
|
|
1653
1653
|
|
|
1654
|
-
/**
|
|
1655
|
-
* Executes a callback before render in a shared frame loop.
|
|
1656
|
-
* Can order effects with render priority or manually render with a positive priority.
|
|
1657
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1654
|
+
/**
|
|
1655
|
+
* Executes a callback before render in a shared frame loop.
|
|
1656
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
1657
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1658
1658
|
*/
|
|
1659
1659
|
function useFrame(callback, renderPriority = 0) {
|
|
1660
1660
|
const store = useStore();
|
|
@@ -1666,9 +1666,9 @@ function useFrame(callback, renderPriority = 0) {
|
|
|
1666
1666
|
return null;
|
|
1667
1667
|
}
|
|
1668
1668
|
|
|
1669
|
-
/**
|
|
1670
|
-
* Returns a node graph of an object with named nodes & materials.
|
|
1671
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1669
|
+
/**
|
|
1670
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
1671
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1672
1672
|
*/
|
|
1673
1673
|
function useGraph(object) {
|
|
1674
1674
|
return React__namespace.useMemo(() => buildGraph(object), [object]);
|
|
@@ -1690,11 +1690,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1690
1690
|
}, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
|
|
1691
1691
|
};
|
|
1692
1692
|
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Synchronously loads and caches assets with a three loader.
|
|
1695
|
-
*
|
|
1696
|
-
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1697
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1693
|
+
/**
|
|
1694
|
+
* Synchronously loads and caches assets with a three loader.
|
|
1695
|
+
*
|
|
1696
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1697
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1698
1698
|
*/
|
|
1699
1699
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1700
1700
|
// Use suspense to load async assets
|
|
@@ -1706,16 +1706,16 @@ function useLoader(Proto, input, extensions, onProgress) {
|
|
|
1706
1706
|
return Array.isArray(input) ? results : results[0];
|
|
1707
1707
|
}
|
|
1708
1708
|
|
|
1709
|
-
/**
|
|
1710
|
-
* Preloads an asset into cache as a side-effect.
|
|
1709
|
+
/**
|
|
1710
|
+
* Preloads an asset into cache as a side-effect.
|
|
1711
1711
|
*/
|
|
1712
1712
|
useLoader.preload = function (Proto, input, extensions) {
|
|
1713
1713
|
const keys = Array.isArray(input) ? input : [input];
|
|
1714
1714
|
return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
|
|
1715
1715
|
};
|
|
1716
1716
|
|
|
1717
|
-
/**
|
|
1718
|
-
* Removes a loaded asset from cache.
|
|
1717
|
+
/**
|
|
1718
|
+
* Removes a loaded asset from cache.
|
|
1719
1719
|
*/
|
|
1720
1720
|
useLoader.clear = function (Proto, input) {
|
|
1721
1721
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -2111,10 +2111,10 @@ function Portal({
|
|
|
2111
2111
|
children,
|
|
2112
2112
|
container
|
|
2113
2113
|
}) {
|
|
2114
|
-
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2115
|
-
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2116
|
-
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2117
|
-
* <Canvas>
|
|
2114
|
+
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2115
|
+
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2116
|
+
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2117
|
+
* <Canvas>
|
|
2118
2118
|
* {createPortal(...)} */
|
|
2119
2119
|
const {
|
|
2120
2120
|
events,
|
|
@@ -381,12 +381,12 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
var _window$document, _window$navigator;
|
|
384
|
-
/**
|
|
385
|
-
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
384
|
+
/**
|
|
385
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
386
386
|
*/
|
|
387
387
|
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
388
|
-
/**
|
|
389
|
-
* The current THREE.ColorManagement instance, if present.
|
|
388
|
+
/**
|
|
389
|
+
* The current THREE.ColorManagement instance, if present.
|
|
390
390
|
*/
|
|
391
391
|
const getColorManagement = () => {
|
|
392
392
|
var _ColorManagement;
|
|
@@ -395,14 +395,14 @@ const getColorManagement = () => {
|
|
|
395
395
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
396
396
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
397
397
|
|
|
398
|
-
/**
|
|
399
|
-
* An SSR-friendly useLayoutEffect.
|
|
400
|
-
*
|
|
401
|
-
* React currently throws a warning when using useLayoutEffect on the server.
|
|
402
|
-
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
403
|
-
* useLayoutEffect elsewhere.
|
|
404
|
-
*
|
|
405
|
-
* @see https://github.com/facebook/react/issues/14927
|
|
398
|
+
/**
|
|
399
|
+
* An SSR-friendly useLayoutEffect.
|
|
400
|
+
*
|
|
401
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
402
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
403
|
+
* useLayoutEffect elsewhere.
|
|
404
|
+
*
|
|
405
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
406
406
|
*/
|
|
407
407
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
408
408
|
function useMutableCallback(fn) {
|
|
@@ -447,8 +447,8 @@ function calculateDpr(dpr) {
|
|
|
447
447
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
/**
|
|
451
|
-
* Returns instance root state
|
|
450
|
+
/**
|
|
451
|
+
* Returns instance root state
|
|
452
452
|
*/
|
|
453
453
|
const getRootState = obj => {
|
|
454
454
|
var _r3f;
|
|
@@ -504,8 +504,8 @@ const is = {
|
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
-
/**
|
|
508
|
-
* Collects nodes and materials from a THREE.Object3D.
|
|
507
|
+
/**
|
|
508
|
+
* Collects nodes and materials from a THREE.Object3D.
|
|
509
509
|
*/
|
|
510
510
|
function buildGraph(object) {
|
|
511
511
|
const data = {
|
|
@@ -845,9 +845,9 @@ function getEventPriority() {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
-
/**
|
|
849
|
-
* Release pointer captures.
|
|
850
|
-
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
848
|
+
/**
|
|
849
|
+
* Release pointer captures.
|
|
850
|
+
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
851
851
|
*/
|
|
852
852
|
function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
|
|
853
853
|
const captureData = captures.get(obj);
|
|
@@ -1182,19 +1182,19 @@ function createEvents(store) {
|
|
|
1182
1182
|
// Check presence of handlers
|
|
1183
1183
|
if (!(instance != null && instance.eventCount)) return;
|
|
1184
1184
|
|
|
1185
|
-
/*
|
|
1186
|
-
MAYBE TODO, DELETE IF NOT:
|
|
1187
|
-
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1188
|
-
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1189
|
-
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1190
|
-
|
|
1191
|
-
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1192
|
-
if (pointerId !== undefined) {
|
|
1193
|
-
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1194
|
-
if (capturedMeshSet) {
|
|
1195
|
-
const captured = capturedMeshSet.get(eventObject)
|
|
1196
|
-
if (captured && captured.localState.stopped) return
|
|
1197
|
-
}
|
|
1185
|
+
/*
|
|
1186
|
+
MAYBE TODO, DELETE IF NOT:
|
|
1187
|
+
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1188
|
+
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1189
|
+
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1190
|
+
|
|
1191
|
+
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1192
|
+
if (pointerId !== undefined) {
|
|
1193
|
+
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1194
|
+
if (capturedMeshSet) {
|
|
1195
|
+
const captured = capturedMeshSet.get(eventObject)
|
|
1196
|
+
if (captured && captured.localState.stopped) return
|
|
1197
|
+
}
|
|
1198
1198
|
}*/
|
|
1199
1199
|
|
|
1200
1200
|
if (isPointerMove) {
|
|
@@ -1500,21 +1500,21 @@ let globalEffects = new Set();
|
|
|
1500
1500
|
let globalAfterEffects = new Set();
|
|
1501
1501
|
let globalTailEffects = new Set();
|
|
1502
1502
|
|
|
1503
|
-
/**
|
|
1504
|
-
* Adds a global render callback which is called each frame.
|
|
1505
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1503
|
+
/**
|
|
1504
|
+
* Adds a global render callback which is called each frame.
|
|
1505
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1506
1506
|
*/
|
|
1507
1507
|
const addEffect = callback => createSubs(callback, globalEffects);
|
|
1508
1508
|
|
|
1509
|
-
/**
|
|
1510
|
-
* Adds a global after-render callback which is called each frame.
|
|
1511
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1509
|
+
/**
|
|
1510
|
+
* Adds a global after-render callback which is called each frame.
|
|
1511
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1512
1512
|
*/
|
|
1513
1513
|
const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
1514
1514
|
|
|
1515
|
-
/**
|
|
1516
|
-
* Adds a global callback which is called when rendering stops.
|
|
1517
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1515
|
+
/**
|
|
1516
|
+
* Adds a global callback which is called when rendering stops.
|
|
1517
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1518
1518
|
*/
|
|
1519
1519
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1520
1520
|
function run(effects, timestamp) {
|
|
@@ -1613,24 +1613,24 @@ function createLoop(roots) {
|
|
|
1613
1613
|
}
|
|
1614
1614
|
return {
|
|
1615
1615
|
loop,
|
|
1616
|
-
/**
|
|
1617
|
-
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1618
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1616
|
+
/**
|
|
1617
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1618
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1619
1619
|
*/
|
|
1620
1620
|
invalidate,
|
|
1621
|
-
/**
|
|
1622
|
-
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1623
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1621
|
+
/**
|
|
1622
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1623
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1624
1624
|
*/
|
|
1625
1625
|
advance
|
|
1626
1626
|
};
|
|
1627
1627
|
}
|
|
1628
1628
|
|
|
1629
|
-
/**
|
|
1630
|
-
* Exposes an object's {@link LocalState}.
|
|
1631
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1632
|
-
*
|
|
1633
|
-
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1629
|
+
/**
|
|
1630
|
+
* Exposes an object's {@link LocalState}.
|
|
1631
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1632
|
+
*
|
|
1633
|
+
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1634
1634
|
*/
|
|
1635
1635
|
function useInstanceHandle(ref) {
|
|
1636
1636
|
const instance = React__namespace.useRef(null);
|
|
@@ -1643,18 +1643,18 @@ function useStore() {
|
|
|
1643
1643
|
return store;
|
|
1644
1644
|
}
|
|
1645
1645
|
|
|
1646
|
-
/**
|
|
1647
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1648
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1646
|
+
/**
|
|
1647
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1648
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1649
1649
|
*/
|
|
1650
1650
|
function useThree(selector = state => state, equalityFn) {
|
|
1651
1651
|
return useStore()(selector, equalityFn);
|
|
1652
1652
|
}
|
|
1653
1653
|
|
|
1654
|
-
/**
|
|
1655
|
-
* Executes a callback before render in a shared frame loop.
|
|
1656
|
-
* Can order effects with render priority or manually render with a positive priority.
|
|
1657
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1654
|
+
/**
|
|
1655
|
+
* Executes a callback before render in a shared frame loop.
|
|
1656
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
1657
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1658
1658
|
*/
|
|
1659
1659
|
function useFrame(callback, renderPriority = 0) {
|
|
1660
1660
|
const store = useStore();
|
|
@@ -1666,9 +1666,9 @@ function useFrame(callback, renderPriority = 0) {
|
|
|
1666
1666
|
return null;
|
|
1667
1667
|
}
|
|
1668
1668
|
|
|
1669
|
-
/**
|
|
1670
|
-
* Returns a node graph of an object with named nodes & materials.
|
|
1671
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1669
|
+
/**
|
|
1670
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
1671
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1672
1672
|
*/
|
|
1673
1673
|
function useGraph(object) {
|
|
1674
1674
|
return React__namespace.useMemo(() => buildGraph(object), [object]);
|
|
@@ -1690,11 +1690,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1690
1690
|
}, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
|
|
1691
1691
|
};
|
|
1692
1692
|
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Synchronously loads and caches assets with a three loader.
|
|
1695
|
-
*
|
|
1696
|
-
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1697
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1693
|
+
/**
|
|
1694
|
+
* Synchronously loads and caches assets with a three loader.
|
|
1695
|
+
*
|
|
1696
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1697
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1698
1698
|
*/
|
|
1699
1699
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1700
1700
|
// Use suspense to load async assets
|
|
@@ -1706,16 +1706,16 @@ function useLoader(Proto, input, extensions, onProgress) {
|
|
|
1706
1706
|
return Array.isArray(input) ? results : results[0];
|
|
1707
1707
|
}
|
|
1708
1708
|
|
|
1709
|
-
/**
|
|
1710
|
-
* Preloads an asset into cache as a side-effect.
|
|
1709
|
+
/**
|
|
1710
|
+
* Preloads an asset into cache as a side-effect.
|
|
1711
1711
|
*/
|
|
1712
1712
|
useLoader.preload = function (Proto, input, extensions) {
|
|
1713
1713
|
const keys = Array.isArray(input) ? input : [input];
|
|
1714
1714
|
return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
|
|
1715
1715
|
};
|
|
1716
1716
|
|
|
1717
|
-
/**
|
|
1718
|
-
* Removes a loaded asset from cache.
|
|
1717
|
+
/**
|
|
1718
|
+
* Removes a loaded asset from cache.
|
|
1719
1719
|
*/
|
|
1720
1720
|
useLoader.clear = function (Proto, input) {
|
|
1721
1721
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -2111,10 +2111,10 @@ function Portal({
|
|
|
2111
2111
|
children,
|
|
2112
2112
|
container
|
|
2113
2113
|
}) {
|
|
2114
|
-
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2115
|
-
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2116
|
-
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2117
|
-
* <Canvas>
|
|
2114
|
+
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2115
|
+
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2116
|
+
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2117
|
+
* <Canvas>
|
|
2118
2118
|
* {createPortal(...)} */
|
|
2119
2119
|
const {
|
|
2120
2120
|
events,
|