@react-three/fiber 8.0.9 → 8.0.12

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.
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, p as pick, o as omit, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-4e14a95b.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from './index-4e14a95b.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-38c121a8.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-38c121a8.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';
@@ -89,19 +89,29 @@ function createPointerEvents(store) {
89
89
  };
90
90
  }
91
91
 
92
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
93
92
  /**
94
93
  * A DOM canvas which accepts threejs elements as children.
95
94
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
96
95
  */
97
-
98
96
  const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
99
97
  children,
100
98
  fallback,
101
99
  resize,
102
100
  style,
103
- onPointerMissed,
101
+ gl,
104
102
  events = createPointerEvents,
103
+ shadows,
104
+ linear,
105
+ flat,
106
+ legacy,
107
+ orthographic,
108
+ frameloop,
109
+ dpr,
110
+ performance,
111
+ raycaster,
112
+ camera,
113
+ onPointerMissed,
114
+ onCreated,
105
115
  ...props
106
116
  }, forwardedRef) {
107
117
  // Create a known catalogue of Threejs-native elements
@@ -119,12 +129,10 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
119
129
  },
120
130
  ...resize
121
131
  });
122
- const meshRef = React.useRef(null);
123
132
  const canvasRef = React.useRef(null);
133
+ const meshRef = React.useRef(null);
124
134
  const [canvas, setCanvas] = React.useState(null);
125
135
  const handlePointerMissed = useMutableCallback(onPointerMissed);
126
- const canvasProps = pick(props, CANVAS_PROPS);
127
- const divProps = omit(props, CANVAS_PROPS);
128
136
  const [block, setBlock] = React.useState(false);
129
137
  const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
130
138
 
@@ -135,18 +143,29 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
135
143
 
136
144
  if (width > 0 && height > 0 && canvas) {
137
145
  if (!root.current) root.current = createRoot(canvas);
138
- root.current.configure({ ...canvasProps,
139
- // Pass mutable reference to onPointerMissed so it's free to update
140
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
141
- onCreated: state => {
142
- state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
143
- canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
144
- },
146
+ root.current.configure({
147
+ gl,
148
+ events,
149
+ shadows,
150
+ linear,
151
+ flat,
152
+ legacy,
153
+ orthographic,
154
+ frameloop,
155
+ dpr,
156
+ performance,
157
+ raycaster,
158
+ camera,
145
159
  size: {
146
160
  width,
147
161
  height
148
162
  },
149
- events
163
+ // Pass mutable reference to onPointerMissed so it's free to update
164
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
165
+ onCreated: state => {
166
+ state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
167
+ onCreated == null ? void 0 : onCreated(state);
168
+ }
150
169
  });
151
170
  root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
152
171
  set: setError
@@ -161,8 +180,8 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
161
180
  setCanvas(canvasRef.current);
162
181
  }, []);
163
182
  React.useEffect(() => {
164
- return () => unmountComponentAtNode(canvas);
165
- }, []);
183
+ if (canvas) return () => unmountComponentAtNode(canvas);
184
+ }, [canvas]);
166
185
  return /*#__PURE__*/React.createElement("div", _extends({
167
186
  ref: mergeRefs([meshRef, containerRef]),
168
187
  style: {
@@ -172,7 +191,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
172
191
  overflow: 'hidden',
173
192
  ...style
174
193
  }
175
- }, divProps), /*#__PURE__*/React.createElement("canvas", {
194
+ }, props), /*#__PURE__*/React.createElement("canvas", {
176
195
  ref: mergeRefs([canvasRef, forwardedRef]),
177
196
  style: {
178
197
  display: 'block'
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var THREE = require('three');
6
6
  var expoAsset = require('expo-asset');
7
- var index = require('../../dist/index-49237346.cjs.dev.js');
7
+ var index = require('../../dist/index-f67eaa0c.cjs.dev.js');
8
8
  var _extends = require('@babel/runtime/helpers/extends');
9
9
  var React = require('react');
10
10
  var mergeRefs = require('react-merge-refs');
@@ -28,14 +28,12 @@ function _interopNamespace(e) {
28
28
  var d = Object.getOwnPropertyDescriptor(e, k);
29
29
  Object.defineProperty(n, k, d.get ? d : {
30
30
  enumerable: true,
31
- get: function () {
32
- return e[k];
33
- }
31
+ get: function () { return e[k]; }
34
32
  });
35
33
  }
36
34
  });
37
35
  }
38
- n['default'] = e;
36
+ n["default"] = e;
39
37
  return Object.freeze(n);
40
38
  }
41
39
 
@@ -100,7 +98,7 @@ function createTouchEvents(store) {
100
98
  events
101
99
  } = store.getState();
102
100
  events.disconnect == null ? void 0 : events.disconnect();
103
- const connected = new Pressability__default['default'](events == null ? void 0 : events.handlers);
101
+ const connected = new Pressability__default["default"](events == null ? void 0 : events.handlers);
104
102
  set(state => ({
105
103
  events: { ...state.events,
106
104
  connected
@@ -127,17 +125,26 @@ function createTouchEvents(store) {
127
125
  };
128
126
  }
129
127
 
130
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
131
128
  /**
132
129
  * A native canvas which accepts threejs elements as children.
133
130
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
134
131
  */
135
-
136
132
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
137
133
  children,
138
134
  style,
139
- events,
135
+ gl,
136
+ events = createTouchEvents,
137
+ shadows,
138
+ linear,
139
+ flat,
140
+ legacy,
141
+ orthographic,
142
+ frameloop,
143
+ performance,
144
+ raycaster,
145
+ camera,
140
146
  onPointerMissed,
147
+ onCreated,
141
148
  ...props
142
149
  }, forwardedRef) => {
143
150
  // Create a known catalogue of Threejs-native elements
@@ -154,8 +161,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
154
161
  const [canvas, setCanvas] = React__namespace.useState(null);
155
162
  const [bind, setBind] = React__namespace.useState();
156
163
  const handlePointerMissed = index.useMutableCallback(onPointerMissed);
157
- const canvasProps = index.pick(props, CANVAS_PROPS);
158
- const viewProps = index.omit(props, CANVAS_PROPS);
159
164
  const [block, setBlock] = React__namespace.useState(false);
160
165
  const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
161
166
 
@@ -188,27 +193,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
188
193
  }, []);
189
194
 
190
195
  if (width > 0 && height > 0 && canvas) {
191
- if (!root.current) root.current = index.createRoot(canvas); // Overwrite onCreated to apply RN bindings
192
-
193
- const onCreated = state => {
194
- // Bind events after creation
195
- const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
196
- setBind(handlers); // Bind render to RN bridge
197
-
198
- const context = state.gl.getContext();
199
- const renderFrame = state.gl.render.bind(state.gl);
200
-
201
- state.gl.render = (scene, camera) => {
202
- renderFrame(scene, camera);
203
- context.endFrameEXP();
204
- };
205
-
206
- return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
207
- };
208
-
209
- root.current.configure({ ...canvasProps,
210
- // Pass mutable reference to onPointerMissed so it's free to update
211
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
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,
212
209
  // expo-gl can only render at native dpr/resolution
213
210
  // https://github.com/expo/expo-three/issues/39
214
211
  dpr: reactNative.PixelRatio.get(),
@@ -216,8 +213,24 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
216
213
  width,
217
214
  height
218
215
  },
219
- events: events || createTouchEvents,
220
- onCreated
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
+ }
221
234
  });
222
235
  root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
223
236
  set: setError
@@ -229,10 +242,12 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
229
242
  }
230
243
 
231
244
  React__namespace.useEffect(() => {
232
- return () => index.unmountComponentAtNode(canvas);
233
- }, []);
234
- return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
235
- ref: mergeRefs__default['default']([viewRef, forwardedRef]),
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]),
236
251
  onLayout: onLayout,
237
252
  style: {
238
253
  flex: 1,
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var THREE = require('three');
6
6
  var expoAsset = require('expo-asset');
7
- var index = require('../../dist/index-4dae9cc6.cjs.prod.js');
7
+ var index = require('../../dist/index-e322e5c8.cjs.prod.js');
8
8
  var _extends = require('@babel/runtime/helpers/extends');
9
9
  var React = require('react');
10
10
  var mergeRefs = require('react-merge-refs');
@@ -28,14 +28,12 @@ function _interopNamespace(e) {
28
28
  var d = Object.getOwnPropertyDescriptor(e, k);
29
29
  Object.defineProperty(n, k, d.get ? d : {
30
30
  enumerable: true,
31
- get: function () {
32
- return e[k];
33
- }
31
+ get: function () { return e[k]; }
34
32
  });
35
33
  }
36
34
  });
37
35
  }
38
- n['default'] = e;
36
+ n["default"] = e;
39
37
  return Object.freeze(n);
40
38
  }
41
39
 
@@ -100,7 +98,7 @@ function createTouchEvents(store) {
100
98
  events
101
99
  } = store.getState();
102
100
  events.disconnect == null ? void 0 : events.disconnect();
103
- const connected = new Pressability__default['default'](events == null ? void 0 : events.handlers);
101
+ const connected = new Pressability__default["default"](events == null ? void 0 : events.handlers);
104
102
  set(state => ({
105
103
  events: { ...state.events,
106
104
  connected
@@ -127,17 +125,26 @@ function createTouchEvents(store) {
127
125
  };
128
126
  }
129
127
 
130
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
131
128
  /**
132
129
  * A native canvas which accepts threejs elements as children.
133
130
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
134
131
  */
135
-
136
132
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
137
133
  children,
138
134
  style,
139
- events,
135
+ gl,
136
+ events = createTouchEvents,
137
+ shadows,
138
+ linear,
139
+ flat,
140
+ legacy,
141
+ orthographic,
142
+ frameloop,
143
+ performance,
144
+ raycaster,
145
+ camera,
140
146
  onPointerMissed,
147
+ onCreated,
141
148
  ...props
142
149
  }, forwardedRef) => {
143
150
  // Create a known catalogue of Threejs-native elements
@@ -154,8 +161,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
154
161
  const [canvas, setCanvas] = React__namespace.useState(null);
155
162
  const [bind, setBind] = React__namespace.useState();
156
163
  const handlePointerMissed = index.useMutableCallback(onPointerMissed);
157
- const canvasProps = index.pick(props, CANVAS_PROPS);
158
- const viewProps = index.omit(props, CANVAS_PROPS);
159
164
  const [block, setBlock] = React__namespace.useState(false);
160
165
  const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
161
166
 
@@ -188,27 +193,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
188
193
  }, []);
189
194
 
190
195
  if (width > 0 && height > 0 && canvas) {
191
- if (!root.current) root.current = index.createRoot(canvas); // Overwrite onCreated to apply RN bindings
192
-
193
- const onCreated = state => {
194
- // Bind events after creation
195
- const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
196
- setBind(handlers); // Bind render to RN bridge
197
-
198
- const context = state.gl.getContext();
199
- const renderFrame = state.gl.render.bind(state.gl);
200
-
201
- state.gl.render = (scene, camera) => {
202
- renderFrame(scene, camera);
203
- context.endFrameEXP();
204
- };
205
-
206
- return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
207
- };
208
-
209
- root.current.configure({ ...canvasProps,
210
- // Pass mutable reference to onPointerMissed so it's free to update
211
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
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,
212
209
  // expo-gl can only render at native dpr/resolution
213
210
  // https://github.com/expo/expo-three/issues/39
214
211
  dpr: reactNative.PixelRatio.get(),
@@ -216,8 +213,24 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
216
213
  width,
217
214
  height
218
215
  },
219
- events: events || createTouchEvents,
220
- onCreated
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
+ }
221
234
  });
222
235
  root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
223
236
  set: setError
@@ -229,10 +242,12 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
229
242
  }
230
243
 
231
244
  React__namespace.useEffect(() => {
232
- return () => index.unmountComponentAtNode(canvas);
233
- }, []);
234
- return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
235
- ref: mergeRefs__default['default']([viewRef, forwardedRef]),
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]),
236
251
  onLayout: onLayout,
237
252
  style: {
238
253
  flex: 1,
@@ -1,7 +1,7 @@
1
1
  import * as THREE from 'three';
2
2
  import { Asset } from 'expo-asset';
3
- import { c as createEvents, e as extend, u as useMutableCallback, p as pick, o as omit, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-4e14a95b.esm.js';
4
- export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from '../../dist/index-4e14a95b.esm.js';
3
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-38c121a8.esm.js';
4
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-38c121a8.esm.js';
5
5
  import _extends from '@babel/runtime/helpers/esm/extends';
6
6
  import * as React from 'react';
7
7
  import mergeRefs from 'react-merge-refs';
@@ -97,17 +97,26 @@ function createTouchEvents(store) {
97
97
  };
98
98
  }
99
99
 
100
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
101
100
  /**
102
101
  * A native canvas which accepts threejs elements as children.
103
102
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
104
103
  */
105
-
106
104
  const Canvas = /*#__PURE__*/React.forwardRef(({
107
105
  children,
108
106
  style,
109
- events,
107
+ gl,
108
+ events = createTouchEvents,
109
+ shadows,
110
+ linear,
111
+ flat,
112
+ legacy,
113
+ orthographic,
114
+ frameloop,
115
+ performance,
116
+ raycaster,
117
+ camera,
110
118
  onPointerMissed,
119
+ onCreated,
111
120
  ...props
112
121
  }, forwardedRef) => {
113
122
  // Create a known catalogue of Threejs-native elements
@@ -124,8 +133,6 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
124
133
  const [canvas, setCanvas] = React.useState(null);
125
134
  const [bind, setBind] = React.useState();
126
135
  const handlePointerMissed = useMutableCallback(onPointerMissed);
127
- const canvasProps = pick(props, CANVAS_PROPS);
128
- const viewProps = omit(props, CANVAS_PROPS);
129
136
  const [block, setBlock] = React.useState(false);
130
137
  const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
131
138
 
@@ -158,27 +165,19 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
158
165
  }, []);
159
166
 
160
167
  if (width > 0 && height > 0 && canvas) {
161
- if (!root.current) root.current = createRoot(canvas); // Overwrite onCreated to apply RN bindings
162
-
163
- const onCreated = state => {
164
- // Bind events after creation
165
- const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
166
- setBind(handlers); // Bind render to RN bridge
167
-
168
- const context = state.gl.getContext();
169
- const renderFrame = state.gl.render.bind(state.gl);
170
-
171
- state.gl.render = (scene, camera) => {
172
- renderFrame(scene, camera);
173
- context.endFrameEXP();
174
- };
175
-
176
- return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
177
- };
178
-
179
- root.current.configure({ ...canvasProps,
180
- // Pass mutable reference to onPointerMissed so it's free to update
181
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
168
+ if (!root.current) root.current = createRoot(canvas);
169
+ root.current.configure({
170
+ gl,
171
+ events,
172
+ shadows,
173
+ linear,
174
+ flat,
175
+ legacy,
176
+ orthographic,
177
+ frameloop,
178
+ performance,
179
+ raycaster,
180
+ camera,
182
181
  // expo-gl can only render at native dpr/resolution
183
182
  // https://github.com/expo/expo-three/issues/39
184
183
  dpr: PixelRatio.get(),
@@ -186,8 +185,24 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
186
185
  width,
187
186
  height
188
187
  },
189
- events: events || createTouchEvents,
190
- onCreated
188
+ // Pass mutable reference to onPointerMissed so it's free to update
189
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
190
+ // Overwrite onCreated to apply RN bindings
191
+ onCreated: state => {
192
+ // Bind events after creation
193
+ const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
194
+ setBind(handlers); // Bind render to RN bridge
195
+
196
+ const context = state.gl.getContext();
197
+ const renderFrame = state.gl.render.bind(state.gl);
198
+
199
+ state.gl.render = (scene, camera) => {
200
+ renderFrame(scene, camera);
201
+ context.endFrameEXP();
202
+ };
203
+
204
+ return onCreated == null ? void 0 : onCreated(state);
205
+ }
191
206
  });
192
207
  root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
193
208
  set: setError
@@ -199,9 +214,11 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
199
214
  }
200
215
 
201
216
  React.useEffect(() => {
202
- return () => unmountComponentAtNode(canvas);
203
- }, []);
204
- return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
217
+ if (canvas) {
218
+ return () => unmountComponentAtNode(canvas);
219
+ }
220
+ }, [canvas]);
221
+ return /*#__PURE__*/React.createElement(View, _extends({}, props, {
205
222
  ref: mergeRefs([viewRef, forwardedRef]),
206
223
  onLayout: onLayout,
207
224
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.0.9",
3
+ "version": "8.0.12",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@babel/runtime": "^7.17.8",
46
- "@types/react-reconciler": "^0.26.4",
46
+ "@types/react-reconciler": "^0.26.6",
47
47
  "react-merge-refs": "^1.1.0",
48
48
  "react-reconciler": "^0.27.0",
49
49
  "react-use-measure": "^2.1.1",