@react-three/fiber 8.0.5 → 8.0.8
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 +18 -0
- package/dist/declarations/src/core/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +21 -25
- package/dist/declarations/src/core/index.d.ts +56 -42
- package/dist/declarations/src/core/loop.d.ts +13 -13
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/store.d.ts +91 -108
- package/dist/declarations/src/core/utils.d.ts +83 -57
- package/dist/declarations/src/index.d.ts +10 -10
- package/dist/declarations/src/native/Canvas.d.ts +8 -13
- package/dist/declarations/src/native/events.d.ts +4 -5
- package/dist/declarations/src/native.d.ts +10 -10
- package/dist/declarations/src/three-types.d.ts +327 -327
- package/dist/declarations/src/web/Canvas.d.ts +9 -13
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-635ddfb2.esm.js → index-548cf96a.esm.js} +126 -24
- package/dist/{index-28a77253.cjs.dev.js → index-b8ee55f0.cjs.dev.js} +128 -23
- package/dist/{index-1ff856c3.cjs.prod.js → index-c4e0ac66.cjs.prod.js} +128 -23
- package/dist/react-three-fiber.cjs.dev.js +13 -41
- package/dist/react-three-fiber.cjs.prod.js +13 -41
- package/dist/react-three-fiber.esm.js +12 -39
- package/native/dist/react-three-fiber-native.cjs.dev.js +9 -37
- package/native/dist/react-three-fiber-native.cjs.prod.js +9 -37
- package/native/dist/react-three-fiber-native.esm.js +8 -35
- package/package.json +1 -1
|
@@ -39,6 +39,47 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
39
39
|
__proto__: null
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
// React currently throws a warning when using useLayoutEffect on the server.
|
|
43
|
+
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
44
|
+
// useLayoutEffect on the client.
|
|
45
|
+
const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
|
|
46
|
+
const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
47
|
+
function Block({
|
|
48
|
+
set
|
|
49
|
+
}) {
|
|
50
|
+
useIsomorphicLayoutEffect(() => {
|
|
51
|
+
set(new Promise(() => null));
|
|
52
|
+
return () => set(false);
|
|
53
|
+
}, [set]);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
class ErrorBoundary extends React__namespace.Component {
|
|
57
|
+
constructor(...args) {
|
|
58
|
+
super(...args);
|
|
59
|
+
this.state = {
|
|
60
|
+
error: false
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
componentDidCatch(error) {
|
|
65
|
+
this.props.set(error);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
render() {
|
|
69
|
+
return this.state.error ? null : this.props.children;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
75
|
+
error: true
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
function useMemoizedFn(fn) {
|
|
79
|
+
const fnRef = React__namespace.useRef(fn);
|
|
80
|
+
useIsomorphicLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
81
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
82
|
+
}
|
|
42
83
|
const DEFAULT = '__default';
|
|
43
84
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
44
85
|
function calculateDpr(dpr) {
|
|
@@ -860,8 +901,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
860
901
|
let added = false;
|
|
861
902
|
|
|
862
903
|
if (child) {
|
|
904
|
+
var _child$__r3f, _parentInstance$__r3f;
|
|
905
|
+
|
|
863
906
|
// The attach attribute implies that the object attaches itself on the parent
|
|
864
|
-
if (child.__r3f.attach) {
|
|
907
|
+
if ((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) {
|
|
865
908
|
attach(parentInstance, child, child.__r3f.attach);
|
|
866
909
|
} else if (child.isObject3D && parentInstance.isObject3D) {
|
|
867
910
|
// add in the usual parent-child way
|
|
@@ -871,7 +914,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
871
914
|
// that is, anything that's a child in React but not a child in the scenegraph.
|
|
872
915
|
|
|
873
916
|
|
|
874
|
-
if (!added) parentInstance.__r3f.objects.push(child);
|
|
917
|
+
if (!added) (_parentInstance$__r3f = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f.objects.push(child);
|
|
875
918
|
if (!child.__r3f) prepare(child, {});
|
|
876
919
|
child.__r3f.parent = parentInstance;
|
|
877
920
|
updateInstance(child);
|
|
@@ -883,7 +926,9 @@ function createRenderer(roots, getEventPriority) {
|
|
|
883
926
|
let added = false;
|
|
884
927
|
|
|
885
928
|
if (child) {
|
|
886
|
-
|
|
929
|
+
var _child$__r3f2, _parentInstance$__r3f2;
|
|
930
|
+
|
|
931
|
+
if ((_child$__r3f2 = child.__r3f) != null && _child$__r3f2.attach) {
|
|
887
932
|
attach(parentInstance, child, child.__r3f.attach);
|
|
888
933
|
} else if (child.isObject3D && parentInstance.isObject3D) {
|
|
889
934
|
child.parent = parentInstance;
|
|
@@ -896,7 +941,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
896
941
|
added = true;
|
|
897
942
|
}
|
|
898
943
|
|
|
899
|
-
if (!added) parentInstance.__r3f.objects.push(child);
|
|
944
|
+
if (!added) (_parentInstance$__r3f2 = parentInstance.__r3f) == null ? void 0 : _parentInstance$__r3f2.objects.push(child);
|
|
900
945
|
if (!child.__r3f) prepare(child, {});
|
|
901
946
|
child.__r3f.parent = parentInstance;
|
|
902
947
|
updateInstance(child);
|
|
@@ -910,21 +955,21 @@ function createRenderer(roots, getEventPriority) {
|
|
|
910
955
|
|
|
911
956
|
function removeChild(parentInstance, child, dispose) {
|
|
912
957
|
if (child) {
|
|
913
|
-
var _parentInstance$
|
|
958
|
+
var _parentInstance$__r3f3, _child$__r3f3, _child$__r3f5;
|
|
914
959
|
|
|
915
960
|
// Clear the parent reference
|
|
916
961
|
if (child.__r3f) child.__r3f.parent = null; // Remove child from the parents objects
|
|
917
962
|
|
|
918
|
-
if ((_parentInstance$
|
|
963
|
+
if ((_parentInstance$__r3f3 = parentInstance.__r3f) != null && _parentInstance$__r3f3.objects) parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child); // Remove attachment
|
|
919
964
|
|
|
920
|
-
if (child.__r3f.attach) {
|
|
965
|
+
if ((_child$__r3f3 = child.__r3f) != null && _child$__r3f3.attach) {
|
|
921
966
|
detach(parentInstance, child, child.__r3f.attach);
|
|
922
967
|
} else if (child.isObject3D && parentInstance.isObject3D) {
|
|
923
|
-
var _child$
|
|
968
|
+
var _child$__r3f4;
|
|
924
969
|
|
|
925
970
|
parentInstance.remove(child); // Remove interactivity
|
|
926
971
|
|
|
927
|
-
if ((_child$
|
|
972
|
+
if ((_child$__r3f4 = child.__r3f) != null && _child$__r3f4.root) {
|
|
928
973
|
removeInteractivity(child.__r3f.root, child);
|
|
929
974
|
}
|
|
930
975
|
} // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
|
|
@@ -938,14 +983,14 @@ function createRenderer(roots, getEventPriority) {
|
|
|
938
983
|
// when the reconciler calls it, but then carry our own check recursively
|
|
939
984
|
|
|
940
985
|
|
|
941
|
-
const isPrimitive = (_child$
|
|
986
|
+
const isPrimitive = (_child$__r3f5 = child.__r3f) == null ? void 0 : _child$__r3f5.primitive;
|
|
942
987
|
const shouldDispose = dispose === undefined ? child.dispose !== null && !isPrimitive : dispose; // Remove nested child objects. Primitives should not have objects and children that are
|
|
943
988
|
// attached to them declaratively ...
|
|
944
989
|
|
|
945
990
|
if (!isPrimitive) {
|
|
946
|
-
var _child$
|
|
991
|
+
var _child$__r3f6;
|
|
947
992
|
|
|
948
|
-
removeRecursive((_child$
|
|
993
|
+
removeRecursive((_child$__r3f6 = child.__r3f) == null ? void 0 : _child$__r3f6.objects, child, shouldDispose);
|
|
949
994
|
removeRecursive(child.children, child, shouldDispose);
|
|
950
995
|
} // Remove references
|
|
951
996
|
|
|
@@ -1303,7 +1348,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1303
1348
|
initialClick: [0, 0],
|
|
1304
1349
|
initialHits: [],
|
|
1305
1350
|
capturedMap: new Map(),
|
|
1306
|
-
subscribe: (ref, priority
|
|
1351
|
+
subscribe: (ref, priority, store) => {
|
|
1307
1352
|
set(({
|
|
1308
1353
|
internal
|
|
1309
1354
|
}) => ({
|
|
@@ -1317,7 +1362,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1317
1362
|
// highest priority renders last (on top of the other frames)
|
|
1318
1363
|
subscribers: [...internal.subscribers, {
|
|
1319
1364
|
ref,
|
|
1320
|
-
priority
|
|
1365
|
+
priority,
|
|
1366
|
+
store
|
|
1321
1367
|
}].sort((a, b) => a.priority - b.priority)
|
|
1322
1368
|
}
|
|
1323
1369
|
}));
|
|
@@ -1391,8 +1437,23 @@ let i;
|
|
|
1391
1437
|
let globalEffects = [];
|
|
1392
1438
|
let globalAfterEffects = [];
|
|
1393
1439
|
let globalTailEffects = [];
|
|
1440
|
+
/**
|
|
1441
|
+
* Adds a global render callback which is called each frame.
|
|
1442
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1443
|
+
*/
|
|
1444
|
+
|
|
1394
1445
|
const addEffect = callback => createSubs(callback, globalEffects);
|
|
1446
|
+
/**
|
|
1447
|
+
* Adds a global after-render callback which is called each frame.
|
|
1448
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1449
|
+
*/
|
|
1450
|
+
|
|
1395
1451
|
const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
1452
|
+
/**
|
|
1453
|
+
* Adds a global callback which is called when rendering stops.
|
|
1454
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1455
|
+
*/
|
|
1456
|
+
|
|
1396
1457
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1397
1458
|
|
|
1398
1459
|
function run(effects, timestamp) {
|
|
@@ -1400,6 +1461,7 @@ function run(effects, timestamp) {
|
|
|
1400
1461
|
}
|
|
1401
1462
|
|
|
1402
1463
|
let subscribers;
|
|
1464
|
+
let subscription;
|
|
1403
1465
|
|
|
1404
1466
|
function render$1(timestamp, state, frame) {
|
|
1405
1467
|
// Run local effects
|
|
@@ -1414,7 +1476,10 @@ function render$1(timestamp, state, frame) {
|
|
|
1414
1476
|
|
|
1415
1477
|
subscribers = state.internal.subscribers;
|
|
1416
1478
|
|
|
1417
|
-
for (i = 0; i < subscribers.length; i++)
|
|
1479
|
+
for (i = 0; i < subscribers.length; i++) {
|
|
1480
|
+
subscription = subscribers[i];
|
|
1481
|
+
subscription.ref.current(subscription.store.getState(), delta, frame);
|
|
1482
|
+
} // Render content
|
|
1418
1483
|
|
|
1419
1484
|
|
|
1420
1485
|
if (!state.internal.priority && state.gl.render) state.gl.render(state.scene, state.camera); // Decrease frame count
|
|
@@ -1479,7 +1544,17 @@ function createLoop(roots) {
|
|
|
1479
1544
|
|
|
1480
1545
|
return {
|
|
1481
1546
|
loop,
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1550
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1551
|
+
*/
|
|
1482
1552
|
invalidate,
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1556
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1557
|
+
*/
|
|
1483
1558
|
advance
|
|
1484
1559
|
};
|
|
1485
1560
|
}
|
|
@@ -1489,18 +1564,35 @@ function useStore() {
|
|
|
1489
1564
|
if (!store) throw `R3F hooks can only be used within the Canvas component!`;
|
|
1490
1565
|
return store;
|
|
1491
1566
|
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1569
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1570
|
+
*/
|
|
1571
|
+
|
|
1492
1572
|
function useThree(selector = state => state, equalityFn) {
|
|
1493
1573
|
return useStore()(selector, equalityFn);
|
|
1494
1574
|
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Executes a callback before render in a shared frame loop.
|
|
1577
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
1578
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1579
|
+
*/
|
|
1580
|
+
|
|
1495
1581
|
function useFrame(callback, renderPriority = 0) {
|
|
1496
|
-
const
|
|
1582
|
+
const store = useStore();
|
|
1583
|
+
const subscribe = store.getState().internal.subscribe; // Update ref
|
|
1497
1584
|
|
|
1498
1585
|
const ref = React__namespace.useRef(callback);
|
|
1499
1586
|
React__namespace.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe on mount, unsubscribe on unmount
|
|
1500
1587
|
|
|
1501
|
-
React__namespace.useLayoutEffect(() => subscribe(ref, renderPriority), [renderPriority, subscribe]);
|
|
1588
|
+
React__namespace.useLayoutEffect(() => subscribe(ref, renderPriority, store), [renderPriority, subscribe, store]);
|
|
1502
1589
|
return null;
|
|
1503
1590
|
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
1593
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1594
|
+
*/
|
|
1595
|
+
|
|
1504
1596
|
function useGraph(object) {
|
|
1505
1597
|
return React__namespace.useMemo(() => buildGraph(object), [object]);
|
|
1506
1598
|
}
|
|
@@ -1517,12 +1609,14 @@ function loadingFn(extensions, onProgress) {
|
|
|
1517
1609
|
}, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
|
|
1518
1610
|
};
|
|
1519
1611
|
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Synchronously loads and caches assets with a three loader.
|
|
1614
|
+
*
|
|
1615
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1616
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1617
|
+
*/
|
|
1618
|
+
|
|
1520
1619
|
|
|
1521
|
-
function useMemoizedFn(fn) {
|
|
1522
|
-
const fnRef = React__namespace.useRef(fn);
|
|
1523
|
-
React__namespace.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1524
|
-
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1525
|
-
}
|
|
1526
1620
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1527
1621
|
// Use suspense to load async assets
|
|
1528
1622
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1532,11 +1626,18 @@ function useLoader(Proto, input, extensions, onProgress) {
|
|
|
1532
1626
|
|
|
1533
1627
|
return Array.isArray(input) ? results : results[0];
|
|
1534
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Preloads an asset into cache as a side-effect.
|
|
1631
|
+
*/
|
|
1535
1632
|
|
|
1536
1633
|
useLoader.preload = function (Proto, input, extensions) {
|
|
1537
1634
|
const keys = Array.isArray(input) ? input : [input];
|
|
1538
1635
|
return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
|
|
1539
1636
|
};
|
|
1637
|
+
/**
|
|
1638
|
+
* Removes a loaded asset from cache.
|
|
1639
|
+
*/
|
|
1640
|
+
|
|
1540
1641
|
|
|
1541
1642
|
useLoader.clear = function (Proto, input) {
|
|
1542
1643
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1783,7 +1884,7 @@ function Provider({
|
|
|
1783
1884
|
onCreated,
|
|
1784
1885
|
rootElement
|
|
1785
1886
|
}) {
|
|
1786
|
-
|
|
1887
|
+
useIsomorphicLayoutEffect(() => {
|
|
1787
1888
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1788
1889
|
|
|
1789
1890
|
state.set(state => ({
|
|
@@ -1833,6 +1934,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
1833
1934
|
|
|
1834
1935
|
function createPortal(children, container, state) {
|
|
1835
1936
|
return /*#__PURE__*/React__namespace.createElement(Portal, {
|
|
1937
|
+
key: container.uuid,
|
|
1836
1938
|
children: children,
|
|
1837
1939
|
container: container,
|
|
1838
1940
|
state: state
|
|
@@ -1910,6 +2012,8 @@ reconciler.injectIntoDevTools({
|
|
|
1910
2012
|
});
|
|
1911
2013
|
const act = React__namespace.unstable_act;
|
|
1912
2014
|
|
|
2015
|
+
exports.Block = Block;
|
|
2016
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
1913
2017
|
exports.act = act;
|
|
1914
2018
|
exports.addAfterEffect = addAfterEffect;
|
|
1915
2019
|
exports.addEffect = addEffect;
|
|
@@ -1933,6 +2037,7 @@ exports.threeTypes = threeTypes;
|
|
|
1933
2037
|
exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
1934
2038
|
exports.useFrame = useFrame;
|
|
1935
2039
|
exports.useGraph = useGraph;
|
|
2040
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
1936
2041
|
exports.useLoader = useLoader;
|
|
1937
2042
|
exports.useMemoizedFn = useMemoizedFn;
|
|
1938
2043
|
exports.useStore = useStore;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-b8ee55f0.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -53,6 +53,8 @@ const DOM_EVENTS = {
|
|
|
53
53
|
onPointerCancel: ['pointercancel', true],
|
|
54
54
|
onLostPointerCapture: ['lostpointercapture', true]
|
|
55
55
|
};
|
|
56
|
+
/** Default R3F event manager for web */
|
|
57
|
+
|
|
56
58
|
function createPointerEvents(store) {
|
|
57
59
|
const {
|
|
58
60
|
handlePointer
|
|
@@ -118,38 +120,10 @@ function createPointerEvents(store) {
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
React__namespace.useLayoutEffect(() => {
|
|
126
|
-
set(new Promise(() => null));
|
|
127
|
-
return () => set(false);
|
|
128
|
-
}, [set]);
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
class ErrorBoundary extends React__namespace.Component {
|
|
133
|
-
constructor(...args) {
|
|
134
|
-
super(...args);
|
|
135
|
-
this.state = {
|
|
136
|
-
error: false
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
componentDidCatch(error) {
|
|
141
|
-
this.props.set(error);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
render() {
|
|
145
|
-
return this.state.error ? null : this.props.children;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
151
|
-
error: true
|
|
152
|
-
});
|
|
123
|
+
/**
|
|
124
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
125
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
126
|
+
*/
|
|
153
127
|
|
|
154
128
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
155
129
|
children,
|
|
@@ -205,21 +179,20 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
205
179
|
},
|
|
206
180
|
events
|
|
207
181
|
});
|
|
208
|
-
root.current.render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
|
|
182
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
209
183
|
set: setError
|
|
210
184
|
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
211
|
-
fallback: /*#__PURE__*/React__namespace.createElement(Block, {
|
|
185
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
212
186
|
set: setBlock
|
|
213
187
|
})
|
|
214
188
|
}, children)));
|
|
215
189
|
}
|
|
216
190
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
React__namespace.useEffect(() => {
|
|
191
|
+
index.useIsomorphicLayoutEffect(() => {
|
|
192
|
+
const canvas = canvasRef.current;
|
|
193
|
+
setCanvas(canvas);
|
|
221
194
|
return () => index.unmountComponentAtNode(canvas);
|
|
222
|
-
}, [
|
|
195
|
+
}, []);
|
|
223
196
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
224
197
|
ref: mergeRefs__default['default']([meshRef, containerRef]),
|
|
225
198
|
style: {
|
|
@@ -258,7 +231,6 @@ exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
|
258
231
|
exports.useFrame = index.useFrame;
|
|
259
232
|
exports.useGraph = index.useGraph;
|
|
260
233
|
exports.useLoader = index.useLoader;
|
|
261
|
-
exports.useMemoizedFn = index.useMemoizedFn;
|
|
262
234
|
exports.useStore = index.useStore;
|
|
263
235
|
exports.useThree = index.useThree;
|
|
264
236
|
exports.Canvas = Canvas;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-c4e0ac66.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -53,6 +53,8 @@ const DOM_EVENTS = {
|
|
|
53
53
|
onPointerCancel: ['pointercancel', true],
|
|
54
54
|
onLostPointerCapture: ['lostpointercapture', true]
|
|
55
55
|
};
|
|
56
|
+
/** Default R3F event manager for web */
|
|
57
|
+
|
|
56
58
|
function createPointerEvents(store) {
|
|
57
59
|
const {
|
|
58
60
|
handlePointer
|
|
@@ -118,38 +120,10 @@ function createPointerEvents(store) {
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
React__namespace.useLayoutEffect(() => {
|
|
126
|
-
set(new Promise(() => null));
|
|
127
|
-
return () => set(false);
|
|
128
|
-
}, [set]);
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
class ErrorBoundary extends React__namespace.Component {
|
|
133
|
-
constructor(...args) {
|
|
134
|
-
super(...args);
|
|
135
|
-
this.state = {
|
|
136
|
-
error: false
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
componentDidCatch(error) {
|
|
141
|
-
this.props.set(error);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
render() {
|
|
145
|
-
return this.state.error ? null : this.props.children;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
151
|
-
error: true
|
|
152
|
-
});
|
|
123
|
+
/**
|
|
124
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
125
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
126
|
+
*/
|
|
153
127
|
|
|
154
128
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
155
129
|
children,
|
|
@@ -205,21 +179,20 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
205
179
|
},
|
|
206
180
|
events
|
|
207
181
|
});
|
|
208
|
-
root.current.render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
|
|
182
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
209
183
|
set: setError
|
|
210
184
|
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
211
|
-
fallback: /*#__PURE__*/React__namespace.createElement(Block, {
|
|
185
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
212
186
|
set: setBlock
|
|
213
187
|
})
|
|
214
188
|
}, children)));
|
|
215
189
|
}
|
|
216
190
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
React__namespace.useEffect(() => {
|
|
191
|
+
index.useIsomorphicLayoutEffect(() => {
|
|
192
|
+
const canvas = canvasRef.current;
|
|
193
|
+
setCanvas(canvas);
|
|
221
194
|
return () => index.unmountComponentAtNode(canvas);
|
|
222
|
-
}, [
|
|
195
|
+
}, []);
|
|
223
196
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
224
197
|
ref: mergeRefs__default['default']([meshRef, containerRef]),
|
|
225
198
|
style: {
|
|
@@ -258,7 +231,6 @@ exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
|
258
231
|
exports.useFrame = index.useFrame;
|
|
259
232
|
exports.useGraph = index.useGraph;
|
|
260
233
|
exports.useLoader = index.useLoader;
|
|
261
|
-
exports.useMemoizedFn = index.useMemoizedFn;
|
|
262
234
|
exports.useStore = index.useStore;
|
|
263
235
|
exports.useThree = index.useThree;
|
|
264
236
|
exports.Canvas = Canvas;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMemoizedFn, p as pick, o as omit, a as createRoot, b as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber,
|
|
1
|
+
import { c as createEvents, e as extend, u as useMemoizedFn, p as pick, o as omit, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-548cf96a.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from './index-548cf96a.esm.js';
|
|
3
3
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as THREE from 'three';
|
|
@@ -23,6 +23,8 @@ const DOM_EVENTS = {
|
|
|
23
23
|
onPointerCancel: ['pointercancel', true],
|
|
24
24
|
onLostPointerCapture: ['lostpointercapture', true]
|
|
25
25
|
};
|
|
26
|
+
/** Default R3F event manager for web */
|
|
27
|
+
|
|
26
28
|
function createPointerEvents(store) {
|
|
27
29
|
const {
|
|
28
30
|
handlePointer
|
|
@@ -88,38 +90,10 @@ function createPointerEvents(store) {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
React.useLayoutEffect(() => {
|
|
96
|
-
set(new Promise(() => null));
|
|
97
|
-
return () => set(false);
|
|
98
|
-
}, [set]);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class ErrorBoundary extends React.Component {
|
|
103
|
-
constructor(...args) {
|
|
104
|
-
super(...args);
|
|
105
|
-
this.state = {
|
|
106
|
-
error: false
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
componentDidCatch(error) {
|
|
111
|
-
this.props.set(error);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
render() {
|
|
115
|
-
return this.state.error ? null : this.props.children;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
121
|
-
error: true
|
|
122
|
-
});
|
|
93
|
+
/**
|
|
94
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
95
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
96
|
+
*/
|
|
123
97
|
|
|
124
98
|
const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
125
99
|
children,
|
|
@@ -184,12 +158,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
184
158
|
}, children)));
|
|
185
159
|
}
|
|
186
160
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
React.useEffect(() => {
|
|
161
|
+
useIsomorphicLayoutEffect(() => {
|
|
162
|
+
const canvas = canvasRef.current;
|
|
163
|
+
setCanvas(canvas);
|
|
191
164
|
return () => unmountComponentAtNode(canvas);
|
|
192
|
-
}, [
|
|
165
|
+
}, []);
|
|
193
166
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
194
167
|
ref: mergeRefs([meshRef, containerRef]),
|
|
195
168
|
style: {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var expoAsset = require('expo-asset');
|
|
7
|
-
var index = require('../../dist/index-
|
|
7
|
+
var index = require('../../dist/index-b8ee55f0.cjs.dev.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var mergeRefs = require('react-merge-refs');
|
|
@@ -62,6 +62,8 @@ const DOM_EVENTS = {
|
|
|
62
62
|
[EVENTS.HOVEROUT]: 'onPointerOut',
|
|
63
63
|
[EVENTS.PRESSMOVE]: 'onPointerMove'
|
|
64
64
|
};
|
|
65
|
+
/** Default R3F event manager for react-native */
|
|
66
|
+
|
|
65
67
|
function createTouchEvents(store) {
|
|
66
68
|
const {
|
|
67
69
|
handlePointer
|
|
@@ -126,42 +128,13 @@ function createTouchEvents(store) {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
React__namespace.useLayoutEffect(() => {
|
|
134
|
-
set(new Promise(() => null));
|
|
135
|
-
return () => set(false);
|
|
136
|
-
}, [set]);
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
class ErrorBoundary extends React__namespace.Component {
|
|
141
|
-
constructor(...args) {
|
|
142
|
-
super(...args);
|
|
143
|
-
this.state = {
|
|
144
|
-
error: false
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
componentDidCatch(error) {
|
|
149
|
-
this.props.set(error);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
render() {
|
|
153
|
-
return this.state.error ? null : this.props.children;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
159
|
-
error: true
|
|
160
|
-
});
|
|
131
|
+
/**
|
|
132
|
+
* A native canvas which accepts threejs elements as children.
|
|
133
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
134
|
+
*/
|
|
161
135
|
|
|
162
136
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
163
137
|
children,
|
|
164
|
-
fallback,
|
|
165
138
|
style,
|
|
166
139
|
events,
|
|
167
140
|
...props
|
|
@@ -247,10 +220,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
247
220
|
events: events || createTouchEvents,
|
|
248
221
|
onCreated
|
|
249
222
|
});
|
|
250
|
-
root.current.render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
|
|
223
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
251
224
|
set: setError
|
|
252
225
|
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
253
|
-
fallback: /*#__PURE__*/React__namespace.createElement(Block, {
|
|
226
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
254
227
|
set: setBlock
|
|
255
228
|
})
|
|
256
229
|
}, children)));
|
|
@@ -376,7 +349,6 @@ exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
|
376
349
|
exports.useFrame = index.useFrame;
|
|
377
350
|
exports.useGraph = index.useGraph;
|
|
378
351
|
exports.useLoader = index.useLoader;
|
|
379
|
-
exports.useMemoizedFn = index.useMemoizedFn;
|
|
380
352
|
exports.useStore = index.useStore;
|
|
381
353
|
exports.useThree = index.useThree;
|
|
382
354
|
exports.Canvas = Canvas;
|