@react-three/fiber 8.0.0-beta.6 → 8.0.0-beta.7
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/index.d.ts +1 -1
- package/dist/{index-45f5b2a2.cjs.prod.js → index-2d224292.cjs.prod.js} +16 -14
- package/dist/{index-74b1fd6b.esm.js → index-6a8cc5a4.esm.js} +16 -14
- package/dist/{index-4782ba04.cjs.dev.js → index-8ce56249.cjs.dev.js} +16 -14
- package/dist/react-three-fiber.cjs.dev.js +7 -2
- package/dist/react-three-fiber.cjs.prod.js +7 -2
- package/dist/react-three-fiber.esm.js +8 -3
- package/native/dist/react-three-fiber-native.cjs.dev.js +6 -3
- package/native/dist/react-three-fiber-native.cjs.prod.js +6 -3
- package/native/dist/react-three-fiber-native.esm.js +6 -4
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ export declare type ReconcilerRoot<TCanvas extends Element> = {
|
|
|
26
26
|
unmount: () => void;
|
|
27
27
|
};
|
|
28
28
|
declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
29
|
-
declare function render<TCanvas extends Element>(
|
|
29
|
+
declare function render<TCanvas extends Element>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
30
30
|
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
31
31
|
export declare type InjectState = Partial<Omit<RootState, 'set' | 'get' | 'setSize' | 'setFrameloop' | 'setDpr' | 'events' | 'invalidate' | 'advance' | 'performance' | 'internal'> & {
|
|
32
32
|
events: {
|
|
@@ -1712,14 +1712,14 @@ function createRoot(canvas) {
|
|
|
1712
1712
|
return this;
|
|
1713
1713
|
},
|
|
1714
1714
|
|
|
1715
|
-
render(
|
|
1715
|
+
render(children) {
|
|
1716
1716
|
// The root has to be configured before it can be rendered
|
|
1717
1717
|
if (!configured) this.configure();
|
|
1718
1718
|
reconciler.updateContainer( /*#__PURE__*/React__namespace.createElement(Provider, {
|
|
1719
1719
|
store: store,
|
|
1720
|
-
|
|
1720
|
+
children: children,
|
|
1721
1721
|
onCreated: onCreated,
|
|
1722
|
-
|
|
1722
|
+
rootElement: canvas
|
|
1723
1723
|
}), fiber, null, () => undefined);
|
|
1724
1724
|
return store;
|
|
1725
1725
|
},
|
|
@@ -1731,36 +1731,36 @@ function createRoot(canvas) {
|
|
|
1731
1731
|
};
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
|
-
function render(
|
|
1734
|
+
function render(children, canvas, config) {
|
|
1735
1735
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1736
1736
|
const root = createRoot(canvas);
|
|
1737
1737
|
root.configure(config);
|
|
1738
|
-
return root.render(
|
|
1738
|
+
return root.render(children);
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
1741
1741
|
function Provider({
|
|
1742
1742
|
store,
|
|
1743
|
-
|
|
1743
|
+
children,
|
|
1744
1744
|
onCreated,
|
|
1745
|
-
|
|
1745
|
+
rootElement
|
|
1746
1746
|
}) {
|
|
1747
|
-
React__namespace.
|
|
1747
|
+
React__namespace.useLayoutEffect(() => {
|
|
1748
1748
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1749
1749
|
|
|
1750
1750
|
state.set(state => ({
|
|
1751
1751
|
internal: { ...state.internal,
|
|
1752
1752
|
active: true
|
|
1753
1753
|
}
|
|
1754
|
-
})); //
|
|
1755
|
-
// a shared target, and not on the canvas itself
|
|
1754
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1756
1755
|
|
|
1757
|
-
|
|
1756
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1757
|
+
// a shared target, and not on the canvas itself
|
|
1758
1758
|
|
|
1759
|
-
if (
|
|
1759
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1760
1760
|
}, []);
|
|
1761
1761
|
return /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
1762
1762
|
value: store
|
|
1763
|
-
},
|
|
1763
|
+
}, children);
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
1766
1766
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1823,7 +1823,9 @@ function Portal({
|
|
|
1823
1823
|
if (injectState) {
|
|
1824
1824
|
// Only the fields of "state" that do not differ from injectState
|
|
1825
1825
|
Object.keys(state).forEach(key => {
|
|
1826
|
-
if (
|
|
1826
|
+
if ( // Some props should be off-limits
|
|
1827
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1828
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1827
1829
|
});
|
|
1828
1830
|
}
|
|
1829
1831
|
|
|
@@ -1683,14 +1683,14 @@ function createRoot(canvas) {
|
|
|
1683
1683
|
return this;
|
|
1684
1684
|
},
|
|
1685
1685
|
|
|
1686
|
-
render(
|
|
1686
|
+
render(children) {
|
|
1687
1687
|
// The root has to be configured before it can be rendered
|
|
1688
1688
|
if (!configured) this.configure();
|
|
1689
1689
|
reconciler.updateContainer( /*#__PURE__*/React.createElement(Provider, {
|
|
1690
1690
|
store: store,
|
|
1691
|
-
|
|
1691
|
+
children: children,
|
|
1692
1692
|
onCreated: onCreated,
|
|
1693
|
-
|
|
1693
|
+
rootElement: canvas
|
|
1694
1694
|
}), fiber, null, () => undefined);
|
|
1695
1695
|
return store;
|
|
1696
1696
|
},
|
|
@@ -1702,36 +1702,36 @@ function createRoot(canvas) {
|
|
|
1702
1702
|
};
|
|
1703
1703
|
}
|
|
1704
1704
|
|
|
1705
|
-
function render(
|
|
1705
|
+
function render(children, canvas, config) {
|
|
1706
1706
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1707
1707
|
const root = createRoot(canvas);
|
|
1708
1708
|
root.configure(config);
|
|
1709
|
-
return root.render(
|
|
1709
|
+
return root.render(children);
|
|
1710
1710
|
}
|
|
1711
1711
|
|
|
1712
1712
|
function Provider({
|
|
1713
1713
|
store,
|
|
1714
|
-
|
|
1714
|
+
children,
|
|
1715
1715
|
onCreated,
|
|
1716
|
-
|
|
1716
|
+
rootElement
|
|
1717
1717
|
}) {
|
|
1718
|
-
React.
|
|
1718
|
+
React.useLayoutEffect(() => {
|
|
1719
1719
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1720
1720
|
|
|
1721
1721
|
state.set(state => ({
|
|
1722
1722
|
internal: { ...state.internal,
|
|
1723
1723
|
active: true
|
|
1724
1724
|
}
|
|
1725
|
-
})); //
|
|
1726
|
-
// a shared target, and not on the canvas itself
|
|
1725
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1727
1726
|
|
|
1728
|
-
|
|
1727
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1728
|
+
// a shared target, and not on the canvas itself
|
|
1729
1729
|
|
|
1730
|
-
if (
|
|
1730
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1731
1731
|
}, []);
|
|
1732
1732
|
return /*#__PURE__*/React.createElement(context.Provider, {
|
|
1733
1733
|
value: store
|
|
1734
|
-
},
|
|
1734
|
+
}, children);
|
|
1735
1735
|
}
|
|
1736
1736
|
|
|
1737
1737
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1794,7 +1794,9 @@ function Portal({
|
|
|
1794
1794
|
if (injectState) {
|
|
1795
1795
|
// Only the fields of "state" that do not differ from injectState
|
|
1796
1796
|
Object.keys(state).forEach(key => {
|
|
1797
|
-
if (
|
|
1797
|
+
if ( // Some props should be off-limits
|
|
1798
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1799
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1798
1800
|
});
|
|
1799
1801
|
}
|
|
1800
1802
|
|
|
@@ -1712,14 +1712,14 @@ function createRoot(canvas) {
|
|
|
1712
1712
|
return this;
|
|
1713
1713
|
},
|
|
1714
1714
|
|
|
1715
|
-
render(
|
|
1715
|
+
render(children) {
|
|
1716
1716
|
// The root has to be configured before it can be rendered
|
|
1717
1717
|
if (!configured) this.configure();
|
|
1718
1718
|
reconciler.updateContainer( /*#__PURE__*/React__namespace.createElement(Provider, {
|
|
1719
1719
|
store: store,
|
|
1720
|
-
|
|
1720
|
+
children: children,
|
|
1721
1721
|
onCreated: onCreated,
|
|
1722
|
-
|
|
1722
|
+
rootElement: canvas
|
|
1723
1723
|
}), fiber, null, () => undefined);
|
|
1724
1724
|
return store;
|
|
1725
1725
|
},
|
|
@@ -1731,36 +1731,36 @@ function createRoot(canvas) {
|
|
|
1731
1731
|
};
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
|
-
function render(
|
|
1734
|
+
function render(children, canvas, config) {
|
|
1735
1735
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1736
1736
|
const root = createRoot(canvas);
|
|
1737
1737
|
root.configure(config);
|
|
1738
|
-
return root.render(
|
|
1738
|
+
return root.render(children);
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
1741
1741
|
function Provider({
|
|
1742
1742
|
store,
|
|
1743
|
-
|
|
1743
|
+
children,
|
|
1744
1744
|
onCreated,
|
|
1745
|
-
|
|
1745
|
+
rootElement
|
|
1746
1746
|
}) {
|
|
1747
|
-
React__namespace.
|
|
1747
|
+
React__namespace.useLayoutEffect(() => {
|
|
1748
1748
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1749
1749
|
|
|
1750
1750
|
state.set(state => ({
|
|
1751
1751
|
internal: { ...state.internal,
|
|
1752
1752
|
active: true
|
|
1753
1753
|
}
|
|
1754
|
-
})); //
|
|
1755
|
-
// a shared target, and not on the canvas itself
|
|
1754
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1756
1755
|
|
|
1757
|
-
|
|
1756
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1757
|
+
// a shared target, and not on the canvas itself
|
|
1758
1758
|
|
|
1759
|
-
if (
|
|
1759
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1760
1760
|
}, []);
|
|
1761
1761
|
return /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
1762
1762
|
value: store
|
|
1763
|
-
},
|
|
1763
|
+
}, children);
|
|
1764
1764
|
}
|
|
1765
1765
|
|
|
1766
1766
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1823,7 +1823,9 @@ function Portal({
|
|
|
1823
1823
|
if (injectState) {
|
|
1824
1824
|
// Only the fields of "state" that do not differ from injectState
|
|
1825
1825
|
Object.keys(state).forEach(key => {
|
|
1826
|
-
if (
|
|
1826
|
+
if ( // Some props should be off-limits
|
|
1827
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1828
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1827
1829
|
});
|
|
1828
1830
|
}
|
|
1829
1831
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-8ce56249.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -175,6 +175,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
175
175
|
},
|
|
176
176
|
...resize
|
|
177
177
|
});
|
|
178
|
+
const meshRef = React__namespace.useRef(null);
|
|
178
179
|
const canvasRef = React__namespace.useRef(null);
|
|
179
180
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
180
181
|
const canvasProps = index.pick({ ...props,
|
|
@@ -194,6 +195,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
194
195
|
if (width > 0 && height > 0 && canvas) {
|
|
195
196
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
196
197
|
root.current.configure({ ...canvasProps,
|
|
198
|
+
onCreated: state => {
|
|
199
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
200
|
+
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
201
|
+
},
|
|
197
202
|
size: {
|
|
198
203
|
width,
|
|
199
204
|
height
|
|
@@ -216,7 +221,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
216
221
|
return () => index.unmountComponentAtNode(canvas);
|
|
217
222
|
}, [canvas]);
|
|
218
223
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
219
|
-
ref: containerRef,
|
|
224
|
+
ref: mergeRefs__default['default']([meshRef, containerRef]),
|
|
220
225
|
style: {
|
|
221
226
|
position: 'relative',
|
|
222
227
|
width: '100%',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-2d224292.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -175,6 +175,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
175
175
|
},
|
|
176
176
|
...resize
|
|
177
177
|
});
|
|
178
|
+
const meshRef = React__namespace.useRef(null);
|
|
178
179
|
const canvasRef = React__namespace.useRef(null);
|
|
179
180
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
180
181
|
const canvasProps = index.pick({ ...props,
|
|
@@ -194,6 +195,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
194
195
|
if (width > 0 && height > 0 && canvas) {
|
|
195
196
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
196
197
|
root.current.configure({ ...canvasProps,
|
|
198
|
+
onCreated: state => {
|
|
199
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
200
|
+
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
201
|
+
},
|
|
197
202
|
size: {
|
|
198
203
|
width,
|
|
199
204
|
height
|
|
@@ -216,7 +221,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
216
221
|
return () => index.unmountComponentAtNode(canvas);
|
|
217
222
|
}, [canvas]);
|
|
218
223
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
219
|
-
ref: containerRef,
|
|
224
|
+
ref: mergeRefs__default['default']([meshRef, containerRef]),
|
|
220
225
|
style: {
|
|
221
226
|
position: 'relative',
|
|
222
227
|
width: '100%',
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-6a8cc5a4.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-6a8cc5a4.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';
|
|
@@ -145,6 +145,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
145
145
|
},
|
|
146
146
|
...resize
|
|
147
147
|
});
|
|
148
|
+
const meshRef = React.useRef(null);
|
|
148
149
|
const canvasRef = React.useRef(null);
|
|
149
150
|
const [canvas, setCanvas] = React.useState(null);
|
|
150
151
|
const canvasProps = pick({ ...props,
|
|
@@ -164,6 +165,10 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
164
165
|
if (width > 0 && height > 0 && canvas) {
|
|
165
166
|
if (!root.current) root.current = createRoot(canvas);
|
|
166
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
|
+
},
|
|
167
172
|
size: {
|
|
168
173
|
width,
|
|
169
174
|
height
|
|
@@ -186,7 +191,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
186
191
|
return () => unmountComponentAtNode(canvas);
|
|
187
192
|
}, [canvas]);
|
|
188
193
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
189
|
-
ref: containerRef,
|
|
194
|
+
ref: mergeRefs([meshRef, containerRef]),
|
|
190
195
|
style: {
|
|
191
196
|
position: 'relative',
|
|
192
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-8ce56249.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 = {
|
|
@@ -190,6 +192,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
190
192
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
191
193
|
|
|
192
194
|
if (error) throw error;
|
|
195
|
+
const viewRef = React__namespace.useRef(null);
|
|
193
196
|
const root = React__namespace.useRef(null);
|
|
194
197
|
const onLayout = React__namespace.useCallback(e => {
|
|
195
198
|
const {
|
|
@@ -219,7 +222,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
219
222
|
|
|
220
223
|
const onCreated = state => {
|
|
221
224
|
// Bind events after creation
|
|
222
|
-
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);
|
|
223
226
|
setBind(handlers); // Bind render to RN bridge
|
|
224
227
|
|
|
225
228
|
const context = state.gl.getContext();
|
|
@@ -257,7 +260,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
257
260
|
return () => index.unmountComponentAtNode(canvas);
|
|
258
261
|
}, [canvas]);
|
|
259
262
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
260
|
-
ref: forwardedRef,
|
|
263
|
+
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
261
264
|
onLayout: onLayout,
|
|
262
265
|
style: {
|
|
263
266
|
flex: 1,
|
|
@@ -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-2d224292.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 = {
|
|
@@ -190,6 +192,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
190
192
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
191
193
|
|
|
192
194
|
if (error) throw error;
|
|
195
|
+
const viewRef = React__namespace.useRef(null);
|
|
193
196
|
const root = React__namespace.useRef(null);
|
|
194
197
|
const onLayout = React__namespace.useCallback(e => {
|
|
195
198
|
const {
|
|
@@ -219,7 +222,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
219
222
|
|
|
220
223
|
const onCreated = state => {
|
|
221
224
|
// Bind events after creation
|
|
222
|
-
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);
|
|
223
226
|
setBind(handlers); // Bind render to RN bridge
|
|
224
227
|
|
|
225
228
|
const context = state.gl.getContext();
|
|
@@ -257,7 +260,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
257
260
|
return () => index.unmountComponentAtNode(canvas);
|
|
258
261
|
}, [canvas]);
|
|
259
262
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
260
|
-
ref: forwardedRef,
|
|
263
|
+
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
261
264
|
onLayout: onLayout,
|
|
262
265
|
style: {
|
|
263
266
|
flex: 1,
|
|
@@ -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, u as useMemoizedFn, p as pick, o as omit, a as createRoot, b as unmountComponentAtNode } from '../../dist/index-
|
|
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-
|
|
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-6a8cc5a4.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-6a8cc5a4.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';
|
|
@@ -161,6 +162,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
161
162
|
if (block) throw block; // Throw exception outwards if anything within canvas throws
|
|
162
163
|
|
|
163
164
|
if (error) throw error;
|
|
165
|
+
const viewRef = React.useRef(null);
|
|
164
166
|
const root = React.useRef(null);
|
|
165
167
|
const onLayout = React.useCallback(e => {
|
|
166
168
|
const {
|
|
@@ -190,7 +192,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
190
192
|
|
|
191
193
|
const onCreated = state => {
|
|
192
194
|
// Bind events after creation
|
|
193
|
-
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);
|
|
194
196
|
setBind(handlers); // Bind render to RN bridge
|
|
195
197
|
|
|
196
198
|
const context = state.gl.getContext();
|
|
@@ -228,7 +230,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
228
230
|
return () => unmountComponentAtNode(canvas);
|
|
229
231
|
}, [canvas]);
|
|
230
232
|
return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
|
|
231
|
-
ref: forwardedRef,
|
|
233
|
+
ref: mergeRefs([viewRef, forwardedRef]),
|
|
232
234
|
onLayout: onLayout,
|
|
233
235
|
style: {
|
|
234
236
|
flex: 1,
|