@react-three/fiber 8.14.5 → 8.14.7
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 +829 -817
- package/dist/{index-563322db.esm.js → index-c4d1c86e.esm.js} +73 -73
- package/dist/{index-0ed4bbca.cjs.prod.js → index-ce1a9f04.cjs.prod.js} +73 -73
- package/dist/{index-886811f8.cjs.dev.js → index-d1f17345.cjs.dev.js} +73 -73
- 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 +85 -107
- package/native/dist/react-three-fiber-native.cjs.prod.js +85 -107
- package/native/dist/react-three-fiber-native.esm.js +87 -109
- package/native/package.json +5 -5
- package/package.json +2 -1
- package/readme.md +253 -253
- package/yarn-error.log +10628 -0
|
@@ -374,12 +374,12 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
var _window$document, _window$navigator;
|
|
377
|
-
/**
|
|
378
|
-
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
377
|
+
/**
|
|
378
|
+
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
|
|
379
379
|
*/
|
|
380
380
|
const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
|
|
381
|
-
/**
|
|
382
|
-
* The current THREE.ColorManagement instance, if present.
|
|
381
|
+
/**
|
|
382
|
+
* The current THREE.ColorManagement instance, if present.
|
|
383
383
|
*/
|
|
384
384
|
const getColorManagement = () => {
|
|
385
385
|
var _ColorManagement;
|
|
@@ -388,14 +388,14 @@ const getColorManagement = () => {
|
|
|
388
388
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
389
389
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
390
390
|
|
|
391
|
-
/**
|
|
392
|
-
* An SSR-friendly useLayoutEffect.
|
|
393
|
-
*
|
|
394
|
-
* React currently throws a warning when using useLayoutEffect on the server.
|
|
395
|
-
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
396
|
-
* useLayoutEffect elsewhere.
|
|
397
|
-
*
|
|
398
|
-
* @see https://github.com/facebook/react/issues/14927
|
|
391
|
+
/**
|
|
392
|
+
* An SSR-friendly useLayoutEffect.
|
|
393
|
+
*
|
|
394
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
395
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
396
|
+
* useLayoutEffect elsewhere.
|
|
397
|
+
*
|
|
398
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
399
399
|
*/
|
|
400
400
|
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;
|
|
401
401
|
function useMutableCallback(fn) {
|
|
@@ -440,8 +440,8 @@ function calculateDpr(dpr) {
|
|
|
440
440
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
/**
|
|
444
|
-
* Returns instance root state
|
|
443
|
+
/**
|
|
444
|
+
* Returns instance root state
|
|
445
445
|
*/
|
|
446
446
|
const getRootState = obj => {
|
|
447
447
|
var _r3f;
|
|
@@ -836,9 +836,9 @@ function getEventPriority() {
|
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
|
|
839
|
-
/**
|
|
840
|
-
* Release pointer captures.
|
|
841
|
-
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
839
|
+
/**
|
|
840
|
+
* Release pointer captures.
|
|
841
|
+
* This is called by releasePointerCapture in the API, and when an object is removed.
|
|
842
842
|
*/
|
|
843
843
|
function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
|
|
844
844
|
const captureData = captures.get(obj);
|
|
@@ -1173,19 +1173,19 @@ function createEvents(store) {
|
|
|
1173
1173
|
// Check presence of handlers
|
|
1174
1174
|
if (!(instance != null && instance.eventCount)) return;
|
|
1175
1175
|
|
|
1176
|
-
/*
|
|
1177
|
-
MAYBE TODO, DELETE IF NOT:
|
|
1178
|
-
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1179
|
-
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1180
|
-
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1181
|
-
|
|
1182
|
-
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1183
|
-
if (pointerId !== undefined) {
|
|
1184
|
-
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1185
|
-
if (capturedMeshSet) {
|
|
1186
|
-
const captured = capturedMeshSet.get(eventObject)
|
|
1187
|
-
if (captured && captured.localState.stopped) return
|
|
1188
|
-
}
|
|
1176
|
+
/*
|
|
1177
|
+
MAYBE TODO, DELETE IF NOT:
|
|
1178
|
+
Check if the object is captured, captured events should not have intersects running in parallel
|
|
1179
|
+
But wouldn't it be better to just replace capturedMap with a single entry?
|
|
1180
|
+
Also, are we OK with straight up making picking up multiple objects impossible?
|
|
1181
|
+
|
|
1182
|
+
const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
|
|
1183
|
+
if (pointerId !== undefined) {
|
|
1184
|
+
const capturedMeshSet = internal.capturedMap.get(pointerId)
|
|
1185
|
+
if (capturedMeshSet) {
|
|
1186
|
+
const captured = capturedMeshSet.get(eventObject)
|
|
1187
|
+
if (captured && captured.localState.stopped) return
|
|
1188
|
+
}
|
|
1189
1189
|
}*/
|
|
1190
1190
|
|
|
1191
1191
|
if (isPointerMove) {
|
|
@@ -1491,21 +1491,21 @@ let globalEffects = new Set();
|
|
|
1491
1491
|
let globalAfterEffects = new Set();
|
|
1492
1492
|
let globalTailEffects = new Set();
|
|
1493
1493
|
|
|
1494
|
-
/**
|
|
1495
|
-
* Adds a global render callback which is called each frame.
|
|
1496
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1494
|
+
/**
|
|
1495
|
+
* Adds a global render callback which is called each frame.
|
|
1496
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1497
1497
|
*/
|
|
1498
1498
|
const addEffect = callback => createSubs(callback, globalEffects);
|
|
1499
1499
|
|
|
1500
|
-
/**
|
|
1501
|
-
* Adds a global after-render callback which is called each frame.
|
|
1502
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1500
|
+
/**
|
|
1501
|
+
* Adds a global after-render callback which is called each frame.
|
|
1502
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1503
1503
|
*/
|
|
1504
1504
|
const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
1505
1505
|
|
|
1506
|
-
/**
|
|
1507
|
-
* Adds a global callback which is called when rendering stops.
|
|
1508
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1506
|
+
/**
|
|
1507
|
+
* Adds a global callback which is called when rendering stops.
|
|
1508
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1509
1509
|
*/
|
|
1510
1510
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1511
1511
|
function run(effects, timestamp) {
|
|
@@ -1604,24 +1604,24 @@ function createLoop(roots) {
|
|
|
1604
1604
|
}
|
|
1605
1605
|
return {
|
|
1606
1606
|
loop,
|
|
1607
|
-
/**
|
|
1608
|
-
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1609
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1607
|
+
/**
|
|
1608
|
+
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
|
|
1609
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
|
|
1610
1610
|
*/
|
|
1611
1611
|
invalidate,
|
|
1612
|
-
/**
|
|
1613
|
-
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1614
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1612
|
+
/**
|
|
1613
|
+
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
|
|
1614
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
1615
1615
|
*/
|
|
1616
1616
|
advance
|
|
1617
1617
|
};
|
|
1618
1618
|
}
|
|
1619
1619
|
|
|
1620
|
-
/**
|
|
1621
|
-
* Exposes an object's {@link LocalState}.
|
|
1622
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1623
|
-
*
|
|
1624
|
-
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1620
|
+
/**
|
|
1621
|
+
* Exposes an object's {@link LocalState}.
|
|
1622
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
1623
|
+
*
|
|
1624
|
+
* **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
|
|
1625
1625
|
*/
|
|
1626
1626
|
function useInstanceHandle(ref) {
|
|
1627
1627
|
const instance = React__namespace.useRef(null);
|
|
@@ -1634,18 +1634,18 @@ function useStore() {
|
|
|
1634
1634
|
return store;
|
|
1635
1635
|
}
|
|
1636
1636
|
|
|
1637
|
-
/**
|
|
1638
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1639
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1637
|
+
/**
|
|
1638
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1639
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1640
1640
|
*/
|
|
1641
1641
|
function useThree(selector = state => state, equalityFn) {
|
|
1642
1642
|
return useStore()(selector, equalityFn);
|
|
1643
1643
|
}
|
|
1644
1644
|
|
|
1645
|
-
/**
|
|
1646
|
-
* Executes a callback before render in a shared frame loop.
|
|
1647
|
-
* Can order effects with render priority or manually render with a positive priority.
|
|
1648
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1645
|
+
/**
|
|
1646
|
+
* Executes a callback before render in a shared frame loop.
|
|
1647
|
+
* Can order effects with render priority or manually render with a positive priority.
|
|
1648
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1649
1649
|
*/
|
|
1650
1650
|
function useFrame(callback, renderPriority = 0) {
|
|
1651
1651
|
const store = useStore();
|
|
@@ -1657,9 +1657,9 @@ function useFrame(callback, renderPriority = 0) {
|
|
|
1657
1657
|
return null;
|
|
1658
1658
|
}
|
|
1659
1659
|
|
|
1660
|
-
/**
|
|
1661
|
-
* Returns a node graph of an object with named nodes & materials.
|
|
1662
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1660
|
+
/**
|
|
1661
|
+
* Returns a node graph of an object with named nodes & materials.
|
|
1662
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
1663
1663
|
*/
|
|
1664
1664
|
function useGraph(object) {
|
|
1665
1665
|
return React__namespace.useMemo(() => buildGraph(object), [object]);
|
|
@@ -1682,11 +1682,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1682
1682
|
};
|
|
1683
1683
|
}
|
|
1684
1684
|
|
|
1685
|
-
/**
|
|
1686
|
-
* Synchronously loads and caches assets with a three loader.
|
|
1687
|
-
*
|
|
1688
|
-
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1689
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1685
|
+
/**
|
|
1686
|
+
* Synchronously loads and caches assets with a three loader.
|
|
1687
|
+
*
|
|
1688
|
+
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
1689
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
1690
1690
|
*/
|
|
1691
1691
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1692
1692
|
// Use suspense to load async assets
|
|
@@ -1698,16 +1698,16 @@ function useLoader(Proto, input, extensions, onProgress) {
|
|
|
1698
1698
|
return Array.isArray(input) ? results : results[0];
|
|
1699
1699
|
}
|
|
1700
1700
|
|
|
1701
|
-
/**
|
|
1702
|
-
* Preloads an asset into cache as a side-effect.
|
|
1701
|
+
/**
|
|
1702
|
+
* Preloads an asset into cache as a side-effect.
|
|
1703
1703
|
*/
|
|
1704
1704
|
useLoader.preload = function (Proto, input, extensions) {
|
|
1705
1705
|
const keys = Array.isArray(input) ? input : [input];
|
|
1706
1706
|
return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
|
|
1707
1707
|
};
|
|
1708
1708
|
|
|
1709
|
-
/**
|
|
1710
|
-
* Removes a loaded asset from cache.
|
|
1709
|
+
/**
|
|
1710
|
+
* Removes a loaded asset from cache.
|
|
1711
1711
|
*/
|
|
1712
1712
|
useLoader.clear = function (Proto, input) {
|
|
1713
1713
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -2082,10 +2082,10 @@ function Portal({
|
|
|
2082
2082
|
children,
|
|
2083
2083
|
container
|
|
2084
2084
|
}) {
|
|
2085
|
-
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2086
|
-
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2087
|
-
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2088
|
-
* <Canvas>
|
|
2085
|
+
/** This has to be a component because it would not be able to call useThree/useStore otherwise since
|
|
2086
|
+
* if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
|
|
2087
|
+
* the "R3F hooks can only be used within the Canvas component!" warning:
|
|
2088
|
+
* <Canvas>
|
|
2089
2089
|
* {createPortal(...)} */
|
|
2090
2090
|
const {
|
|
2091
2091
|
events,
|
|
@@ -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-d1f17345.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -251,9 +251,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
251
251
|
}, fallback)));
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
/**
|
|
255
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
256
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
254
|
+
/**
|
|
255
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
256
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
257
257
|
*/
|
|
258
258
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
|
|
259
259
|
return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
|
|
@@ -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-ce1a9f04.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -251,9 +251,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
251
251
|
}, fallback)));
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
/**
|
|
255
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
256
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
254
|
+
/**
|
|
255
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
256
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
257
257
|
*/
|
|
258
258
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
|
|
259
259
|
return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-c4d1c86e.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-c4d1c86e.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';
|
|
@@ -224,9 +224,9 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
224
224
|
}, fallback)));
|
|
225
225
|
});
|
|
226
226
|
|
|
227
|
-
/**
|
|
228
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
229
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
227
|
+
/**
|
|
228
|
+
* A DOM canvas which accepts threejs elements as children.
|
|
229
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
230
230
|
*/
|
|
231
231
|
const Canvas = /*#__PURE__*/React.forwardRef(function CanvasWrapper(props, ref) {
|
|
232
232
|
return /*#__PURE__*/React.createElement(FiberProvider, null, /*#__PURE__*/React.createElement(CanvasImpl, _extends({}, props, {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-d1f17345.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -12,6 +12,7 @@ var itsFine = require('its-fine');
|
|
|
12
12
|
var expoAsset = require('expo-asset');
|
|
13
13
|
var fs = require('expo-file-system');
|
|
14
14
|
var base64Js = require('base64-js');
|
|
15
|
+
var buffer = require('buffer');
|
|
15
16
|
require('react-reconciler/constants');
|
|
16
17
|
require('zustand');
|
|
17
18
|
require('react-reconciler');
|
|
@@ -122,9 +123,9 @@ function createTouchEvents(store) {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
/**
|
|
126
|
-
* A native canvas which accepts threejs elements as children.
|
|
127
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
126
|
+
/**
|
|
127
|
+
* A native canvas which accepts threejs elements as children.
|
|
128
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
128
129
|
*/
|
|
129
130
|
const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
130
131
|
children,
|
|
@@ -271,9 +272,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
271
272
|
}));
|
|
272
273
|
});
|
|
273
274
|
|
|
274
|
-
/**
|
|
275
|
-
* A native canvas which accepts threejs elements as children.
|
|
276
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
275
|
+
/**
|
|
276
|
+
* A native canvas which accepts threejs elements as children.
|
|
277
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
277
278
|
*/
|
|
278
279
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
|
|
279
280
|
return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
|
|
@@ -291,54 +292,52 @@ function polyfills() {
|
|
|
291
292
|
}
|
|
292
293
|
|
|
293
294
|
// Patch Blob for ArrayBuffer if unsupported
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
};
|
|
336
|
-
}
|
|
295
|
+
try {
|
|
296
|
+
new Blob([new ArrayBuffer(4)]);
|
|
297
|
+
} catch (_) {
|
|
298
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
299
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
300
|
+
const blobId = uuidv4();
|
|
301
|
+
const items = parts.map(part => {
|
|
302
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
303
|
+
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
304
|
+
return {
|
|
305
|
+
data,
|
|
306
|
+
type: 'string'
|
|
307
|
+
};
|
|
308
|
+
} else if (part instanceof Blob) {
|
|
309
|
+
return {
|
|
310
|
+
data: part.data,
|
|
311
|
+
type: 'blob'
|
|
312
|
+
};
|
|
313
|
+
} else {
|
|
314
|
+
return {
|
|
315
|
+
data: String(part),
|
|
316
|
+
type: 'string'
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const size = items.reduce((acc, curr) => {
|
|
321
|
+
if (curr.type === 'string') {
|
|
322
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
323
|
+
} else {
|
|
324
|
+
return acc + curr.data.size;
|
|
325
|
+
}
|
|
326
|
+
}, 0);
|
|
327
|
+
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
328
|
+
return BlobManager.createFromOptions({
|
|
329
|
+
blobId,
|
|
330
|
+
offset: 0,
|
|
331
|
+
size,
|
|
332
|
+
type: options ? options.type : '',
|
|
333
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
334
|
+
});
|
|
335
|
+
};
|
|
337
336
|
}
|
|
338
337
|
async function getAsset(input) {
|
|
339
338
|
if (typeof input === 'string') {
|
|
340
|
-
// Don't process storage
|
|
341
|
-
if (input.startsWith('file:')
|
|
339
|
+
// Don't process storage
|
|
340
|
+
if (input.startsWith('file:')) return input;
|
|
342
341
|
|
|
343
342
|
// Unpack Blobs from react-native BlobManager
|
|
344
343
|
if (input.startsWith('blob:')) {
|
|
@@ -356,7 +355,18 @@ function polyfills() {
|
|
|
356
355
|
reader.onerror = rej;
|
|
357
356
|
reader.readAsText(blob);
|
|
358
357
|
});
|
|
359
|
-
|
|
358
|
+
input = `data:${blob.type};base64,${data}`;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Create safe URI for JSI
|
|
362
|
+
if (input.startsWith('data:')) {
|
|
363
|
+
const [header, data] = input.split(',');
|
|
364
|
+
const [, type] = header.split('/');
|
|
365
|
+
const uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
|
|
366
|
+
await fs__namespace.writeAsStringAsync(uri, data, {
|
|
367
|
+
encoding: fs__namespace.EncodingType.Base64
|
|
368
|
+
});
|
|
369
|
+
return uri;
|
|
360
370
|
}
|
|
361
371
|
}
|
|
362
372
|
|
|
@@ -382,18 +392,10 @@ function polyfills() {
|
|
|
382
392
|
|
|
383
393
|
// There's no Image in native, so create a data texture instead
|
|
384
394
|
THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
385
|
-
if (this.path) url = this.path + url;
|
|
395
|
+
if (this.path && typeof url === 'string') url = this.path + url;
|
|
396
|
+
this.manager.itemStart(url);
|
|
386
397
|
const texture = new THREE__namespace.Texture();
|
|
387
398
|
getAsset(url).then(async uri => {
|
|
388
|
-
// Create safe URI for JSI
|
|
389
|
-
if (uri.startsWith('data:')) {
|
|
390
|
-
const [header, data] = uri.split(',');
|
|
391
|
-
const [, type] = header.split('/');
|
|
392
|
-
uri = fs__namespace.cacheDirectory + uuidv4() + `.${type}`;
|
|
393
|
-
await fs__namespace.writeAsStringAsync(uri, data, {
|
|
394
|
-
encoding: fs__namespace.EncodingType.Base64
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
399
|
const {
|
|
398
400
|
width,
|
|
399
401
|
height
|
|
@@ -416,59 +418,35 @@ function polyfills() {
|
|
|
416
418
|
// @ts-ignore
|
|
417
419
|
texture.isDataTexture = true;
|
|
418
420
|
onLoad == null ? void 0 : onLoad(texture);
|
|
419
|
-
}).catch(
|
|
421
|
+
}).catch(error => {
|
|
422
|
+
onError == null ? void 0 : onError(error);
|
|
423
|
+
this.manager.itemError(url);
|
|
424
|
+
}).finally(() => {
|
|
425
|
+
this.manager.itemEnd(url);
|
|
426
|
+
});
|
|
420
427
|
return texture;
|
|
421
428
|
};
|
|
422
429
|
|
|
423
430
|
// Fetches assets via XMLHttpRequest
|
|
424
431
|
THREE__namespace.FileLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
425
|
-
if (this.path) url = this.path + url;
|
|
426
|
-
|
|
432
|
+
if (this.path && typeof url === 'string') url = this.path + url;
|
|
433
|
+
this.manager.itemStart(url);
|
|
427
434
|
getAsset(url).then(async uri => {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
this.manager.itemEnd(url);
|
|
440
|
-
} else {
|
|
441
|
-
onError == null ? void 0 : onError(event);
|
|
442
|
-
this.manager.itemError(url);
|
|
443
|
-
this.manager.itemEnd(url);
|
|
444
|
-
}
|
|
445
|
-
}, false);
|
|
446
|
-
request.addEventListener('progress', event => {
|
|
447
|
-
onProgress == null ? void 0 : onProgress(event);
|
|
448
|
-
}, false);
|
|
449
|
-
request.addEventListener('error', event => {
|
|
450
|
-
onError == null ? void 0 : onError(event);
|
|
451
|
-
this.manager.itemError(url);
|
|
452
|
-
this.manager.itemEnd(url);
|
|
453
|
-
}, false);
|
|
454
|
-
request.addEventListener('abort', event => {
|
|
455
|
-
onError == null ? void 0 : onError(event);
|
|
456
|
-
this.manager.itemError(url);
|
|
457
|
-
this.manager.itemEnd(url);
|
|
458
|
-
}, false);
|
|
459
|
-
if (this.responseType) request.responseType = this.responseType;
|
|
460
|
-
if (this.withCredentials) request.withCredentials = this.withCredentials;
|
|
461
|
-
for (const header in this.requestHeader) {
|
|
462
|
-
request.setRequestHeader(header, this.requestHeader[header]);
|
|
463
|
-
}
|
|
464
|
-
request.send(null);
|
|
465
|
-
this.manager.itemStart(url);
|
|
466
|
-
}).catch(onError);
|
|
467
|
-
return request;
|
|
435
|
+
const base64 = await fs__namespace.readAsStringAsync(uri, {
|
|
436
|
+
encoding: fs__namespace.EncodingType.Base64
|
|
437
|
+
});
|
|
438
|
+
const data = buffer.Buffer.from(base64, 'base64');
|
|
439
|
+
onLoad == null ? void 0 : onLoad(data.buffer);
|
|
440
|
+
}).catch(error => {
|
|
441
|
+
onError == null ? void 0 : onError(error);
|
|
442
|
+
this.manager.itemError(url);
|
|
443
|
+
}).finally(() => {
|
|
444
|
+
this.manager.itemEnd(url);
|
|
445
|
+
});
|
|
468
446
|
};
|
|
469
447
|
}
|
|
470
448
|
|
|
471
|
-
polyfills();
|
|
449
|
+
if (reactNative.Platform.OS !== 'web') polyfills();
|
|
472
450
|
|
|
473
451
|
exports.ReactThreeFiber = index.threeTypes;
|
|
474
452
|
exports._roots = index.roots;
|