@react-three/fiber 8.0.0-beta.5 → 8.0.0-beta.8
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/dist/declarations/src/core/events.d.ts +11 -6
- package/dist/declarations/src/core/hooks.d.ts +6 -6
- package/dist/declarations/src/core/index.d.ts +13 -5
- package/dist/declarations/src/core/store.d.ts +12 -21
- package/dist/declarations/src/core/utils.d.ts +2 -1
- package/dist/{index-5dc2de40.cjs.dev.js → index-2056f0b6.cjs.dev.js} +144 -131
- package/dist/{index-32069e53.esm.js → index-3238fd12.esm.js} +143 -131
- package/dist/{index-e2a317e2.cjs.prod.js → index-f5108bb9.cjs.prod.js} +144 -131
- package/dist/react-three-fiber.cjs.dev.js +28 -7
- package/dist/react-three-fiber.cjs.prod.js +28 -7
- package/dist/react-three-fiber.esm.js +27 -7
- package/native/dist/react-three-fiber-native.cjs.dev.js +27 -8
- package/native/dist/react-three-fiber-native.cjs.prod.js +27 -8
- package/native/dist/react-three-fiber-native.esm.js +25 -8
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, p as pick, o as omit, a as createRoot,
|
|
2
|
-
export { t as ReactThreeFiber,
|
|
1
|
+
import { c as createEvents, e as extend, u as useMemoizedFn, p as pick, o as omit, a as createRoot, b as unmountComponentAtNode } from './index-3238fd12.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, v as _roots, s as act, m as addAfterEffect, l as addEffect, n as addTail, k as advance, h as applyProps, d as context, f as createPortal, a as createRoot, i as dispose, e as extend, q as getRootState, j as invalidate, g as reconciler, r as render, b as unmountComponentAtNode, y as useFrame, z as useGraph, A as useLoader, u as useMemoizedFn, w as useStore, x as useThree } from './index-3238fd12.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';
|
|
@@ -28,7 +28,17 @@ function createPointerEvents(store) {
|
|
|
28
28
|
handlePointer
|
|
29
29
|
} = createEvents(store);
|
|
30
30
|
return {
|
|
31
|
-
|
|
31
|
+
priority: 1,
|
|
32
|
+
enabled: true,
|
|
33
|
+
|
|
34
|
+
compute(event, state, previous) {
|
|
35
|
+
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
36
|
+
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
37
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
38
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
connected: undefined,
|
|
32
42
|
handlers: Object.keys(DOM_EVENTS).reduce((acc, key) => ({ ...acc,
|
|
33
43
|
[key]: handlePointer(key)
|
|
34
44
|
}), {}),
|
|
@@ -69,7 +79,7 @@ function createPointerEvents(store) {
|
|
|
69
79
|
});
|
|
70
80
|
set(state => ({
|
|
71
81
|
events: { ...state.events,
|
|
72
|
-
connected:
|
|
82
|
+
connected: undefined
|
|
73
83
|
}
|
|
74
84
|
}));
|
|
75
85
|
}
|
|
@@ -123,6 +133,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
123
133
|
// This will include the entire THREE namespace by default, users can extend
|
|
124
134
|
// their own elements by using the createRoot API instead
|
|
125
135
|
React.useMemo(() => extend(THREE), []);
|
|
136
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
126
137
|
const [containerRef, {
|
|
127
138
|
width,
|
|
128
139
|
height
|
|
@@ -134,10 +145,15 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
134
145
|
},
|
|
135
146
|
...resize
|
|
136
147
|
});
|
|
148
|
+
const meshRef = React.useRef(null);
|
|
137
149
|
const canvasRef = React.useRef(null);
|
|
138
150
|
const [canvas, setCanvas] = React.useState(null);
|
|
139
|
-
const canvasProps = pick(props,
|
|
140
|
-
|
|
151
|
+
const canvasProps = pick({ ...props,
|
|
152
|
+
onPointerMissed
|
|
153
|
+
}, CANVAS_PROPS);
|
|
154
|
+
const divProps = omit({ ...props,
|
|
155
|
+
onPointerMissed
|
|
156
|
+
}, CANVAS_PROPS);
|
|
141
157
|
const [block, setBlock] = React.useState(false);
|
|
142
158
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
143
159
|
|
|
@@ -149,6 +165,10 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
149
165
|
if (width > 0 && height > 0 && canvas) {
|
|
150
166
|
if (!root.current) root.current = createRoot(canvas);
|
|
151
167
|
root.current.configure({ ...canvasProps,
|
|
168
|
+
onCreated: state => {
|
|
169
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
170
|
+
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
171
|
+
},
|
|
152
172
|
size: {
|
|
153
173
|
width,
|
|
154
174
|
height
|
|
@@ -171,7 +191,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
171
191
|
return () => unmountComponentAtNode(canvas);
|
|
172
192
|
}, [canvas]);
|
|
173
193
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
174
|
-
ref: containerRef,
|
|
194
|
+
ref: mergeRefs([meshRef, containerRef]),
|
|
175
195
|
style: {
|
|
176
196
|
position: 'relative',
|
|
177
197
|
width: '100%',
|
|
@@ -4,9 +4,10 @@ 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-
|
|
7
|
+
var index = require('../../dist/index-2056f0b6.cjs.dev.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
|
+
var mergeRefs = require('react-merge-refs');
|
|
10
11
|
var reactNative = require('react-native');
|
|
11
12
|
var expoGl = require('expo-gl');
|
|
12
13
|
var Pressability = require('react-native/Libraries/Pressability/Pressability');
|
|
@@ -40,6 +41,7 @@ function _interopNamespace(e) {
|
|
|
40
41
|
|
|
41
42
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
42
43
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
44
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
43
45
|
var Pressability__default = /*#__PURE__*/_interopDefault(Pressability);
|
|
44
46
|
|
|
45
47
|
const EVENTS = {
|
|
@@ -76,7 +78,17 @@ function createTouchEvents(store) {
|
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
return {
|
|
79
|
-
|
|
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,
|
|
80
92
|
handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
|
|
81
93
|
[name]: event => handleTouch(event, name)
|
|
82
94
|
}), {}),
|
|
@@ -105,7 +117,7 @@ function createTouchEvents(store) {
|
|
|
105
117
|
events.connected.reset();
|
|
106
118
|
set(state => ({
|
|
107
119
|
events: { ...state.events,
|
|
108
|
-
connected:
|
|
120
|
+
connected: undefined
|
|
109
121
|
}
|
|
110
122
|
}));
|
|
111
123
|
}
|
|
@@ -158,6 +170,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
158
170
|
// This will include the entire THREE namespace by default, users can extend
|
|
159
171
|
// their own elements by using the createRoot API instead
|
|
160
172
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
173
|
+
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
161
174
|
const [{
|
|
162
175
|
width,
|
|
163
176
|
height
|
|
@@ -167,14 +180,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
167
180
|
});
|
|
168
181
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
169
182
|
const [bind, setBind] = React__namespace.useState();
|
|
170
|
-
const canvasProps = index.pick(props,
|
|
171
|
-
|
|
183
|
+
const canvasProps = index.pick({ ...props,
|
|
184
|
+
onPointerMissed
|
|
185
|
+
}, CANVAS_PROPS);
|
|
186
|
+
const viewProps = index.omit({ ...props,
|
|
187
|
+
onPointerMissed
|
|
188
|
+
}, CANVAS_PROPS);
|
|
172
189
|
const [block, setBlock] = React__namespace.useState(false);
|
|
173
190
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
174
191
|
|
|
175
192
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
176
193
|
|
|
177
194
|
if (error) throw error;
|
|
195
|
+
const viewRef = React__namespace.useRef(null);
|
|
178
196
|
const root = React__namespace.useRef(null);
|
|
179
197
|
const onLayout = React__namespace.useCallback(e => {
|
|
180
198
|
const {
|
|
@@ -204,7 +222,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
204
222
|
|
|
205
223
|
const onCreated = state => {
|
|
206
224
|
// Bind events after creation
|
|
207
|
-
const handlers = state.events.connect == null ? void 0 : state.events.connect(
|
|
225
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
208
226
|
setBind(handlers); // Bind render to RN bridge
|
|
209
227
|
|
|
210
228
|
const context = state.gl.getContext();
|
|
@@ -242,7 +260,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
242
260
|
return () => index.unmountComponentAtNode(canvas);
|
|
243
261
|
}, [canvas]);
|
|
244
262
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
245
|
-
ref: forwardedRef,
|
|
263
|
+
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
246
264
|
onLayout: onLayout,
|
|
247
265
|
style: {
|
|
248
266
|
flex: 1,
|
|
@@ -350,14 +368,15 @@ exports.createPortal = index.createPortal;
|
|
|
350
368
|
exports.createRoot = index.createRoot;
|
|
351
369
|
exports.dispose = index.dispose;
|
|
352
370
|
exports.extend = index.extend;
|
|
371
|
+
exports.getRootState = index.getRootState;
|
|
353
372
|
exports.invalidate = index.invalidate;
|
|
354
373
|
exports.reconciler = index.reconciler;
|
|
355
374
|
exports.render = index.render;
|
|
356
375
|
exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
357
376
|
exports.useFrame = index.useFrame;
|
|
358
377
|
exports.useGraph = index.useGraph;
|
|
359
|
-
exports.useInject = index.useInject;
|
|
360
378
|
exports.useLoader = index.useLoader;
|
|
379
|
+
exports.useMemoizedFn = index.useMemoizedFn;
|
|
361
380
|
exports.useStore = index.useStore;
|
|
362
381
|
exports.useThree = index.useThree;
|
|
363
382
|
exports.Canvas = Canvas;
|
|
@@ -4,9 +4,10 @@ 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-
|
|
7
|
+
var index = require('../../dist/index-f5108bb9.cjs.prod.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
|
+
var mergeRefs = require('react-merge-refs');
|
|
10
11
|
var reactNative = require('react-native');
|
|
11
12
|
var expoGl = require('expo-gl');
|
|
12
13
|
var Pressability = require('react-native/Libraries/Pressability/Pressability');
|
|
@@ -40,6 +41,7 @@ function _interopNamespace(e) {
|
|
|
40
41
|
|
|
41
42
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
42
43
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
44
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
43
45
|
var Pressability__default = /*#__PURE__*/_interopDefault(Pressability);
|
|
44
46
|
|
|
45
47
|
const EVENTS = {
|
|
@@ -76,7 +78,17 @@ function createTouchEvents(store) {
|
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
return {
|
|
79
|
-
|
|
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,
|
|
80
92
|
handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
|
|
81
93
|
[name]: event => handleTouch(event, name)
|
|
82
94
|
}), {}),
|
|
@@ -105,7 +117,7 @@ function createTouchEvents(store) {
|
|
|
105
117
|
events.connected.reset();
|
|
106
118
|
set(state => ({
|
|
107
119
|
events: { ...state.events,
|
|
108
|
-
connected:
|
|
120
|
+
connected: undefined
|
|
109
121
|
}
|
|
110
122
|
}));
|
|
111
123
|
}
|
|
@@ -158,6 +170,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
158
170
|
// This will include the entire THREE namespace by default, users can extend
|
|
159
171
|
// their own elements by using the createRoot API instead
|
|
160
172
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
173
|
+
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
161
174
|
const [{
|
|
162
175
|
width,
|
|
163
176
|
height
|
|
@@ -167,14 +180,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
167
180
|
});
|
|
168
181
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
169
182
|
const [bind, setBind] = React__namespace.useState();
|
|
170
|
-
const canvasProps = index.pick(props,
|
|
171
|
-
|
|
183
|
+
const canvasProps = index.pick({ ...props,
|
|
184
|
+
onPointerMissed
|
|
185
|
+
}, CANVAS_PROPS);
|
|
186
|
+
const viewProps = index.omit({ ...props,
|
|
187
|
+
onPointerMissed
|
|
188
|
+
}, CANVAS_PROPS);
|
|
172
189
|
const [block, setBlock] = React__namespace.useState(false);
|
|
173
190
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
174
191
|
|
|
175
192
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
176
193
|
|
|
177
194
|
if (error) throw error;
|
|
195
|
+
const viewRef = React__namespace.useRef(null);
|
|
178
196
|
const root = React__namespace.useRef(null);
|
|
179
197
|
const onLayout = React__namespace.useCallback(e => {
|
|
180
198
|
const {
|
|
@@ -204,7 +222,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
204
222
|
|
|
205
223
|
const onCreated = state => {
|
|
206
224
|
// Bind events after creation
|
|
207
|
-
const handlers = state.events.connect == null ? void 0 : state.events.connect(
|
|
225
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
208
226
|
setBind(handlers); // Bind render to RN bridge
|
|
209
227
|
|
|
210
228
|
const context = state.gl.getContext();
|
|
@@ -242,7 +260,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
242
260
|
return () => index.unmountComponentAtNode(canvas);
|
|
243
261
|
}, [canvas]);
|
|
244
262
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
245
|
-
ref: forwardedRef,
|
|
263
|
+
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
246
264
|
onLayout: onLayout,
|
|
247
265
|
style: {
|
|
248
266
|
flex: 1,
|
|
@@ -350,14 +368,15 @@ exports.createPortal = index.createPortal;
|
|
|
350
368
|
exports.createRoot = index.createRoot;
|
|
351
369
|
exports.dispose = index.dispose;
|
|
352
370
|
exports.extend = index.extend;
|
|
371
|
+
exports.getRootState = index.getRootState;
|
|
353
372
|
exports.invalidate = index.invalidate;
|
|
354
373
|
exports.reconciler = index.reconciler;
|
|
355
374
|
exports.render = index.render;
|
|
356
375
|
exports.unmountComponentAtNode = index.unmountComponentAtNode;
|
|
357
376
|
exports.useFrame = index.useFrame;
|
|
358
377
|
exports.useGraph = index.useGraph;
|
|
359
|
-
exports.useInject = index.useInject;
|
|
360
378
|
exports.useLoader = index.useLoader;
|
|
379
|
+
exports.useMemoizedFn = index.useMemoizedFn;
|
|
361
380
|
exports.useStore = index.useStore;
|
|
362
381
|
exports.useThree = index.useThree;
|
|
363
382
|
exports.Canvas = Canvas;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { Asset } from 'expo-asset';
|
|
3
|
-
import { c as createEvents, e as extend, p as pick, o as omit, a as createRoot,
|
|
4
|
-
export { t as ReactThreeFiber,
|
|
3
|
+
import { c as createEvents, e as extend, u as useMemoizedFn, p as pick, o as omit, a as createRoot, b as unmountComponentAtNode } from '../../dist/index-3238fd12.esm.js';
|
|
4
|
+
export { t as ReactThreeFiber, v as _roots, s as act, m as addAfterEffect, l as addEffect, n as addTail, k as advance, h as applyProps, d as context, f as createPortal, a as createRoot, i as dispose, e as extend, q as getRootState, j as invalidate, g as reconciler, r as render, b as unmountComponentAtNode, y as useFrame, z as useGraph, A as useLoader, u as useMemoizedFn, w as useStore, x as useThree } from '../../dist/index-3238fd12.esm.js';
|
|
5
5
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
+
import mergeRefs from 'react-merge-refs';
|
|
7
8
|
import { PixelRatio, View, StyleSheet } from 'react-native';
|
|
8
9
|
import { GLView } from 'expo-gl';
|
|
9
10
|
import Pressability from 'react-native/Libraries/Pressability/Pressability';
|
|
@@ -47,7 +48,17 @@ function createTouchEvents(store) {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
return {
|
|
50
|
-
|
|
51
|
+
priority: 1,
|
|
52
|
+
enabled: true,
|
|
53
|
+
|
|
54
|
+
compute(event, state, previous) {
|
|
55
|
+
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
56
|
+
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
57
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
58
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
connected: undefined,
|
|
51
62
|
handlers: Object.values(EVENTS).reduce((acc, name) => ({ ...acc,
|
|
52
63
|
[name]: event => handleTouch(event, name)
|
|
53
64
|
}), {}),
|
|
@@ -76,7 +87,7 @@ function createTouchEvents(store) {
|
|
|
76
87
|
events.connected.reset();
|
|
77
88
|
set(state => ({
|
|
78
89
|
events: { ...state.events,
|
|
79
|
-
connected:
|
|
90
|
+
connected: undefined
|
|
80
91
|
}
|
|
81
92
|
}));
|
|
82
93
|
}
|
|
@@ -129,6 +140,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
129
140
|
// This will include the entire THREE namespace by default, users can extend
|
|
130
141
|
// their own elements by using the createRoot API instead
|
|
131
142
|
React.useMemo(() => extend(THREE), []);
|
|
143
|
+
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
132
144
|
const [{
|
|
133
145
|
width,
|
|
134
146
|
height
|
|
@@ -138,14 +150,19 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
138
150
|
});
|
|
139
151
|
const [canvas, setCanvas] = React.useState(null);
|
|
140
152
|
const [bind, setBind] = React.useState();
|
|
141
|
-
const canvasProps = pick(props,
|
|
142
|
-
|
|
153
|
+
const canvasProps = pick({ ...props,
|
|
154
|
+
onPointerMissed
|
|
155
|
+
}, CANVAS_PROPS);
|
|
156
|
+
const viewProps = omit({ ...props,
|
|
157
|
+
onPointerMissed
|
|
158
|
+
}, CANVAS_PROPS);
|
|
143
159
|
const [block, setBlock] = React.useState(false);
|
|
144
160
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
145
161
|
|
|
146
162
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
147
163
|
|
|
148
164
|
if (error) throw error;
|
|
165
|
+
const viewRef = React.useRef(null);
|
|
149
166
|
const root = React.useRef(null);
|
|
150
167
|
const onLayout = React.useCallback(e => {
|
|
151
168
|
const {
|
|
@@ -175,7 +192,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
175
192
|
|
|
176
193
|
const onCreated = state => {
|
|
177
194
|
// Bind events after creation
|
|
178
|
-
const handlers = state.events.connect == null ? void 0 : state.events.connect(
|
|
195
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
179
196
|
setBind(handlers); // Bind render to RN bridge
|
|
180
197
|
|
|
181
198
|
const context = state.gl.getContext();
|
|
@@ -213,7 +230,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
213
230
|
return () => unmountComponentAtNode(canvas);
|
|
214
231
|
}, [canvas]);
|
|
215
232
|
return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
|
|
216
|
-
ref: forwardedRef,
|
|
233
|
+
ref: mergeRefs([viewRef, forwardedRef]),
|
|
217
234
|
onLayout: onLayout,
|
|
218
235
|
style: {
|
|
219
236
|
flex: 1,
|