@react-three/fiber 7.0.26 → 7.0.29
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 +19 -1
- package/dist/declarations/src/core/events.d.ts +3 -3
- package/dist/declarations/src/core/hooks.d.ts +4 -1
- package/dist/declarations/src/core/renderer.d.ts +3 -3
- package/dist/declarations/src/core/store.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/three-types.d.ts +18 -0
- package/dist/declarations/src/web/Canvas.d.ts +2 -2
- package/dist/declarations/src/web/events.d.ts +2 -2
- package/dist/declarations/src/web/index.d.ts +4 -4
- package/dist/react-three-fiber.cjs.dev.js +45 -37
- package/dist/react-three-fiber.cjs.prod.js +45 -37
- package/dist/react-three-fiber.esm.js +39 -30
- 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 -2
- 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
|
@@ -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
|
});
|
|
@@ -756,8 +756,13 @@ function createRenderer(roots) {
|
|
|
756
756
|
|
|
757
757
|
if (child) {
|
|
758
758
|
if (child.attachArray) {
|
|
759
|
-
|
|
760
|
-
|
|
759
|
+
let array = parentInstance[child.attachArray];
|
|
760
|
+
|
|
761
|
+
if (!is.arr(array)) {
|
|
762
|
+
parentInstance[child.attachArray] = [];
|
|
763
|
+
array = parentInstance[child.attachArray];
|
|
764
|
+
}
|
|
765
|
+
|
|
761
766
|
array.splice(array.indexOf(beforeChild), 0, child);
|
|
762
767
|
} else if (child.attachObject || child.attach && !is.fun(child.attach)) {
|
|
763
768
|
// attach and attachObject don't have an order anyway, so just append
|
|
@@ -1023,9 +1028,7 @@ function createRenderer(roots) {
|
|
|
1023
1028
|
return !!localState.handlers;
|
|
1024
1029
|
},
|
|
1025
1030
|
|
|
1026
|
-
commitMount(instance)
|
|
1027
|
-
/*, type, props*/
|
|
1028
|
-
{
|
|
1031
|
+
commitMount(instance) {
|
|
1029
1032
|
var _instance$__r3f8;
|
|
1030
1033
|
|
|
1031
1034
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1537,6 +1540,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1537
1540
|
events,
|
|
1538
1541
|
...props
|
|
1539
1542
|
}, forwardedRef) {
|
|
1543
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1540
1544
|
const [containerRef, {
|
|
1541
1545
|
width,
|
|
1542
1546
|
height
|
|
@@ -1569,10 +1573,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1569
1573
|
width,
|
|
1570
1574
|
height
|
|
1571
1575
|
},
|
|
1576
|
+
onPointerMissed,
|
|
1572
1577
|
events: events || createPointerEvents
|
|
1573
1578
|
});
|
|
1574
1579
|
}
|
|
1575
|
-
}, [width, height, children]);
|
|
1580
|
+
}, [width, height, children, onPointerMissed]);
|
|
1576
1581
|
useIsomorphicLayoutEffect(() => {
|
|
1577
1582
|
const container = canvasRef.current;
|
|
1578
1583
|
return () => unmountComponentAtNode(container);
|
|
@@ -1653,6 +1658,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1653
1658
|
};
|
|
1654
1659
|
}
|
|
1655
1660
|
|
|
1661
|
+
function useMemoizedFn(fn) {
|
|
1662
|
+
const fnRef = React.useRef(fn);
|
|
1663
|
+
React.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
1664
|
+
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
1665
|
+
}
|
|
1656
1666
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1657
1667
|
// Use suspense to load async assets
|
|
1658
1668
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1838,8 +1848,7 @@ function dispose(obj) {
|
|
|
1838
1848
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1839
1849
|
|
|
1840
1850
|
for (const p in obj) {
|
|
1841
|
-
|
|
1842
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1851
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1843
1852
|
delete obj[p];
|
|
1844
1853
|
}
|
|
1845
1854
|
}
|
|
@@ -1856,4 +1865,4 @@ reconciler.injectIntoDevTools({
|
|
|
1856
1865
|
version: '17.0.2'
|
|
1857
1866
|
});
|
|
1858
1867
|
|
|
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 };
|
|
1868
|
+
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.29",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"main": "dist/react-three-fiber.cjs.js",
|
|
31
31
|
"module": "dist/react-three-fiber.esm.js",
|
|
32
32
|
"types": "dist/react-three-fiber.cjs.d.ts",
|
|
33
|
-
"react-native": "dist/native.js",
|
|
34
33
|
"sideEffects": false,
|
|
35
34
|
"preconstruct": {
|
|
36
35
|
"entrypoints": [
|
|
@@ -42,6 +41,7 @@
|
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"@babel/runtime": "^7.13.10",
|
|
44
|
+
"@types/react-reconciler": "^0.26.2",
|
|
45
45
|
"react-merge-refs": "^1.1.0",
|
|
46
46
|
"react-reconciler": "^0.26.2",
|
|
47
47
|
"react-three-fiber": "0.0.0-deprecated",
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var THREE = require('three');
|
|
6
|
-
var expoAsset = require('expo-asset');
|
|
7
|
-
var index = require('../../dist/index-95c17855.cjs.dev.js');
|
|
8
|
-
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var reactNative = require('react-native');
|
|
11
|
-
var expoGl = require('expo-gl');
|
|
12
|
-
var Pressability = require('react-native/Libraries/Pressability/Pressability');
|
|
13
|
-
require('suspend-react');
|
|
14
|
-
require('react-reconciler/constants');
|
|
15
|
-
require('zustand');
|
|
16
|
-
require('react-reconciler');
|
|
17
|
-
require('scheduler');
|
|
18
|
-
|
|
19
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
function _interopNamespace(e) {
|
|
22
|
-
if (e && e.__esModule) return e;
|
|
23
|
-
var n = Object.create(null);
|
|
24
|
-
if (e) {
|
|
25
|
-
Object.keys(e).forEach(function (k) {
|
|
26
|
-
if (k !== 'default') {
|
|
27
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return e[k];
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
n['default'] = e;
|
|
38
|
-
return Object.freeze(n);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
42
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
|
-
var Pressability__default = /*#__PURE__*/_interopDefault(Pressability);
|
|
44
|
-
|
|
45
|
-
const EVENTS = {
|
|
46
|
-
PRESS: 'onPress',
|
|
47
|
-
PRESSIN: 'onPressIn',
|
|
48
|
-
PRESSOUT: 'onPressOut',
|
|
49
|
-
LONGPRESS: 'onLongPress',
|
|
50
|
-
HOVERIN: 'onHoverIn',
|
|
51
|
-
HOVEROUT: 'onHoverOut',
|
|
52
|
-
PRESSMOVE: 'onPressMove'
|
|
53
|
-
};
|
|
54
|
-
const DOM_EVENTS = {
|
|
55
|
-
[EVENTS.PRESS]: 'onClick',
|
|
56
|
-
[EVENTS.PRESSIN]: 'onPointerDown',
|
|
57
|
-
[EVENTS.PRESSOUT]: 'onPointerUp',
|
|
58
|
-
[EVENTS.LONGPRESS]: 'onDoubleClick',
|
|
59
|
-
[EVENTS.HOVERIN]: 'onPointerOver',
|
|
60
|
-
[EVENTS.HOVEROUT]: 'onPointerOut',
|
|
61
|
-
[EVENTS.PRESSMOVE]: 'onPointerMove'
|
|
62
|
-
};
|
|
63
|
-
function createTouchEvents(store) {
|
|
64
|
-
const {
|
|
65
|
-
handlePointer
|
|
66
|
-
} = index.createEvents(store);
|
|
67
|
-
|
|
68
|
-
const handleTouch = (event, name) => {
|
|
69
|
-
event.persist() // Apply offset
|
|
70
|
-
;
|
|
71
|
-
event.nativeEvent.offsetX = event.nativeEvent.locationX;
|
|
72
|
-
event.nativeEvent.offsetY = event.nativeEvent.locationY; // Emulate DOM event
|
|
73
|
-
|
|
74
|
-
const callback = handlePointer(DOM_EVENTS[name]);
|
|
75
|
-
return callback(event.nativeEvent);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
connected: false,
|
|
80
|
-
handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
|
|
81
|
-
[name]: event => handleTouch(event, name)
|
|
82
|
-
}), {}),
|
|
83
|
-
connect: () => {
|
|
84
|
-
const {
|
|
85
|
-
set,
|
|
86
|
-
events
|
|
87
|
-
} = store.getState();
|
|
88
|
-
events.disconnect == null ? void 0 : events.disconnect();
|
|
89
|
-
const connected = new Pressability__default['default'](events == null ? void 0 : events.handlers);
|
|
90
|
-
set(state => ({
|
|
91
|
-
events: { ...state.events,
|
|
92
|
-
connected
|
|
93
|
-
}
|
|
94
|
-
}));
|
|
95
|
-
const handlers = connected.getEventHandlers();
|
|
96
|
-
return handlers;
|
|
97
|
-
},
|
|
98
|
-
disconnect: () => {
|
|
99
|
-
const {
|
|
100
|
-
set,
|
|
101
|
-
events
|
|
102
|
-
} = store.getState();
|
|
103
|
-
|
|
104
|
-
if (events.connected) {
|
|
105
|
-
events.connected.reset();
|
|
106
|
-
set(state => ({
|
|
107
|
-
events: { ...state.events,
|
|
108
|
-
connected: false
|
|
109
|
-
}
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'orthographic', 'frameloop', 'performance', 'clock', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
117
|
-
|
|
118
|
-
function Block({
|
|
119
|
-
set
|
|
120
|
-
}) {
|
|
121
|
-
React__namespace.useLayoutEffect(() => {
|
|
122
|
-
set(new Promise(() => null));
|
|
123
|
-
return () => set(false);
|
|
124
|
-
}, [set]);
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class ErrorBoundary extends React__namespace.Component {
|
|
129
|
-
constructor(...args) {
|
|
130
|
-
super(...args);
|
|
131
|
-
this.state = {
|
|
132
|
-
error: false
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
componentDidCatch(error) {
|
|
137
|
-
this.props.set(error);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
render() {
|
|
141
|
-
return this.state.error ? null : this.props.children;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
147
|
-
error: true
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
151
|
-
children,
|
|
152
|
-
fallback,
|
|
153
|
-
style,
|
|
154
|
-
events,
|
|
155
|
-
...props
|
|
156
|
-
}, forwardedRef) => {
|
|
157
|
-
// Create a known catalogue of Threejs-native elements
|
|
158
|
-
// This will include the entire THREE namespace by default, users can extend
|
|
159
|
-
// their own elements by using the createRoot API instead
|
|
160
|
-
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
161
|
-
const [{
|
|
162
|
-
width,
|
|
163
|
-
height
|
|
164
|
-
}, setSize] = React__namespace.useState({
|
|
165
|
-
width: 0,
|
|
166
|
-
height: 0
|
|
167
|
-
});
|
|
168
|
-
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
169
|
-
const [bind, setBind] = React__namespace.useState();
|
|
170
|
-
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
171
|
-
const viewProps = index.omit(props, CANVAS_PROPS);
|
|
172
|
-
const [block, setBlock] = React__namespace.useState(false);
|
|
173
|
-
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
174
|
-
|
|
175
|
-
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
176
|
-
|
|
177
|
-
if (error) throw error;
|
|
178
|
-
const onLayout = React__namespace.useCallback(e => {
|
|
179
|
-
const {
|
|
180
|
-
width,
|
|
181
|
-
height
|
|
182
|
-
} = e.nativeEvent.layout;
|
|
183
|
-
setSize({
|
|
184
|
-
width,
|
|
185
|
-
height
|
|
186
|
-
});
|
|
187
|
-
}, []);
|
|
188
|
-
const onContextCreate = React__namespace.useCallback(context => {
|
|
189
|
-
const canvasShim = {
|
|
190
|
-
width: context.drawingBufferWidth,
|
|
191
|
-
height: context.drawingBufferHeight,
|
|
192
|
-
style: {},
|
|
193
|
-
addEventListener: () => {},
|
|
194
|
-
removeEventListener: () => {},
|
|
195
|
-
clientHeight: context.drawingBufferHeight,
|
|
196
|
-
getContext: () => context
|
|
197
|
-
};
|
|
198
|
-
setCanvas(canvasShim);
|
|
199
|
-
}, []);
|
|
200
|
-
|
|
201
|
-
if (width > 0 && height > 0 && canvas) {
|
|
202
|
-
// Overwrite onCreated to apply RN bindings
|
|
203
|
-
const onCreated = state => {
|
|
204
|
-
// Bind events after creation
|
|
205
|
-
const handlers = state.events.connect == null ? void 0 : state.events.connect(canvas);
|
|
206
|
-
setBind(handlers); // Bind render to RN bridge
|
|
207
|
-
|
|
208
|
-
const context = state.gl.getContext();
|
|
209
|
-
const renderFrame = state.gl.render.bind(state.gl);
|
|
210
|
-
|
|
211
|
-
state.gl.render = (scene, camera) => {
|
|
212
|
-
renderFrame(scene, camera);
|
|
213
|
-
context.endFrameEXP();
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
index.createRoot(canvas, { ...canvasProps,
|
|
220
|
-
// expo-gl can only render at native dpr/resolution
|
|
221
|
-
// https://github.com/expo/expo-three/issues/39
|
|
222
|
-
dpr: reactNative.PixelRatio.get(),
|
|
223
|
-
size: {
|
|
224
|
-
width,
|
|
225
|
-
height
|
|
226
|
-
},
|
|
227
|
-
events: events || createTouchEvents,
|
|
228
|
-
onCreated
|
|
229
|
-
}).render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
|
|
230
|
-
set: setError
|
|
231
|
-
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
232
|
-
fallback: /*#__PURE__*/React__namespace.createElement(Block, {
|
|
233
|
-
set: setBlock
|
|
234
|
-
})
|
|
235
|
-
}, children)));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
React__namespace.useEffect(() => {
|
|
239
|
-
return () => index.unmountComponentAtNode(canvas);
|
|
240
|
-
}, [canvas]);
|
|
241
|
-
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
242
|
-
ref: forwardedRef,
|
|
243
|
-
onLayout: onLayout,
|
|
244
|
-
style: {
|
|
245
|
-
flex: 1,
|
|
246
|
-
...style
|
|
247
|
-
}
|
|
248
|
-
}, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
|
|
249
|
-
onContextCreate: onContextCreate,
|
|
250
|
-
style: reactNative.StyleSheet.absoluteFill
|
|
251
|
-
}));
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Generates an asset based on input type.
|
|
256
|
-
*/
|
|
257
|
-
|
|
258
|
-
const getAsset = input => {
|
|
259
|
-
if (input instanceof expoAsset.Asset) return input;
|
|
260
|
-
|
|
261
|
-
switch (typeof input) {
|
|
262
|
-
case 'string':
|
|
263
|
-
return expoAsset.Asset.fromURI(input);
|
|
264
|
-
|
|
265
|
-
case 'number':
|
|
266
|
-
return expoAsset.Asset.fromModule(input);
|
|
267
|
-
|
|
268
|
-
default:
|
|
269
|
-
throw 'Invalid asset! Must be a URI or module.';
|
|
270
|
-
}
|
|
271
|
-
}; // Don't pre-process urls, let expo-asset generate an absolute URL
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
THREE__namespace.LoaderUtils.extractUrlBase = () => './'; // There's no Image in native, so create a data texture instead
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
278
|
-
const texture = new THREE__namespace.Texture(); // @ts-expect-error
|
|
279
|
-
|
|
280
|
-
texture.isDataTexture = true;
|
|
281
|
-
getAsset(url).downloadAsync().then(asset => {
|
|
282
|
-
texture.image = {
|
|
283
|
-
data: asset,
|
|
284
|
-
width: asset.width,
|
|
285
|
-
height: asset.height
|
|
286
|
-
};
|
|
287
|
-
texture.needsUpdate = true;
|
|
288
|
-
onLoad == null ? void 0 : onLoad(texture);
|
|
289
|
-
}).catch(onError);
|
|
290
|
-
return texture;
|
|
291
|
-
}; // Fetches assets via XMLHttpRequest
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
THREE__namespace.FileLoader.prototype.load = function (url, onLoad, onProgress, onError) {
|
|
295
|
-
if (this.path) url = this.path + url;
|
|
296
|
-
const request = new XMLHttpRequest();
|
|
297
|
-
getAsset(url).downloadAsync().then(asset => {
|
|
298
|
-
request.open('GET', asset.uri, true);
|
|
299
|
-
request.addEventListener('load', event => {
|
|
300
|
-
if (request.status === 200) {
|
|
301
|
-
onLoad == null ? void 0 : onLoad(request.response);
|
|
302
|
-
this.manager.itemEnd(url);
|
|
303
|
-
} else {
|
|
304
|
-
onError == null ? void 0 : onError(event);
|
|
305
|
-
this.manager.itemError(url);
|
|
306
|
-
this.manager.itemEnd(url);
|
|
307
|
-
}
|
|
308
|
-
}, false);
|
|
309
|
-
request.addEventListener('progress', event => {
|
|
310
|
-
onProgress == null ? void 0 : onProgress(event);
|
|
311
|
-
}, false);
|
|
312
|
-
request.addEventListener('error', event => {
|
|
313
|
-
onError == null ? void 0 : onError(event);
|
|
314
|
-
this.manager.itemError(url);
|
|
315
|
-
this.manager.itemEnd(url);
|
|
316
|
-
}, false);
|
|
317
|
-
request.addEventListener('abort', event => {
|
|
318
|
-
onError == null ? void 0 : onError(event);
|
|
319
|
-
this.manager.itemError(url);
|
|
320
|
-
this.manager.itemEnd(url);
|
|
321
|
-
}, false);
|
|
322
|
-
if (this.responseType) request.responseType = this.responseType;
|
|
323
|
-
if (this.withCredentials) request.withCredentials = this.withCredentials;
|
|
324
|
-
|
|
325
|
-
for (const header in this.requestHeader) {
|
|
326
|
-
request.setRequestHeader(header, this.requestHeader[header]);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
request.send(null);
|
|
330
|
-
this.manager.itemStart(url);
|
|
331
|
-
});
|
|
332
|
-
return request;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
exports.ReactThreeFiber = index.threeTypes;
|
|
336
|
-
exports._roots = index.roots;
|
|
337
|
-
exports.act = index.act;
|
|
338
|
-
exports.addAfterEffect = index.addAfterEffect;
|
|
339
|
-
exports.addEffect = index.addEffect;
|
|
340
|
-
exports.addTail = index.addTail;
|
|
341
|
-
exports.advance = index.advance;
|
|
342
|
-
exports.applyProps = index.applyProps;
|
|
343
|
-
exports.context = index.context;
|
|
344
|
-
exports.createPortal = index.createPortal;
|
|
345
|
-
exports.createRoot = index.createRoot;
|
|
346
|
-
exports.dispose = index.dispose;
|
|
347
|
-
exports.extend = index.extend;
|
|
348
|
-
exports.invalidate = index.invalidate;
|
|
349
|
-
exports.reconciler = index.reconciler;
|
|
350
|
-
exports.render = index.render;
|
|
351
|
-
exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
352
|
-
exports.useFrame = index.useFrame;
|
|
353
|
-
exports.useGraph = index.useGraph;
|
|
354
|
-
exports.useLoader = index.useLoader;
|
|
355
|
-
exports.useStore = index.useStore;
|
|
356
|
-
exports.useThree = index.useThree;
|
|
357
|
-
exports.Canvas = Canvas;
|
|
358
|
-
exports.events = createTouchEvents;
|