@react-three/fiber 8.0.0-beta.6 → 8.0.0-beta.9
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/declarations/src/core/store.d.ts +6 -4
- package/dist/{index-4782ba04.cjs.dev.js → index-2056f0b6.cjs.dev.js} +24 -15
- package/dist/{index-74b1fd6b.esm.js → index-3238fd12.esm.js} +24 -15
- package/dist/{index-45f5b2a2.cjs.prod.js → index-f5108bb9.cjs.prod.js} +24 -15
- 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: {
|
|
@@ -50,20 +50,23 @@ export declare type InternalState = {
|
|
|
50
50
|
subscribe: (callback: React.MutableRefObject<RenderCallback>, priority?: number) => () => void;
|
|
51
51
|
};
|
|
52
52
|
export declare type RootState = {
|
|
53
|
+
set: SetState<RootState>;
|
|
54
|
+
get: GetState<RootState>;
|
|
53
55
|
gl: THREE.WebGLRenderer;
|
|
54
56
|
camera: Camera & {
|
|
55
57
|
manual?: boolean;
|
|
56
58
|
};
|
|
59
|
+
scene: THREE.Scene;
|
|
57
60
|
raycaster: THREE.Raycaster;
|
|
61
|
+
clock: THREE.Clock;
|
|
58
62
|
events: EventManager<any>;
|
|
59
63
|
xr: {
|
|
60
64
|
connect: () => void;
|
|
61
65
|
disconnect: () => void;
|
|
62
66
|
};
|
|
63
|
-
scene: THREE.Scene;
|
|
64
67
|
controls: THREE.EventDispatcher | null;
|
|
65
68
|
pointer: THREE.Vector2;
|
|
66
|
-
|
|
69
|
+
mouse: THREE.Vector2;
|
|
67
70
|
linear: boolean;
|
|
68
71
|
flat: boolean;
|
|
69
72
|
frameloop: 'always' | 'demand' | 'never';
|
|
@@ -72,10 +75,9 @@ export declare type RootState = {
|
|
|
72
75
|
viewport: Viewport & {
|
|
73
76
|
getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
|
|
74
77
|
};
|
|
75
|
-
set: SetState<RootState>;
|
|
76
|
-
get: GetState<RootState>;
|
|
77
78
|
invalidate: () => void;
|
|
78
79
|
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
80
|
+
setEvents: (events: Partial<EventManager<any>>) => void;
|
|
79
81
|
setSize: (width: number, height: number) => void;
|
|
80
82
|
setDpr: (dpr: Dpr) => void;
|
|
81
83
|
setFrameloop: (frameloop?: 'always' | 'demand' | 'never') => void;
|
|
@@ -1176,6 +1176,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
}));
|
|
1178
1178
|
|
|
1179
|
+
const pointer = new THREE__namespace.Vector2();
|
|
1179
1180
|
return {
|
|
1180
1181
|
set,
|
|
1181
1182
|
get,
|
|
@@ -1196,7 +1197,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1196
1197
|
scene: prepare(new THREE__namespace.Scene()),
|
|
1197
1198
|
controls: null,
|
|
1198
1199
|
clock: new THREE__namespace.Clock(),
|
|
1199
|
-
pointer
|
|
1200
|
+
pointer,
|
|
1201
|
+
mouse: pointer,
|
|
1200
1202
|
frameloop: 'always',
|
|
1201
1203
|
onPointerMissed: undefined,
|
|
1202
1204
|
performance: {
|
|
@@ -1228,6 +1230,11 @@ const createStore = (invalidate, advance) => {
|
|
|
1228
1230
|
factor: 0,
|
|
1229
1231
|
getCurrentViewport
|
|
1230
1232
|
},
|
|
1233
|
+
setEvents: events => set(state => ({ ...state,
|
|
1234
|
+
events: { ...state.events,
|
|
1235
|
+
events
|
|
1236
|
+
}
|
|
1237
|
+
})),
|
|
1231
1238
|
setSize: (width, height) => {
|
|
1232
1239
|
const camera = get().camera;
|
|
1233
1240
|
const size = {
|
|
@@ -1712,14 +1719,14 @@ function createRoot(canvas) {
|
|
|
1712
1719
|
return this;
|
|
1713
1720
|
},
|
|
1714
1721
|
|
|
1715
|
-
render(
|
|
1722
|
+
render(children) {
|
|
1716
1723
|
// The root has to be configured before it can be rendered
|
|
1717
1724
|
if (!configured) this.configure();
|
|
1718
1725
|
reconciler.updateContainer( /*#__PURE__*/React__namespace.createElement(Provider, {
|
|
1719
1726
|
store: store,
|
|
1720
|
-
|
|
1727
|
+
children: children,
|
|
1721
1728
|
onCreated: onCreated,
|
|
1722
|
-
|
|
1729
|
+
rootElement: canvas
|
|
1723
1730
|
}), fiber, null, () => undefined);
|
|
1724
1731
|
return store;
|
|
1725
1732
|
},
|
|
@@ -1731,36 +1738,36 @@ function createRoot(canvas) {
|
|
|
1731
1738
|
};
|
|
1732
1739
|
}
|
|
1733
1740
|
|
|
1734
|
-
function render(
|
|
1741
|
+
function render(children, canvas, config) {
|
|
1735
1742
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1736
1743
|
const root = createRoot(canvas);
|
|
1737
1744
|
root.configure(config);
|
|
1738
|
-
return root.render(
|
|
1745
|
+
return root.render(children);
|
|
1739
1746
|
}
|
|
1740
1747
|
|
|
1741
1748
|
function Provider({
|
|
1742
1749
|
store,
|
|
1743
|
-
|
|
1750
|
+
children,
|
|
1744
1751
|
onCreated,
|
|
1745
|
-
|
|
1752
|
+
rootElement
|
|
1746
1753
|
}) {
|
|
1747
|
-
React__namespace.
|
|
1754
|
+
React__namespace.useLayoutEffect(() => {
|
|
1748
1755
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1749
1756
|
|
|
1750
1757
|
state.set(state => ({
|
|
1751
1758
|
internal: { ...state.internal,
|
|
1752
1759
|
active: true
|
|
1753
1760
|
}
|
|
1754
|
-
})); //
|
|
1755
|
-
// a shared target, and not on the canvas itself
|
|
1761
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1756
1762
|
|
|
1757
|
-
|
|
1763
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1764
|
+
// a shared target, and not on the canvas itself
|
|
1758
1765
|
|
|
1759
|
-
if (
|
|
1766
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1760
1767
|
}, []);
|
|
1761
1768
|
return /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
1762
1769
|
value: store
|
|
1763
|
-
},
|
|
1770
|
+
}, children);
|
|
1764
1771
|
}
|
|
1765
1772
|
|
|
1766
1773
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1823,7 +1830,9 @@ function Portal({
|
|
|
1823
1830
|
if (injectState) {
|
|
1824
1831
|
// Only the fields of "state" that do not differ from injectState
|
|
1825
1832
|
Object.keys(state).forEach(key => {
|
|
1826
|
-
if (
|
|
1833
|
+
if ( // Some props should be off-limits
|
|
1834
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1835
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1827
1836
|
});
|
|
1828
1837
|
}
|
|
1829
1838
|
|
|
@@ -1147,6 +1147,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
}));
|
|
1149
1149
|
|
|
1150
|
+
const pointer = new THREE.Vector2();
|
|
1150
1151
|
return {
|
|
1151
1152
|
set,
|
|
1152
1153
|
get,
|
|
@@ -1167,7 +1168,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1167
1168
|
scene: prepare(new THREE.Scene()),
|
|
1168
1169
|
controls: null,
|
|
1169
1170
|
clock: new THREE.Clock(),
|
|
1170
|
-
pointer
|
|
1171
|
+
pointer,
|
|
1172
|
+
mouse: pointer,
|
|
1171
1173
|
frameloop: 'always',
|
|
1172
1174
|
onPointerMissed: undefined,
|
|
1173
1175
|
performance: {
|
|
@@ -1199,6 +1201,11 @@ const createStore = (invalidate, advance) => {
|
|
|
1199
1201
|
factor: 0,
|
|
1200
1202
|
getCurrentViewport
|
|
1201
1203
|
},
|
|
1204
|
+
setEvents: events => set(state => ({ ...state,
|
|
1205
|
+
events: { ...state.events,
|
|
1206
|
+
events
|
|
1207
|
+
}
|
|
1208
|
+
})),
|
|
1202
1209
|
setSize: (width, height) => {
|
|
1203
1210
|
const camera = get().camera;
|
|
1204
1211
|
const size = {
|
|
@@ -1683,14 +1690,14 @@ function createRoot(canvas) {
|
|
|
1683
1690
|
return this;
|
|
1684
1691
|
},
|
|
1685
1692
|
|
|
1686
|
-
render(
|
|
1693
|
+
render(children) {
|
|
1687
1694
|
// The root has to be configured before it can be rendered
|
|
1688
1695
|
if (!configured) this.configure();
|
|
1689
1696
|
reconciler.updateContainer( /*#__PURE__*/React.createElement(Provider, {
|
|
1690
1697
|
store: store,
|
|
1691
|
-
|
|
1698
|
+
children: children,
|
|
1692
1699
|
onCreated: onCreated,
|
|
1693
|
-
|
|
1700
|
+
rootElement: canvas
|
|
1694
1701
|
}), fiber, null, () => undefined);
|
|
1695
1702
|
return store;
|
|
1696
1703
|
},
|
|
@@ -1702,36 +1709,36 @@ function createRoot(canvas) {
|
|
|
1702
1709
|
};
|
|
1703
1710
|
}
|
|
1704
1711
|
|
|
1705
|
-
function render(
|
|
1712
|
+
function render(children, canvas, config) {
|
|
1706
1713
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1707
1714
|
const root = createRoot(canvas);
|
|
1708
1715
|
root.configure(config);
|
|
1709
|
-
return root.render(
|
|
1716
|
+
return root.render(children);
|
|
1710
1717
|
}
|
|
1711
1718
|
|
|
1712
1719
|
function Provider({
|
|
1713
1720
|
store,
|
|
1714
|
-
|
|
1721
|
+
children,
|
|
1715
1722
|
onCreated,
|
|
1716
|
-
|
|
1723
|
+
rootElement
|
|
1717
1724
|
}) {
|
|
1718
|
-
React.
|
|
1725
|
+
React.useLayoutEffect(() => {
|
|
1719
1726
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1720
1727
|
|
|
1721
1728
|
state.set(state => ({
|
|
1722
1729
|
internal: { ...state.internal,
|
|
1723
1730
|
active: true
|
|
1724
1731
|
}
|
|
1725
|
-
})); //
|
|
1726
|
-
// a shared target, and not on the canvas itself
|
|
1732
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1727
1733
|
|
|
1728
|
-
|
|
1734
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1735
|
+
// a shared target, and not on the canvas itself
|
|
1729
1736
|
|
|
1730
|
-
if (
|
|
1737
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1731
1738
|
}, []);
|
|
1732
1739
|
return /*#__PURE__*/React.createElement(context.Provider, {
|
|
1733
1740
|
value: store
|
|
1734
|
-
},
|
|
1741
|
+
}, children);
|
|
1735
1742
|
}
|
|
1736
1743
|
|
|
1737
1744
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1794,7 +1801,9 @@ function Portal({
|
|
|
1794
1801
|
if (injectState) {
|
|
1795
1802
|
// Only the fields of "state" that do not differ from injectState
|
|
1796
1803
|
Object.keys(state).forEach(key => {
|
|
1797
|
-
if (
|
|
1804
|
+
if ( // Some props should be off-limits
|
|
1805
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1806
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1798
1807
|
});
|
|
1799
1808
|
}
|
|
1800
1809
|
|
|
@@ -1176,6 +1176,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
}));
|
|
1178
1178
|
|
|
1179
|
+
const pointer = new THREE__namespace.Vector2();
|
|
1179
1180
|
return {
|
|
1180
1181
|
set,
|
|
1181
1182
|
get,
|
|
@@ -1196,7 +1197,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1196
1197
|
scene: prepare(new THREE__namespace.Scene()),
|
|
1197
1198
|
controls: null,
|
|
1198
1199
|
clock: new THREE__namespace.Clock(),
|
|
1199
|
-
pointer
|
|
1200
|
+
pointer,
|
|
1201
|
+
mouse: pointer,
|
|
1200
1202
|
frameloop: 'always',
|
|
1201
1203
|
onPointerMissed: undefined,
|
|
1202
1204
|
performance: {
|
|
@@ -1228,6 +1230,11 @@ const createStore = (invalidate, advance) => {
|
|
|
1228
1230
|
factor: 0,
|
|
1229
1231
|
getCurrentViewport
|
|
1230
1232
|
},
|
|
1233
|
+
setEvents: events => set(state => ({ ...state,
|
|
1234
|
+
events: { ...state.events,
|
|
1235
|
+
events
|
|
1236
|
+
}
|
|
1237
|
+
})),
|
|
1231
1238
|
setSize: (width, height) => {
|
|
1232
1239
|
const camera = get().camera;
|
|
1233
1240
|
const size = {
|
|
@@ -1712,14 +1719,14 @@ function createRoot(canvas) {
|
|
|
1712
1719
|
return this;
|
|
1713
1720
|
},
|
|
1714
1721
|
|
|
1715
|
-
render(
|
|
1722
|
+
render(children) {
|
|
1716
1723
|
// The root has to be configured before it can be rendered
|
|
1717
1724
|
if (!configured) this.configure();
|
|
1718
1725
|
reconciler.updateContainer( /*#__PURE__*/React__namespace.createElement(Provider, {
|
|
1719
1726
|
store: store,
|
|
1720
|
-
|
|
1727
|
+
children: children,
|
|
1721
1728
|
onCreated: onCreated,
|
|
1722
|
-
|
|
1729
|
+
rootElement: canvas
|
|
1723
1730
|
}), fiber, null, () => undefined);
|
|
1724
1731
|
return store;
|
|
1725
1732
|
},
|
|
@@ -1731,36 +1738,36 @@ function createRoot(canvas) {
|
|
|
1731
1738
|
};
|
|
1732
1739
|
}
|
|
1733
1740
|
|
|
1734
|
-
function render(
|
|
1741
|
+
function render(children, canvas, config) {
|
|
1735
1742
|
console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
|
|
1736
1743
|
const root = createRoot(canvas);
|
|
1737
1744
|
root.configure(config);
|
|
1738
|
-
return root.render(
|
|
1745
|
+
return root.render(children);
|
|
1739
1746
|
}
|
|
1740
1747
|
|
|
1741
1748
|
function Provider({
|
|
1742
1749
|
store,
|
|
1743
|
-
|
|
1750
|
+
children,
|
|
1744
1751
|
onCreated,
|
|
1745
|
-
|
|
1752
|
+
rootElement
|
|
1746
1753
|
}) {
|
|
1747
|
-
React__namespace.
|
|
1754
|
+
React__namespace.useLayoutEffect(() => {
|
|
1748
1755
|
const state = store.getState(); // Flag the canvas active, rendering will now begin
|
|
1749
1756
|
|
|
1750
1757
|
state.set(state => ({
|
|
1751
1758
|
internal: { ...state.internal,
|
|
1752
1759
|
active: true
|
|
1753
1760
|
}
|
|
1754
|
-
})); //
|
|
1755
|
-
// a shared target, and not on the canvas itself
|
|
1761
|
+
})); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
|
|
1756
1762
|
|
|
1757
|
-
|
|
1763
|
+
if (onCreated) onCreated(state); // Connect events to the targets parent, this is done to ensure events are registered on
|
|
1764
|
+
// a shared target, and not on the canvas itself
|
|
1758
1765
|
|
|
1759
|
-
if (
|
|
1766
|
+
if (!store.getState().events.connected) state.events.connect == null ? void 0 : state.events.connect(rootElement); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1760
1767
|
}, []);
|
|
1761
1768
|
return /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
1762
1769
|
value: store
|
|
1763
|
-
},
|
|
1770
|
+
}, children);
|
|
1764
1771
|
}
|
|
1765
1772
|
|
|
1766
1773
|
function unmountComponentAtNode(canvas, callback) {
|
|
@@ -1823,7 +1830,9 @@ function Portal({
|
|
|
1823
1830
|
if (injectState) {
|
|
1824
1831
|
// Only the fields of "state" that do not differ from injectState
|
|
1825
1832
|
Object.keys(state).forEach(key => {
|
|
1826
|
-
if (
|
|
1833
|
+
if ( // Some props should be off-limits
|
|
1834
|
+
!['size', 'viewport', 'internal', 'performance'].includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1835
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1827
1836
|
});
|
|
1828
1837
|
}
|
|
1829
1838
|
|
|
@@ -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-2056f0b6.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-f5108bb9.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-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';
|
|
@@ -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-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 = {
|
|
@@ -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-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 = {
|
|
@@ -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-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';
|
|
@@ -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,
|