@react-three/fiber 8.0.7 → 8.0.10
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/CHANGELOG.md +19 -1
- package/dist/declarations/src/core/hooks.d.ts +0 -4
- package/dist/declarations/src/core/index.d.ts +24 -6
- package/dist/declarations/src/core/store.d.ts +1 -20
- package/dist/declarations/src/core/utils.d.ts +29 -1
- package/dist/declarations/src/index.d.ts +3 -3
- package/dist/declarations/src/native/Canvas.d.ts +1 -6
- package/dist/declarations/src/native/events.d.ts +1 -2
- package/dist/declarations/src/native.d.ts +3 -3
- package/dist/declarations/src/three-types.d.ts +1 -0
- package/dist/declarations/src/web/Canvas.d.ts +1 -5
- package/dist/{index-75d39ab1.cjs.dev.js → index-018d2d45.cjs.dev.js} +176 -52
- package/dist/{index-e42f8ac9.esm.js → index-91152509.esm.js} +173 -52
- package/dist/{index-4fb4daff.cjs.prod.js → index-c8c0474b.cjs.prod.js} +176 -52
- package/dist/react-three-fiber.cjs.dev.js +30 -54
- package/dist/react-three-fiber.cjs.prod.js +30 -54
- package/dist/react-three-fiber.esm.js +29 -52
- package/native/dist/react-three-fiber-native.cjs.dev.js +30 -53
- package/native/dist/react-three-fiber-native.cjs.prod.js +30 -53
- package/native/dist/react-three-fiber-native.esm.js +29 -51
- package/package.json +1 -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
|
|
4
|
-
export { t as ReactThreeFiber,
|
|
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-91152509.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-91152509.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';
|
|
@@ -32,6 +32,8 @@ const DOM_EVENTS = {
|
|
|
32
32
|
[EVENTS.HOVEROUT]: 'onPointerOut',
|
|
33
33
|
[EVENTS.PRESSMOVE]: 'onPointerMove'
|
|
34
34
|
};
|
|
35
|
+
/** Default R3F event manager for react-native */
|
|
36
|
+
|
|
35
37
|
function createTouchEvents(store) {
|
|
36
38
|
const {
|
|
37
39
|
handlePointer
|
|
@@ -64,79 +66,54 @@ function createTouchEvents(store) {
|
|
|
64
66
|
}), {}),
|
|
65
67
|
connect: () => {
|
|
66
68
|
const {
|
|
67
|
-
|
|
69
|
+
set,
|
|
68
70
|
events
|
|
69
71
|
} = store.getState();
|
|
70
72
|
events.disconnect == null ? void 0 : events.disconnect();
|
|
71
73
|
const connected = new Pressability(events == null ? void 0 : events.handlers);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
set(state => ({
|
|
75
|
+
events: { ...state.events,
|
|
76
|
+
connected
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
75
79
|
const handlers = connected.getEventHandlers();
|
|
76
80
|
return handlers;
|
|
77
81
|
},
|
|
78
82
|
disconnect: () => {
|
|
79
83
|
const {
|
|
80
|
-
|
|
84
|
+
set,
|
|
81
85
|
events
|
|
82
86
|
} = store.getState();
|
|
83
87
|
|
|
84
88
|
if (events.connected) {
|
|
85
89
|
events.connected.reset();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
set(state => ({
|
|
91
|
+
events: { ...state.events,
|
|
92
|
+
connected: undefined
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
React.useLayoutEffect(() => {
|
|
100
|
-
set(new Promise(() => null));
|
|
101
|
-
return () => set(false);
|
|
102
|
-
}, [set]);
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
class ErrorBoundary extends React.Component {
|
|
107
|
-
constructor(...args) {
|
|
108
|
-
super(...args);
|
|
109
|
-
this.state = {
|
|
110
|
-
error: false
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
componentDidCatch(error) {
|
|
115
|
-
this.props.set(error);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
render() {
|
|
119
|
-
return this.state.error ? null : this.props.children;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
ErrorBoundary.getDerivedStateFromError = () => ({
|
|
125
|
-
error: true
|
|
126
|
-
});
|
|
101
|
+
/**
|
|
102
|
+
* A native canvas which accepts threejs elements as children.
|
|
103
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
104
|
+
*/
|
|
127
105
|
|
|
128
106
|
const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
129
107
|
children,
|
|
130
|
-
fallback,
|
|
131
108
|
style,
|
|
132
109
|
events,
|
|
110
|
+
onPointerMissed,
|
|
133
111
|
...props
|
|
134
112
|
}, forwardedRef) => {
|
|
135
113
|
// Create a known catalogue of Threejs-native elements
|
|
136
114
|
// This will include the entire THREE namespace by default, users can extend
|
|
137
115
|
// their own elements by using the createRoot API instead
|
|
138
116
|
React.useMemo(() => extend(THREE), []);
|
|
139
|
-
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
140
117
|
const [{
|
|
141
118
|
width,
|
|
142
119
|
height
|
|
@@ -146,12 +123,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
146
123
|
});
|
|
147
124
|
const [canvas, setCanvas] = React.useState(null);
|
|
148
125
|
const [bind, setBind] = React.useState();
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const viewProps = omit({ ...props,
|
|
153
|
-
onPointerMissed
|
|
154
|
-
}, CANVAS_PROPS);
|
|
126
|
+
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
127
|
+
const canvasProps = pick(props, CANVAS_PROPS);
|
|
128
|
+
const viewProps = omit(props, CANVAS_PROPS);
|
|
155
129
|
const [block, setBlock] = React.useState(false);
|
|
156
130
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
157
131
|
|
|
@@ -203,6 +177,8 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
203
177
|
};
|
|
204
178
|
|
|
205
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),
|
|
206
182
|
// expo-gl can only render at native dpr/resolution
|
|
207
183
|
// https://github.com/expo/expo-three/issues/39
|
|
208
184
|
dpr: PixelRatio.get(),
|
|
@@ -223,7 +199,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
223
199
|
}
|
|
224
200
|
|
|
225
201
|
React.useEffect(() => {
|
|
226
|
-
|
|
202
|
+
if (canvas) {
|
|
203
|
+
return () => unmountComponentAtNode(canvas);
|
|
204
|
+
}
|
|
227
205
|
}, [canvas]);
|
|
228
206
|
return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
|
|
229
207
|
ref: mergeRefs([viewRef, forwardedRef]),
|