@react-three/fiber 7.0.25 → 7.0.28
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 +63 -63
- package/dist/declarations/src/core/hooks.d.ts +32 -29
- package/dist/declarations/src/core/is.d.ts +9 -9
- package/dist/declarations/src/core/loop.d.ts +12 -12
- package/dist/declarations/src/core/renderer.d.ts +61 -61
- package/dist/declarations/src/core/store.d.ts +118 -116
- package/dist/declarations/src/index.d.ts +8 -7
- package/dist/declarations/src/three-types.d.ts +329 -311
- package/dist/declarations/src/web/Canvas.d.ts +13 -13
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/declarations/src/web/index.d.ts +36 -36
- package/dist/react-three-fiber.cjs.dev.js +51 -46
- package/dist/react-three-fiber.cjs.prod.js +51 -46
- package/dist/react-three-fiber.esm.js +45 -39
- package/native/dist/react-three-fiber-native.cjs.d.ts +1 -11
- package/native/dist/react-three-fiber-native.cjs.dev.js +369 -0
- package/native/dist/react-three-fiber-native.cjs.js +6 -15
- package/native/dist/react-three-fiber-native.cjs.prod.js +369 -0
- package/native/dist/react-three-fiber-native.esm.js +317 -0
- package/package.json +2 -1
|
@@ -81,7 +81,7 @@ function createEvents(store) {
|
|
|
81
81
|
/** Sets up defaultRaycaster */
|
|
82
82
|
|
|
83
83
|
function prepareRay(event) {
|
|
84
|
-
var
|
|
84
|
+
var _customOffsets$offset, _customOffsets$offset2, _customOffsets$width, _customOffsets$height;
|
|
85
85
|
|
|
86
86
|
const state = store.getState();
|
|
87
87
|
const {
|
|
@@ -92,14 +92,11 @@ function createEvents(store) {
|
|
|
92
92
|
} = state; // https://github.com/pmndrs/react-three-fiber/pull/782
|
|
93
93
|
// Events trigger outside of canvas when moved
|
|
94
94
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
width,
|
|
101
|
-
height
|
|
102
|
-
} = size;
|
|
95
|
+
const customOffsets = raycaster.computeOffsets == null ? void 0 : raycaster.computeOffsets(event, state);
|
|
96
|
+
const offsetX = (_customOffsets$offset = customOffsets == null ? void 0 : customOffsets.offsetX) != null ? _customOffsets$offset : event.offsetX;
|
|
97
|
+
const offsetY = (_customOffsets$offset2 = customOffsets == null ? void 0 : customOffsets.offsetY) != null ? _customOffsets$offset2 : event.offsetY;
|
|
98
|
+
const width = (_customOffsets$width = customOffsets == null ? void 0 : customOffsets.width) != null ? _customOffsets$width : size.width;
|
|
99
|
+
const height = (_customOffsets$height = customOffsets == null ? void 0 : customOffsets.height) != null ? _customOffsets$height : size.height;
|
|
103
100
|
mouse.set(offsetX / width * 2 - 1, -(offsetY / height) * 2 + 1);
|
|
104
101
|
raycaster.setFromCamera(mouse, camera);
|
|
105
102
|
}
|
|
@@ -596,29 +593,29 @@ function createRenderer(roots) {
|
|
|
596
593
|
localState.eventCount = Object.keys(localState.handlers).length;
|
|
597
594
|
} // Special treatment for objects with support for set/copy, and layers
|
|
598
595
|
else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE.Layers)) {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
612
|
-
|
|
613
|
-
if (!isLinear && isColor) targetProp.convertSRGBToLinear();
|
|
614
|
-
} // Else, just overwrite the value
|
|
615
|
-
|
|
616
|
-
} else {
|
|
617
|
-
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 ...
|
|
618
608
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
619
609
|
|
|
620
|
-
if (!isLinear &&
|
|
621
|
-
}
|
|
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
|
+
}
|
|
622
619
|
|
|
623
620
|
invalidateInstance(instance);
|
|
624
621
|
});
|
|
@@ -759,8 +756,13 @@ function createRenderer(roots) {
|
|
|
759
756
|
|
|
760
757
|
if (child) {
|
|
761
758
|
if (child.attachArray) {
|
|
762
|
-
|
|
763
|
-
|
|
759
|
+
let array = parentInstance[child.attachArray];
|
|
760
|
+
|
|
761
|
+
if (!is.arr(array)) {
|
|
762
|
+
parentInstance[child.attachArray] = [];
|
|
763
|
+
array = parentInstance[child.attachArray];
|
|
764
|
+
}
|
|
765
|
+
|
|
764
766
|
array.splice(array.indexOf(beforeChild), 0, child);
|
|
765
767
|
} else if (child.attachObject || child.attach && !is.fun(child.attach)) {
|
|
766
768
|
// attach and attachObject don't have an order anyway, so just append
|
|
@@ -1026,9 +1028,7 @@ function createRenderer(roots) {
|
|
|
1026
1028
|
return !!localState.handlers;
|
|
1027
1029
|
},
|
|
1028
1030
|
|
|
1029
|
-
commitMount(instance)
|
|
1030
|
-
/*, type, props*/
|
|
1031
|
-
{
|
|
1031
|
+
commitMount(instance) {
|
|
1032
1032
|
var _instance$__r3f8;
|
|
1033
1033
|
|
|
1034
1034
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1540,6 +1540,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1540
1540
|
events,
|
|
1541
1541
|
...props
|
|
1542
1542
|
}, forwardedRef) {
|
|
1543
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
1543
1544
|
const [containerRef, {
|
|
1544
1545
|
width,
|
|
1545
1546
|
height
|
|
@@ -1572,10 +1573,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
1572
1573
|
width,
|
|
1573
1574
|
height
|
|
1574
1575
|
},
|
|
1576
|
+
onPointerMissed,
|
|
1575
1577
|
events: events || createPointerEvents
|
|
1576
1578
|
});
|
|
1577
1579
|
}
|
|
1578
|
-
}, [width, height, children]);
|
|
1580
|
+
}, [width, height, children, onPointerMissed]);
|
|
1579
1581
|
useIsomorphicLayoutEffect(() => {
|
|
1580
1582
|
const container = canvasRef.current;
|
|
1581
1583
|
return () => unmountComponentAtNode(container);
|
|
@@ -1656,6 +1658,11 @@ function loadingFn(extensions, onProgress) {
|
|
|
1656
1658
|
};
|
|
1657
1659
|
}
|
|
1658
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
|
+
}
|
|
1659
1666
|
function useLoader(Proto, input, extensions, onProgress) {
|
|
1660
1667
|
// Use suspense to load async assets
|
|
1661
1668
|
const keys = Array.isArray(input) ? input : [input];
|
|
@@ -1841,8 +1848,7 @@ function dispose(obj) {
|
|
|
1841
1848
|
if (obj.dispose && obj.type !== 'Scene') obj.dispose();
|
|
1842
1849
|
|
|
1843
1850
|
for (const p in obj) {
|
|
1844
|
-
|
|
1845
|
-
(_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
|
|
1851
|
+
p.dispose == null ? void 0 : p.dispose();
|
|
1846
1852
|
delete obj[p];
|
|
1847
1853
|
}
|
|
1848
1854
|
}
|
|
@@ -1859,4 +1865,4 @@ reconciler.injectIntoDevTools({
|
|
|
1859
1865
|
version: '17.0.2'
|
|
1860
1866
|
});
|
|
1861
1867
|
|
|
1862
|
-
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,11 +1 @@
|
|
|
1
|
-
|
|
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
|
+
export * from "../../dist/declarations/src/native";
|
|
@@ -0,0 +1,369 @@
|
|
|
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-9ced08b3.cjs.dev.js');
|
|
8
|
+
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var mergeRefs = require('react-merge-refs');
|
|
11
|
+
var reactNative = require('react-native');
|
|
12
|
+
var expoGl = require('expo-gl');
|
|
13
|
+
var Pressability = require('react-native/Libraries/Pressability/Pressability');
|
|
14
|
+
require('react-reconciler/constants');
|
|
15
|
+
require('zustand');
|
|
16
|
+
require('react-reconciler');
|
|
17
|
+
require('scheduler');
|
|
18
|
+
require('suspend-react');
|
|
19
|
+
|
|
20
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
function _interopNamespace(e) {
|
|
23
|
+
if (e && e.__esModule) return e;
|
|
24
|
+
var n = Object.create(null);
|
|
25
|
+
if (e) {
|
|
26
|
+
Object.keys(e).forEach(function (k) {
|
|
27
|
+
if (k !== 'default') {
|
|
28
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
29
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return e[k]; }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
n["default"] = e;
|
|
37
|
+
return Object.freeze(n);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
41
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
42
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
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
|
+
/** Default R3F event manager for react-native */
|
|
64
|
+
|
|
65
|
+
function createTouchEvents(store) {
|
|
66
|
+
const {
|
|
67
|
+
handlePointer
|
|
68
|
+
} = index.createEvents(store);
|
|
69
|
+
|
|
70
|
+
const handleTouch = (event, name) => {
|
|
71
|
+
event.persist() // Apply offset
|
|
72
|
+
;
|
|
73
|
+
event.nativeEvent.offsetX = event.nativeEvent.locationX;
|
|
74
|
+
event.nativeEvent.offsetY = event.nativeEvent.locationY; // Emulate DOM event
|
|
75
|
+
|
|
76
|
+
const callback = handlePointer(DOM_EVENTS[name]);
|
|
77
|
+
return callback(event.nativeEvent);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
priority: 1,
|
|
82
|
+
enabled: true,
|
|
83
|
+
|
|
84
|
+
compute(event, state, previous) {
|
|
85
|
+
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
86
|
+
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
87
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
88
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
connected: undefined,
|
|
92
|
+
handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
|
|
93
|
+
[name]: event => handleTouch(event, name)
|
|
94
|
+
}), {}),
|
|
95
|
+
connect: () => {
|
|
96
|
+
const {
|
|
97
|
+
set,
|
|
98
|
+
events
|
|
99
|
+
} = store.getState();
|
|
100
|
+
events.disconnect == null ? void 0 : events.disconnect();
|
|
101
|
+
const connected = new Pressability__default["default"](events == null ? void 0 : events.handlers);
|
|
102
|
+
set(state => ({
|
|
103
|
+
events: { ...state.events,
|
|
104
|
+
connected
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
const handlers = connected.getEventHandlers();
|
|
108
|
+
return handlers;
|
|
109
|
+
},
|
|
110
|
+
disconnect: () => {
|
|
111
|
+
const {
|
|
112
|
+
set,
|
|
113
|
+
events
|
|
114
|
+
} = store.getState();
|
|
115
|
+
|
|
116
|
+
if (events.connected) {
|
|
117
|
+
events.connected.reset();
|
|
118
|
+
set(state => ({
|
|
119
|
+
events: { ...state.events,
|
|
120
|
+
connected: undefined
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A native canvas which accepts threejs elements as children.
|
|
130
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
131
|
+
*/
|
|
132
|
+
const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
133
|
+
children,
|
|
134
|
+
style,
|
|
135
|
+
gl,
|
|
136
|
+
events = createTouchEvents,
|
|
137
|
+
shadows,
|
|
138
|
+
linear,
|
|
139
|
+
flat,
|
|
140
|
+
legacy,
|
|
141
|
+
orthographic,
|
|
142
|
+
frameloop,
|
|
143
|
+
performance,
|
|
144
|
+
raycaster,
|
|
145
|
+
camera,
|
|
146
|
+
onPointerMissed,
|
|
147
|
+
onCreated,
|
|
148
|
+
...props
|
|
149
|
+
}, forwardedRef) => {
|
|
150
|
+
// Create a known catalogue of Threejs-native elements
|
|
151
|
+
// This will include the entire THREE namespace by default, users can extend
|
|
152
|
+
// their own elements by using the createRoot API instead
|
|
153
|
+
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
154
|
+
const [{
|
|
155
|
+
width,
|
|
156
|
+
height
|
|
157
|
+
}, setSize] = React__namespace.useState({
|
|
158
|
+
width: 0,
|
|
159
|
+
height: 0
|
|
160
|
+
});
|
|
161
|
+
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
162
|
+
const [bind, setBind] = React__namespace.useState();
|
|
163
|
+
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
164
|
+
const [block, setBlock] = React__namespace.useState(false);
|
|
165
|
+
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
166
|
+
|
|
167
|
+
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
168
|
+
|
|
169
|
+
if (error) throw error;
|
|
170
|
+
const viewRef = React__namespace.useRef(null);
|
|
171
|
+
const root = React__namespace.useRef(null);
|
|
172
|
+
const onLayout = React__namespace.useCallback(e => {
|
|
173
|
+
const {
|
|
174
|
+
width,
|
|
175
|
+
height
|
|
176
|
+
} = e.nativeEvent.layout;
|
|
177
|
+
setSize({
|
|
178
|
+
width,
|
|
179
|
+
height
|
|
180
|
+
});
|
|
181
|
+
}, []);
|
|
182
|
+
const onContextCreate = React__namespace.useCallback(context => {
|
|
183
|
+
const canvasShim = {
|
|
184
|
+
width: context.drawingBufferWidth,
|
|
185
|
+
height: context.drawingBufferHeight,
|
|
186
|
+
style: {},
|
|
187
|
+
addEventListener: () => {},
|
|
188
|
+
removeEventListener: () => {},
|
|
189
|
+
clientHeight: context.drawingBufferHeight,
|
|
190
|
+
getContext: () => context
|
|
191
|
+
};
|
|
192
|
+
setCanvas(canvasShim);
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
if (width > 0 && height > 0 && canvas) {
|
|
196
|
+
if (!root.current) root.current = index.createRoot(canvas);
|
|
197
|
+
root.current.configure({
|
|
198
|
+
gl,
|
|
199
|
+
events,
|
|
200
|
+
shadows,
|
|
201
|
+
linear,
|
|
202
|
+
flat,
|
|
203
|
+
legacy,
|
|
204
|
+
orthographic,
|
|
205
|
+
frameloop,
|
|
206
|
+
performance,
|
|
207
|
+
raycaster,
|
|
208
|
+
camera,
|
|
209
|
+
// expo-gl can only render at native dpr/resolution
|
|
210
|
+
// https://github.com/expo/expo-three/issues/39
|
|
211
|
+
dpr: reactNative.PixelRatio.get(),
|
|
212
|
+
size: {
|
|
213
|
+
width,
|
|
214
|
+
height
|
|
215
|
+
},
|
|
216
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
217
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
218
|
+
// Overwrite onCreated to apply RN bindings
|
|
219
|
+
onCreated: state => {
|
|
220
|
+
// Bind events after creation
|
|
221
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
222
|
+
setBind(handlers); // Bind render to RN bridge
|
|
223
|
+
|
|
224
|
+
const context = state.gl.getContext();
|
|
225
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
226
|
+
|
|
227
|
+
state.gl.render = (scene, camera) => {
|
|
228
|
+
renderFrame(scene, camera);
|
|
229
|
+
context.endFrameEXP();
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
236
|
+
set: setError
|
|
237
|
+
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
238
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
239
|
+
set: setBlock
|
|
240
|
+
})
|
|
241
|
+
}, children)));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
React__namespace.useEffect(() => {
|
|
245
|
+
if (canvas) {
|
|
246
|
+
return () => index.unmountComponentAtNode(canvas);
|
|
247
|
+
}
|
|
248
|
+
}, [canvas]);
|
|
249
|
+
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
|
|
250
|
+
ref: mergeRefs__default["default"]([viewRef, forwardedRef]),
|
|
251
|
+
onLayout: onLayout,
|
|
252
|
+
style: {
|
|
253
|
+
flex: 1,
|
|
254
|
+
...style
|
|
255
|
+
}
|
|
256
|
+
}, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
|
|
257
|
+
onContextCreate: onContextCreate,
|
|
258
|
+
style: reactNative.StyleSheet.absoluteFill
|
|
259
|
+
}));
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Generates an asset based on input type.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
const getAsset = input => {
|
|
267
|
+
if (input instanceof expoAsset.Asset) return input;
|
|
268
|
+
|
|
269
|
+
switch (typeof input) {
|
|
270
|
+
case 'string':
|
|
271
|
+
return expoAsset.Asset.fromURI(input);
|
|
272
|
+
|
|
273
|
+
case 'number':
|
|
274
|
+
return expoAsset.Asset.fromModule(input);
|
|
275
|
+
|
|
276
|
+
default:
|
|
277
|
+
throw 'Invalid asset! Must be a URI or module.';
|
|
278
|
+
}
|
|
279
|
+
}; // Don't pre-process urls, let expo-asset generate an absolute URL
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
const extractUrlBase = THREE__namespace.LoaderUtils.extractUrlBase.bind(THREE__namespace.LoaderUtils);
|
|
283
|
+
|
|
284
|
+
THREE__namespace.LoaderUtils.extractUrlBase = url => typeof url === 'string' ? extractUrlBase(url) : './'; // There's no Image in native, so create a data texture instead
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
|
|
288
|
+
const texture = new THREE__namespace.Texture(); // @ts-ignore
|
|
289
|
+
|
|
290
|
+
texture.isDataTexture = true;
|
|
291
|
+
getAsset(url).downloadAsync().then(asset => {
|
|
292
|
+
texture.image = {
|
|
293
|
+
data: asset,
|
|
294
|
+
width: asset.width,
|
|
295
|
+
height: asset.height
|
|
296
|
+
};
|
|
297
|
+
texture.needsUpdate = true;
|
|
298
|
+
onLoad == null ? void 0 : onLoad(texture);
|
|
299
|
+
}).catch(onError);
|
|
300
|
+
return texture;
|
|
301
|
+
}; // Fetches assets via XMLHttpRequest
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
THREE__namespace.FileLoader.prototype.load = function (url, onLoad, onProgress, onError) {
|
|
305
|
+
if (this.path) url = this.path + url;
|
|
306
|
+
const request = new XMLHttpRequest();
|
|
307
|
+
getAsset(url).downloadAsync().then(asset => {
|
|
308
|
+
request.open('GET', asset.uri, true);
|
|
309
|
+
request.addEventListener('load', event => {
|
|
310
|
+
if (request.status === 200) {
|
|
311
|
+
onLoad == null ? void 0 : onLoad(request.response);
|
|
312
|
+
this.manager.itemEnd(url);
|
|
313
|
+
} else {
|
|
314
|
+
onError == null ? void 0 : onError(event);
|
|
315
|
+
this.manager.itemError(url);
|
|
316
|
+
this.manager.itemEnd(url);
|
|
317
|
+
}
|
|
318
|
+
}, false);
|
|
319
|
+
request.addEventListener('progress', event => {
|
|
320
|
+
onProgress == null ? void 0 : onProgress(event);
|
|
321
|
+
}, false);
|
|
322
|
+
request.addEventListener('error', event => {
|
|
323
|
+
onError == null ? void 0 : onError(event);
|
|
324
|
+
this.manager.itemError(url);
|
|
325
|
+
this.manager.itemEnd(url);
|
|
326
|
+
}, false);
|
|
327
|
+
request.addEventListener('abort', event => {
|
|
328
|
+
onError == null ? void 0 : onError(event);
|
|
329
|
+
this.manager.itemError(url);
|
|
330
|
+
this.manager.itemEnd(url);
|
|
331
|
+
}, false);
|
|
332
|
+
if (this.responseType) request.responseType = this.responseType;
|
|
333
|
+
if (this.withCredentials) request.withCredentials = this.withCredentials;
|
|
334
|
+
|
|
335
|
+
for (const header in this.requestHeader) {
|
|
336
|
+
request.setRequestHeader(header, this.requestHeader[header]);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
request.send(null);
|
|
340
|
+
this.manager.itemStart(url);
|
|
341
|
+
});
|
|
342
|
+
return request;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
exports.ReactThreeFiber = index.threeTypes;
|
|
346
|
+
exports._roots = index.roots;
|
|
347
|
+
exports.act = index.act;
|
|
348
|
+
exports.addAfterEffect = index.addAfterEffect;
|
|
349
|
+
exports.addEffect = index.addEffect;
|
|
350
|
+
exports.addTail = index.addTail;
|
|
351
|
+
exports.advance = index.advance;
|
|
352
|
+
exports.applyProps = index.applyProps;
|
|
353
|
+
exports.context = index.context;
|
|
354
|
+
exports.createPortal = index.createPortal;
|
|
355
|
+
exports.createRoot = index.createRoot;
|
|
356
|
+
exports.dispose = index.dispose;
|
|
357
|
+
exports.extend = index.extend;
|
|
358
|
+
exports.getRootState = index.getRootState;
|
|
359
|
+
exports.invalidate = index.invalidate;
|
|
360
|
+
exports.reconciler = index.reconciler;
|
|
361
|
+
exports.render = index.render;
|
|
362
|
+
exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
363
|
+
exports.useFrame = index.useFrame;
|
|
364
|
+
exports.useGraph = index.useGraph;
|
|
365
|
+
exports.useLoader = index.useLoader;
|
|
366
|
+
exports.useStore = index.useStore;
|
|
367
|
+
exports.useThree = index.useThree;
|
|
368
|
+
exports.Canvas = Canvas;
|
|
369
|
+
exports.events = createTouchEvents;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unregister();
|
|
3
|
+
if (process.env.NODE_ENV === "production") {
|
|
4
|
+
module.exports = require("./react-three-fiber-native.cjs.prod.js");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./react-three-fiber-native.cjs.dev.js");
|
|
7
|
+
}
|