@react-three/fiber 7.0.24 → 7.0.27

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.
@@ -81,7 +81,7 @@ function createEvents(store) {
81
81
  /** Sets up defaultRaycaster */
82
82
 
83
83
  function prepareRay(event) {
84
- var _raycaster$computeOff;
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
- offsetX,
97
- offsetY
98
- } = (_raycaster$computeOff = raycaster.computeOffsets == null ? void 0 : raycaster.computeOffsets(event, state)) != null ? _raycaster$computeOff : event;
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
  }
@@ -555,6 +552,8 @@ function createRenderer(roots) {
555
552
 
556
553
  if (instance.__r3f) instance.__r3f.memoizedProps = memoized;
557
554
  changes.forEach(([key, value, isEvent, keys]) => {
555
+ var _rootState$gl;
556
+
558
557
  let currentInstance = instance;
559
558
  let targetProp = currentInstance[key]; // Revolve dashed props
560
559
 
@@ -585,37 +584,38 @@ function createRenderer(roots) {
585
584
 
586
585
  if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
587
586
  } else value = 0;
588
- } // Deal with pointer events ...
587
+ }
589
588
 
589
+ const isLinear = (rootState == null ? void 0 : (_rootState$gl = rootState.gl) == null ? void 0 : _rootState$gl.outputEncoding) === THREE.LinearEncoding; // Deal with pointer events ...
590
590
 
591
591
  if (isEvent) {
592
592
  if (value) localState.handlers[key] = value;else delete localState.handlers[key];
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
- // 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 ...
608
- // https://github.com/pmndrs/react-three-fiber/issues/344
609
-
610
- if (!rootState.linear && 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 (!rootState.linear && currentInstance[key] instanceof THREE.Texture) currentInstance[key].encoding = THREE.sRGBEncoding;
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
  });
@@ -891,10 +891,13 @@ function createRenderer(roots) {
891
891
 
892
892
  instance.__r3f.objects = [];
893
893
  removeChild(parent, instance);
894
- appendChild(parent, newInstance) // This evil hack switches the react-internal fiber node
895
- // https://github.com/facebook/react/issues/14983
896
- // https://github.com/facebook/react/pull/15021
897
- ;
894
+ appendChild(parent, newInstance); // Re-bind event handlers
895
+
896
+ if (newInstance.raycast && newInstance.__r3f.eventCount) {
897
+ const rootState = newInstance.__r3f.root.getState();
898
+
899
+ rootState.internal.interaction.push(newInstance);
900
+ } // This evil hack switches the react-internal fiber node
898
901
  [fiber, fiber.alternate].forEach(fiber => {
899
902
  if (fiber !== null) {
900
903
  fiber.stateNode = newInstance;
@@ -1020,9 +1023,7 @@ function createRenderer(roots) {
1020
1023
  return !!localState.handlers;
1021
1024
  },
1022
1025
 
1023
- commitMount(instance)
1024
- /*, type, props*/
1025
- {
1026
+ commitMount(instance) {
1026
1027
  var _instance$__r3f8;
1027
1028
 
1028
1029
  // https://github.com/facebook/react/issues/20271
@@ -1534,6 +1535,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
1534
1535
  events,
1535
1536
  ...props
1536
1537
  }, forwardedRef) {
1538
+ const onPointerMissed = useMemoizedFn(props.onPointerMissed);
1537
1539
  const [containerRef, {
1538
1540
  width,
1539
1541
  height
@@ -1566,10 +1568,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
1566
1568
  width,
1567
1569
  height
1568
1570
  },
1571
+ onPointerMissed,
1569
1572
  events: events || createPointerEvents
1570
1573
  });
1571
1574
  }
1572
- }, [width, height, children]);
1575
+ }, [width, height, children, onPointerMissed]);
1573
1576
  useIsomorphicLayoutEffect(() => {
1574
1577
  const container = canvasRef.current;
1575
1578
  return () => unmountComponentAtNode(container);
@@ -1650,6 +1653,11 @@ function loadingFn(extensions, onProgress) {
1650
1653
  };
1651
1654
  }
1652
1655
 
1656
+ function useMemoizedFn(fn) {
1657
+ const fnRef = React.useRef(fn);
1658
+ React.useLayoutEffect(() => void (fnRef.current = fn), [fn]);
1659
+ return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
1660
+ }
1653
1661
  function useLoader(Proto, input, extensions, onProgress) {
1654
1662
  // Use suspense to load async assets
1655
1663
  const keys = Array.isArray(input) ? input : [input];
@@ -1835,8 +1843,7 @@ function dispose(obj) {
1835
1843
  if (obj.dispose && obj.type !== 'Scene') obj.dispose();
1836
1844
 
1837
1845
  for (const p in obj) {
1838
- var _dispose, _ref;
1839
- (_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
1846
+ p.dispose == null ? void 0 : p.dispose();
1840
1847
  delete obj[p];
1841
1848
  }
1842
1849
  }
@@ -1853,4 +1860,4 @@ reconciler.injectIntoDevTools({
1853
1860
  version: '17.0.2'
1854
1861
  });
1855
1862
 
1856
- 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 };
1863
+ 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 * from "../../dist/declarations/src/native";
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
- 'use strict';
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
- 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
- }
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.24",
3
+ "version": "7.0.27",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -42,6 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@babel/runtime": "^7.13.10",
45
+ "@types/react-reconciler": "^0.26.2",
45
46
  "react-merge-refs": "^1.1.0",
46
47
  "react-reconciler": "^0.26.2",
47
48
  "react-three-fiber": "0.0.0-deprecated",
@@ -55,7 +56,7 @@
55
56
  "peerDependencies": {
56
57
  "react": ">=17.0",
57
58
  "react-dom": ">=17.0",
58
- "three": ">=0.126"
59
+ "three": ">=0.133"
59
60
  },
60
61
  "peerDependenciesMeta": {
61
62
  "react-dom": {
@@ -1,388 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var index = require('../../dist/index-ff3eb68b.cjs.dev.js');
6
- var THREE = require('three');
7
- var expoAsset = require('expo-asset');
8
- var expoFileSystem = require('expo-file-system');
9
- var base64Arraybuffer = require('base64-arraybuffer');
10
- var suspendReact = require('suspend-react');
11
- var _extends = require('@babel/runtime/helpers/extends');
12
- var React = require('react');
13
- var reactNative = require('react-native');
14
- var expoGl = require('expo-gl');
15
- var Pressability = require('react-native/Libraries/Pressability/Pressability');
16
- require('react-reconciler/constants');
17
- require('zustand');
18
- require('react-reconciler');
19
- require('scheduler');
20
-
21
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
22
-
23
- function _interopNamespace(e) {
24
- if (e && e.__esModule) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () {
33
- return e[k];
34
- }
35
- });
36
- }
37
- });
38
- }
39
- n['default'] = e;
40
- return Object.freeze(n);
41
- }
42
-
43
- var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
44
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
45
- var Pressability__default = /*#__PURE__*/_interopDefault(Pressability);
46
-
47
- /**
48
- * Generates an asset based on input type.
49
- */
50
-
51
- const getAsset = input => {
52
- if (input instanceof expoAsset.Asset) return input;
53
-
54
- switch (typeof input) {
55
- case 'string':
56
- return expoAsset.Asset.fromURI(input);
57
-
58
- case 'number':
59
- return expoAsset.Asset.fromModule(input);
60
-
61
- default:
62
- throw 'Invalid asset! Must be a URI or module.';
63
- }
64
- };
65
- /**
66
- * Downloads from a local URI and decodes into an ArrayBuffer.
67
- */
68
-
69
-
70
- const toBuffer = async localUri => expoFileSystem.readAsStringAsync(localUri, {
71
- encoding: 'base64'
72
- }).then(base64Arraybuffer.decode);
73
-
74
- function loadingFn(extensions, onProgress) {
75
- return function (Proto, ...input) {
76
- // Construct new loader and run extensions
77
- const loader = new Proto();
78
- if (extensions) extensions(loader); // Go through the urls and load them
79
-
80
- return Promise.all(input.map(entry => new Promise(async (res, reject) => {
81
- // Construct URL
82
- const url = typeof entry === 'string' ? loader.path + entry : entry; // There's no Image in native, so we create & pass a data texture instead
83
-
84
- if (loader instanceof THREE__namespace.TextureLoader) {
85
- const asset = await getAsset(url).downloadAsync();
86
- const texture = new THREE__namespace.Texture();
87
- texture.isDataTexture = true;
88
- texture.image = {
89
- data: asset,
90
- width: asset.width,
91
- height: asset.height
92
- };
93
- texture.needsUpdate = true;
94
- return res(texture);
95
- } // Do similar for CubeTextures
96
-
97
-
98
- if (loader instanceof THREE__namespace.CubeTextureLoader) {
99
- const texture = new THREE__namespace.CubeTexture();
100
- texture.isDataTexture = true;
101
- texture.images = await Promise.all(url.map(async src => {
102
- const asset = await getAsset(src).downloadAsync();
103
- return {
104
- data: asset,
105
- width: asset.width,
106
- height: asset.height
107
- };
108
- }));
109
- texture.needsUpdate = true;
110
- return res(texture);
111
- } // If asset is external and not an Image, load it
112
-
113
-
114
- if (url.startsWith != null && url.startsWith('http') && Proto.prototype.hasOwnProperty('load')) {
115
- return loader.load(entry, data => {
116
- if (data.scene) Object.assign(data, index.buildGraph(data.scene));
117
- res(data);
118
- }, onProgress, error => reject(`Could not load ${url}: ${error.message}`));
119
- } // Otherwise, create a localUri and a file buffer
120
-
121
-
122
- const {
123
- localUri
124
- } = await getAsset(url).downloadAsync();
125
- const arrayBuffer = await toBuffer(localUri); // Parse it
126
-
127
- const parsed = loader.parse == null ? void 0 : loader.parse(arrayBuffer, undefined, data => {
128
- if (data.scene) Object.assign(data, index.buildGraph(data.scene));
129
- res(data);
130
- }, error => reject(`Could not load ${url}: ${error.message}`)); // Respect synchronous parsers which don't have callbacks
131
-
132
- if (parsed) return res(parsed);
133
- })));
134
- };
135
- }
136
-
137
- function useLoader(Proto, input, extensions, onProgress) {
138
- // Use suspense to load async assets
139
- const keys = Array.isArray(input) ? input : [input];
140
- const results = suspendReact.suspend(loadingFn(extensions, onProgress), [Proto, ...keys], {
141
- equal: index.is.equ
142
- }); // Return the object/s
143
-
144
- return Array.isArray(input) ? results : results[0];
145
- }
146
-
147
- useLoader.preload = function (Proto, input, extensions) {
148
- const keys = Array.isArray(input) ? input : [input];
149
- return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
150
- };
151
-
152
- useLoader.clear = function (Proto, input) {
153
- const keys = Array.isArray(input) ? input : [input];
154
- return suspendReact.clear([Proto, ...keys]);
155
- };
156
-
157
- const EVENTS = {
158
- PRESS: 'onPress',
159
- PRESSIN: 'onPressIn',
160
- PRESSOUT: 'onPressOut',
161
- LONGPRESS: 'onLongPress',
162
- HOVERIN: 'onHoverIn',
163
- HOVEROUT: 'onHoverOut',
164
- PRESSMOVE: 'onPressMove'
165
- };
166
- const DOM_EVENTS = {
167
- [EVENTS.PRESS]: 'onClick',
168
- [EVENTS.PRESSIN]: 'onPointerDown',
169
- [EVENTS.PRESSOUT]: 'onPointerUp',
170
- [EVENTS.LONGPRESS]: 'onDoubleClick',
171
- [EVENTS.HOVERIN]: 'onPointerOver',
172
- [EVENTS.HOVEROUT]: 'onPointerOut',
173
- [EVENTS.PRESSMOVE]: 'onPointerMove'
174
- };
175
- function createTouchEvents(store) {
176
- const {
177
- handlePointer
178
- } = index.createEvents(store);
179
-
180
- const handleTouch = (event, name) => {
181
- event.persist() // Apply offset
182
- ;
183
- event.nativeEvent.offsetX = event.nativeEvent.pageX;
184
- event.nativeEvent.offsetY = event.nativeEvent.pageY; // Emulate DOM event
185
-
186
- const callback = handlePointer(DOM_EVENTS[name]);
187
- return callback(event.nativeEvent);
188
- };
189
-
190
- return {
191
- connected: false,
192
- handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
193
- [name]: event => handleTouch(event, name)
194
- }), {}),
195
- connect: () => {
196
- const {
197
- set,
198
- events
199
- } = store.getState();
200
- events.disconnect == null ? void 0 : events.disconnect();
201
- const connected = new Pressability__default['default'](events == null ? void 0 : events.handlers);
202
- const handlers = connected.getEventHandlers();
203
- set(state => ({
204
- events: { ...state.events,
205
- connected,
206
- handlers
207
- }
208
- }));
209
- },
210
- disconnect: () => {
211
- const {
212
- set,
213
- events
214
- } = store.getState();
215
-
216
- if (events.connected) {
217
- events.connected.reset();
218
- set(state => ({
219
- events: { ...state.events,
220
- connected: false
221
- }
222
- }));
223
- }
224
- }
225
- };
226
- }
227
-
228
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'orthographic', 'frameloop', 'performance', 'clock', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
229
-
230
- function Block({
231
- set
232
- }) {
233
- React__namespace.useLayoutEffect(() => {
234
- set(new Promise(() => null));
235
- return () => set(false);
236
- }, [set]);
237
- return null;
238
- }
239
-
240
- class ErrorBoundary extends React__namespace.Component {
241
- constructor(...args) {
242
- super(...args);
243
- this.state = {
244
- error: false
245
- };
246
- }
247
-
248
- componentDidCatch(error) {
249
- this.props.set(error);
250
- }
251
-
252
- render() {
253
- return this.state.error ? null : this.props.children;
254
- }
255
-
256
- }
257
-
258
- ErrorBoundary.getDerivedStateFromError = () => ({
259
- error: true
260
- });
261
-
262
- const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
263
- children,
264
- fallback,
265
- style,
266
- events,
267
- ...props
268
- }, forwardedRef) => {
269
- // Create a known catalogue of Threejs-native elements
270
- // This will include the entire THREE namespace by default, users can extend
271
- // their own elements by using the createRoot API instead
272
- React__namespace.useMemo(() => index.extend(THREE__namespace), []);
273
- const [{
274
- width,
275
- height
276
- }, setSize] = React__namespace.useState({
277
- width: 0,
278
- height: 0
279
- });
280
- const [canvas, setCanvas] = React__namespace.useState(null);
281
- const [bind, setBind] = React__namespace.useState();
282
- const canvasProps = index.pick(props, CANVAS_PROPS);
283
- const viewProps = index.omit(props, CANVAS_PROPS);
284
- const [block, setBlock] = React__namespace.useState(false);
285
- const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
286
-
287
- if (block) throw block; // Throw exception outwards if anything within canvas throws
288
-
289
- if (error) throw error;
290
- const onLayout = React__namespace.useCallback(e => {
291
- const {
292
- width,
293
- height
294
- } = e.nativeEvent.layout;
295
- setSize({
296
- width,
297
- height
298
- });
299
- }, []);
300
- const onContextCreate = React__namespace.useCallback(context => {
301
- const canvasShim = {
302
- width: context.drawingBufferWidth,
303
- height: context.drawingBufferHeight,
304
- style: {},
305
- addEventListener: () => {},
306
- removeEventListener: () => {},
307
- clientHeight: context.drawingBufferHeight,
308
- getContext: () => context
309
- };
310
- setCanvas(canvasShim);
311
- }, []);
312
-
313
- if (width > 0 && height > 0 && canvas) {
314
- // Overwrite onCreated to apply RN bindings
315
- const onCreated = state => {
316
- // Bind events after creation
317
- setBind(state.events.handlers); // Bind render to RN bridge
318
-
319
- const context = state.gl.getContext();
320
- const renderFrame = state.gl.render.bind(state.gl);
321
-
322
- state.gl.render = (scene, camera) => {
323
- renderFrame(scene, camera);
324
- context.endFrameEXP();
325
- };
326
-
327
- return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
328
- };
329
-
330
- index.createRoot(canvas, { ...canvasProps,
331
- // expo-gl can only render at native dpr/resolution
332
- // https://github.com/expo/expo-three/issues/39
333
- dpr: reactNative.PixelRatio.get(),
334
- size: {
335
- width,
336
- height
337
- },
338
- events: events || createTouchEvents,
339
- onCreated
340
- }).render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
341
- set: setError
342
- }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
343
- fallback: /*#__PURE__*/React__namespace.createElement(Block, {
344
- set: setBlock
345
- })
346
- }, children)));
347
- }
348
-
349
- React__namespace.useEffect(() => {
350
- return () => index.unmountComponentAtNode(canvas);
351
- }, [canvas]);
352
- return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
353
- ref: forwardedRef,
354
- onLayout: onLayout,
355
- style: {
356
- flex: 1,
357
- ...style
358
- }
359
- }, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
360
- onContextCreate: onContextCreate,
361
- style: reactNative.StyleSheet.absoluteFill
362
- }));
363
- });
364
-
365
- exports.ReactThreeFiber = index.threeTypes;
366
- exports._roots = index.roots;
367
- exports.act = index.act;
368
- exports.addAfterEffect = index.addAfterEffect;
369
- exports.addEffect = index.addEffect;
370
- exports.addTail = index.addTail;
371
- exports.advance = index.advance;
372
- exports.applyProps = index.applyProps;
373
- exports.context = index.context;
374
- exports.createPortal = index.createPortal;
375
- exports.createRoot = index.createRoot;
376
- exports.dispose = index.dispose;
377
- exports.extend = index.extend;
378
- exports.invalidate = index.invalidate;
379
- exports.reconciler = index.reconciler;
380
- exports.render = index.render;
381
- exports.unmountComponentAtNode = index.unmountComponentAtNode;
382
- exports.useFrame = index.useFrame;
383
- exports.useGraph = index.useGraph;
384
- exports.useStore = index.useStore;
385
- exports.useThree = index.useThree;
386
- exports.Canvas = Canvas;
387
- exports.events = createTouchEvents;
388
- exports.useLoader = useLoader;