@react-three/fiber 9.7.0 → 9.8.0
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 +27 -0
- package/dist/declarations/react-reconciler/index.d.ts +30 -13
- package/dist/declarations/src/core/index.d.ts +1 -0
- package/dist/declarations/src/core/promise.d.ts +15 -0
- package/dist/declarations/src/core/reconciler.d.ts +4 -0
- package/dist/declarations/src/core/renderer.d.ts +4 -2
- package/dist/declarations/src/core/utils.d.ts +3 -0
- package/dist/declarations/src/native/Canvas.d.ts +1 -1
- package/dist/declarations/src/web/Canvas.d.ts +2 -2
- package/dist/{events-156d8d12.esm.js → events-803f4abc.esm.js} +7745 -6524
- package/dist/{events-4c71f21f.cjs.prod.js → events-a79ef12b.cjs.prod.js} +3330 -2690
- package/dist/{events-b1bdeb1a.cjs.dev.js → events-ce5e34e8.cjs.dev.js} +7745 -6523
- package/dist/react-three-fiber.cjs.dev.js +58 -40
- package/dist/react-three-fiber.cjs.prod.js +58 -40
- package/dist/react-three-fiber.esm.js +60 -42
- package/native/dist/react-three-fiber-native.cjs.dev.js +46 -40
- package/native/dist/react-three-fiber-native.cjs.prod.js +46 -40
- package/native/dist/react-three-fiber-native.esm.js +47 -41
- package/package.json +6 -6
- package/react-reconciler/index.d.ts +30 -13
- package/react-reconciler/index.js +79 -77
- package/readme.md +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-ce5e34e8.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -86,46 +86,55 @@ function CanvasImpl({
|
|
|
86
86
|
// Throw exception outwards if anything within canvas throws
|
|
87
87
|
if (error) throw error;
|
|
88
88
|
const root = React__namespace.useRef(null);
|
|
89
|
+
|
|
90
|
+
// Waits for an async renderer without hiding the canvas
|
|
91
|
+
const [gate, waitFor] = events.useGate();
|
|
92
|
+
const rootState = React__namespace.useRef(null);
|
|
93
|
+
const eventTarget = () => eventSource ? events.isRef(eventSource) ? eventSource.current : eventSource : divRef.current;
|
|
89
94
|
events.useIsomorphicLayoutEffect(() => {
|
|
90
95
|
const canvas = canvasRef.current;
|
|
91
96
|
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
92
97
|
if (!root.current) root.current = events.createRoot(canvas);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Call onCreated callback
|
|
126
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
98
|
+
root.current.configure({
|
|
99
|
+
gl,
|
|
100
|
+
scene,
|
|
101
|
+
events: events$1,
|
|
102
|
+
shadows,
|
|
103
|
+
linear,
|
|
104
|
+
flat,
|
|
105
|
+
legacy,
|
|
106
|
+
orthographic,
|
|
107
|
+
frameloop,
|
|
108
|
+
dpr,
|
|
109
|
+
performance,
|
|
110
|
+
raycaster,
|
|
111
|
+
camera,
|
|
112
|
+
size: containerRect,
|
|
113
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
114
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
115
|
+
onCreated: state => {
|
|
116
|
+
var _eventTarget;
|
|
117
|
+
rootState.current = state;
|
|
118
|
+
// A ref to an ancestor is not attached yet. The effect below settles it
|
|
119
|
+
state.events.connect == null ? void 0 : state.events.connect((_eventTarget = eventTarget()) != null ? _eventTarget : divRef.current);
|
|
120
|
+
// Set up compute function
|
|
121
|
+
if (eventPrefix) {
|
|
122
|
+
state.setEvents({
|
|
123
|
+
compute: (event, state) => {
|
|
124
|
+
const x = event[eventPrefix + 'X'];
|
|
125
|
+
const y = event[eventPrefix + 'Y'];
|
|
126
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
127
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
127
130
|
}
|
|
128
|
-
|
|
131
|
+
// Call onCreated callback
|
|
132
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
133
|
+
}
|
|
134
|
+
}).catch(setError);
|
|
135
|
+
|
|
136
|
+
// Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
|
|
137
|
+
if (root.current.ready.status === 'fulfilled') {
|
|
129
138
|
root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
|
|
130
139
|
children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
|
|
131
140
|
set: setError,
|
|
@@ -137,10 +146,19 @@ function CanvasImpl({
|
|
|
137
146
|
})
|
|
138
147
|
})
|
|
139
148
|
}));
|
|
149
|
+
} else if (root.current.ready.status === 'pending') {
|
|
150
|
+
waitFor(root.current.ready);
|
|
140
151
|
}
|
|
141
|
-
run();
|
|
142
152
|
}
|
|
143
153
|
});
|
|
154
|
+
|
|
155
|
+
// Refs on ancestors attach after our layout effect
|
|
156
|
+
React__namespace.useEffect(() => {
|
|
157
|
+
var _rootState$current;
|
|
158
|
+
const state = (_rootState$current = rootState.current) == null ? void 0 : _rootState$current.get();
|
|
159
|
+
const target = eventTarget();
|
|
160
|
+
if (state && target && state.events.connected !== target) state.events.connect == null ? void 0 : state.events.connect(target);
|
|
161
|
+
});
|
|
144
162
|
React__namespace.useEffect(() => {
|
|
145
163
|
const canvas = canvasRef.current;
|
|
146
164
|
if (canvas) return () => events.unmountComponentAtNode(canvas);
|
|
@@ -149,7 +167,7 @@ function CanvasImpl({
|
|
|
149
167
|
// When the event source is not this div, we need to set pointer-events to none
|
|
150
168
|
// Or else the canvas will block events from reaching the event source
|
|
151
169
|
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
152
|
-
return /*#__PURE__*/jsxRuntime.
|
|
170
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
153
171
|
ref: divRef,
|
|
154
172
|
style: {
|
|
155
173
|
position: 'relative',
|
|
@@ -160,7 +178,7 @@ function CanvasImpl({
|
|
|
160
178
|
...style
|
|
161
179
|
},
|
|
162
180
|
...props,
|
|
163
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
181
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
164
182
|
ref: containerRef,
|
|
165
183
|
style: {
|
|
166
184
|
width: '100%',
|
|
@@ -173,7 +191,7 @@ function CanvasImpl({
|
|
|
173
191
|
},
|
|
174
192
|
children: fallback
|
|
175
193
|
})
|
|
176
|
-
})
|
|
194
|
+
}), gate]
|
|
177
195
|
});
|
|
178
196
|
}
|
|
179
197
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-a79ef12b.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -86,46 +86,55 @@ function CanvasImpl({
|
|
|
86
86
|
// Throw exception outwards if anything within canvas throws
|
|
87
87
|
if (error) throw error;
|
|
88
88
|
const root = React__namespace.useRef(null);
|
|
89
|
+
|
|
90
|
+
// Waits for an async renderer without hiding the canvas
|
|
91
|
+
const [gate, waitFor] = events.useGate();
|
|
92
|
+
const rootState = React__namespace.useRef(null);
|
|
93
|
+
const eventTarget = () => eventSource ? events.isRef(eventSource) ? eventSource.current : eventSource : divRef.current;
|
|
89
94
|
events.useIsomorphicLayoutEffect(() => {
|
|
90
95
|
const canvas = canvasRef.current;
|
|
91
96
|
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
92
97
|
if (!root.current) root.current = events.createRoot(canvas);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Call onCreated callback
|
|
126
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
98
|
+
root.current.configure({
|
|
99
|
+
gl,
|
|
100
|
+
scene,
|
|
101
|
+
events: events$1,
|
|
102
|
+
shadows,
|
|
103
|
+
linear,
|
|
104
|
+
flat,
|
|
105
|
+
legacy,
|
|
106
|
+
orthographic,
|
|
107
|
+
frameloop,
|
|
108
|
+
dpr,
|
|
109
|
+
performance,
|
|
110
|
+
raycaster,
|
|
111
|
+
camera,
|
|
112
|
+
size: containerRect,
|
|
113
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
114
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
115
|
+
onCreated: state => {
|
|
116
|
+
var _eventTarget;
|
|
117
|
+
rootState.current = state;
|
|
118
|
+
// A ref to an ancestor is not attached yet. The effect below settles it
|
|
119
|
+
state.events.connect == null ? void 0 : state.events.connect((_eventTarget = eventTarget()) != null ? _eventTarget : divRef.current);
|
|
120
|
+
// Set up compute function
|
|
121
|
+
if (eventPrefix) {
|
|
122
|
+
state.setEvents({
|
|
123
|
+
compute: (event, state) => {
|
|
124
|
+
const x = event[eventPrefix + 'X'];
|
|
125
|
+
const y = event[eventPrefix + 'Y'];
|
|
126
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
127
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
127
130
|
}
|
|
128
|
-
|
|
131
|
+
// Call onCreated callback
|
|
132
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
133
|
+
}
|
|
134
|
+
}).catch(setError);
|
|
135
|
+
|
|
136
|
+
// Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
|
|
137
|
+
if (root.current.ready.status === 'fulfilled') {
|
|
129
138
|
root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
|
|
130
139
|
children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
|
|
131
140
|
set: setError,
|
|
@@ -137,10 +146,19 @@ function CanvasImpl({
|
|
|
137
146
|
})
|
|
138
147
|
})
|
|
139
148
|
}));
|
|
149
|
+
} else if (root.current.ready.status === 'pending') {
|
|
150
|
+
waitFor(root.current.ready);
|
|
140
151
|
}
|
|
141
|
-
run();
|
|
142
152
|
}
|
|
143
153
|
});
|
|
154
|
+
|
|
155
|
+
// Refs on ancestors attach after our layout effect
|
|
156
|
+
React__namespace.useEffect(() => {
|
|
157
|
+
var _rootState$current;
|
|
158
|
+
const state = (_rootState$current = rootState.current) == null ? void 0 : _rootState$current.get();
|
|
159
|
+
const target = eventTarget();
|
|
160
|
+
if (state && target && state.events.connected !== target) state.events.connect == null ? void 0 : state.events.connect(target);
|
|
161
|
+
});
|
|
144
162
|
React__namespace.useEffect(() => {
|
|
145
163
|
const canvas = canvasRef.current;
|
|
146
164
|
if (canvas) return () => events.unmountComponentAtNode(canvas);
|
|
@@ -149,7 +167,7 @@ function CanvasImpl({
|
|
|
149
167
|
// When the event source is not this div, we need to set pointer-events to none
|
|
150
168
|
// Or else the canvas will block events from reaching the event source
|
|
151
169
|
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
152
|
-
return /*#__PURE__*/jsxRuntime.
|
|
170
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
153
171
|
ref: divRef,
|
|
154
172
|
style: {
|
|
155
173
|
position: 'relative',
|
|
@@ -160,7 +178,7 @@ function CanvasImpl({
|
|
|
160
178
|
...style
|
|
161
179
|
},
|
|
162
180
|
...props,
|
|
163
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
181
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
164
182
|
ref: containerRef,
|
|
165
183
|
style: {
|
|
166
184
|
width: '100%',
|
|
@@ -173,7 +191,7 @@ function CanvasImpl({
|
|
|
173
191
|
},
|
|
174
192
|
children: fallback
|
|
175
193
|
})
|
|
176
|
-
})
|
|
194
|
+
}), gate]
|
|
177
195
|
});
|
|
178
196
|
}
|
|
179
197
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, b as
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots,
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, b as useGate, c as useIsomorphicLayoutEffect, d as createRoot, E as ErrorBoundary, B as Block, f as unmountComponentAtNode, g as createPointerEvents, i as isRef } from './events-803f4abc.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, y as act, l as addAfterEffect, k as addEffect, m as addTail, o as advance, v as applyProps, z as buildGraph, s as context, h as createEvents, p as createPortal, d as createRoot, x as dispose, g as events, e as extend, j as flushGlobalEffects, q as flushSync, w as getRootState, n as invalidate, r as reconciler, f as unmountComponentAtNode, F as useFrame, G as useGraph, A as useInstanceHandle, H as useLoader, C as useStore, D as useThree } from './events-803f4abc.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import useMeasure from 'react-use-measure';
|
|
6
6
|
import { FiberProvider } from 'its-fine';
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
8
|
import 'zustand/traditional';
|
|
9
9
|
import 'suspend-react';
|
|
10
10
|
import 'scheduler';
|
|
@@ -59,46 +59,55 @@ function CanvasImpl({
|
|
|
59
59
|
// Throw exception outwards if anything within canvas throws
|
|
60
60
|
if (error) throw error;
|
|
61
61
|
const root = React.useRef(null);
|
|
62
|
+
|
|
63
|
+
// Waits for an async renderer without hiding the canvas
|
|
64
|
+
const [gate, waitFor] = useGate();
|
|
65
|
+
const rootState = React.useRef(null);
|
|
66
|
+
const eventTarget = () => eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current;
|
|
62
67
|
useIsomorphicLayoutEffect(() => {
|
|
63
68
|
const canvas = canvasRef.current;
|
|
64
69
|
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
65
70
|
if (!root.current) root.current = createRoot(canvas);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Call onCreated callback
|
|
99
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
71
|
+
root.current.configure({
|
|
72
|
+
gl,
|
|
73
|
+
scene,
|
|
74
|
+
events,
|
|
75
|
+
shadows,
|
|
76
|
+
linear,
|
|
77
|
+
flat,
|
|
78
|
+
legacy,
|
|
79
|
+
orthographic,
|
|
80
|
+
frameloop,
|
|
81
|
+
dpr,
|
|
82
|
+
performance,
|
|
83
|
+
raycaster,
|
|
84
|
+
camera,
|
|
85
|
+
size: containerRect,
|
|
86
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
87
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
88
|
+
onCreated: state => {
|
|
89
|
+
var _eventTarget;
|
|
90
|
+
rootState.current = state;
|
|
91
|
+
// A ref to an ancestor is not attached yet. The effect below settles it
|
|
92
|
+
state.events.connect == null ? void 0 : state.events.connect((_eventTarget = eventTarget()) != null ? _eventTarget : divRef.current);
|
|
93
|
+
// Set up compute function
|
|
94
|
+
if (eventPrefix) {
|
|
95
|
+
state.setEvents({
|
|
96
|
+
compute: (event, state) => {
|
|
97
|
+
const x = event[eventPrefix + 'X'];
|
|
98
|
+
const y = event[eventPrefix + 'Y'];
|
|
99
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
100
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
100
103
|
}
|
|
101
|
-
|
|
104
|
+
// Call onCreated callback
|
|
105
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
106
|
+
}
|
|
107
|
+
}).catch(setError);
|
|
108
|
+
|
|
109
|
+
// Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
|
|
110
|
+
if (root.current.ready.status === 'fulfilled') {
|
|
102
111
|
root.current.render( /*#__PURE__*/jsx(Bridge, {
|
|
103
112
|
children: /*#__PURE__*/jsx(ErrorBoundary, {
|
|
104
113
|
set: setError,
|
|
@@ -110,10 +119,19 @@ function CanvasImpl({
|
|
|
110
119
|
})
|
|
111
120
|
})
|
|
112
121
|
}));
|
|
122
|
+
} else if (root.current.ready.status === 'pending') {
|
|
123
|
+
waitFor(root.current.ready);
|
|
113
124
|
}
|
|
114
|
-
run();
|
|
115
125
|
}
|
|
116
126
|
});
|
|
127
|
+
|
|
128
|
+
// Refs on ancestors attach after our layout effect
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
var _rootState$current;
|
|
131
|
+
const state = (_rootState$current = rootState.current) == null ? void 0 : _rootState$current.get();
|
|
132
|
+
const target = eventTarget();
|
|
133
|
+
if (state && target && state.events.connected !== target) state.events.connect == null ? void 0 : state.events.connect(target);
|
|
134
|
+
});
|
|
117
135
|
React.useEffect(() => {
|
|
118
136
|
const canvas = canvasRef.current;
|
|
119
137
|
if (canvas) return () => unmountComponentAtNode(canvas);
|
|
@@ -122,7 +140,7 @@ function CanvasImpl({
|
|
|
122
140
|
// When the event source is not this div, we need to set pointer-events to none
|
|
123
141
|
// Or else the canvas will block events from reaching the event source
|
|
124
142
|
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
125
|
-
return /*#__PURE__*/
|
|
143
|
+
return /*#__PURE__*/jsxs("div", {
|
|
126
144
|
ref: divRef,
|
|
127
145
|
style: {
|
|
128
146
|
position: 'relative',
|
|
@@ -133,7 +151,7 @@ function CanvasImpl({
|
|
|
133
151
|
...style
|
|
134
152
|
},
|
|
135
153
|
...props,
|
|
136
|
-
children: /*#__PURE__*/jsx("div", {
|
|
154
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
137
155
|
ref: containerRef,
|
|
138
156
|
style: {
|
|
139
157
|
width: '100%',
|
|
@@ -146,7 +164,7 @@ function CanvasImpl({
|
|
|
146
164
|
},
|
|
147
165
|
children: fallback
|
|
148
166
|
})
|
|
149
|
-
})
|
|
167
|
+
}), gate]
|
|
150
168
|
});
|
|
151
169
|
}
|
|
152
170
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('../../dist/events-
|
|
5
|
+
var events = require('../../dist/events-ce5e34e8.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -190,45 +190,50 @@ function CanvasImpl({
|
|
|
190
190
|
});
|
|
191
191
|
setBind(responder.panHandlers);
|
|
192
192
|
}, []);
|
|
193
|
+
|
|
194
|
+
// Waits for an async renderer without hiding the view
|
|
195
|
+
const [gate, waitFor] = events.useGate();
|
|
193
196
|
events.useIsomorphicLayoutEffect(() => {
|
|
194
197
|
if (root.current && width > 0 && height > 0) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
198
|
+
root.current.configure({
|
|
199
|
+
gl,
|
|
200
|
+
events: events$1,
|
|
201
|
+
shadows,
|
|
202
|
+
linear,
|
|
203
|
+
flat,
|
|
204
|
+
legacy,
|
|
205
|
+
orthographic,
|
|
206
|
+
frameloop,
|
|
207
|
+
performance,
|
|
208
|
+
raycaster,
|
|
209
|
+
camera,
|
|
210
|
+
scene,
|
|
211
|
+
// expo-gl can only render at native dpr/resolution
|
|
212
|
+
// https://github.com/expo/expo-three/issues/39
|
|
213
|
+
dpr: reactNative.PixelRatio.get(),
|
|
214
|
+
size: {
|
|
215
|
+
width,
|
|
216
|
+
height,
|
|
217
|
+
top,
|
|
218
|
+
left
|
|
219
|
+
},
|
|
220
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
221
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
222
|
+
// Overwrite onCreated to apply RN bindings
|
|
223
|
+
onCreated: state => {
|
|
224
|
+
// Bind render to RN bridge
|
|
225
|
+
const context = state.gl.getContext();
|
|
226
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
227
|
+
state.gl.render = (scene, camera) => {
|
|
228
|
+
renderFrame(scene, camera);
|
|
229
|
+
context.endFrameEXP();
|
|
230
|
+
};
|
|
231
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
232
|
+
}
|
|
233
|
+
}).catch(setError);
|
|
234
|
+
|
|
235
|
+
// Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
|
|
236
|
+
if (root.current.ready.status === 'fulfilled') {
|
|
232
237
|
root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
|
|
233
238
|
children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
|
|
234
239
|
set: setError,
|
|
@@ -240,8 +245,9 @@ function CanvasImpl({
|
|
|
240
245
|
})
|
|
241
246
|
})
|
|
242
247
|
}));
|
|
248
|
+
} else if (root.current.ready.status === 'pending') {
|
|
249
|
+
waitFor(root.current.ready);
|
|
243
250
|
}
|
|
244
|
-
run();
|
|
245
251
|
}
|
|
246
252
|
});
|
|
247
253
|
React__namespace.useEffect(() => {
|
|
@@ -265,7 +271,7 @@ function CanvasImpl({
|
|
|
265
271
|
style: reactNative.StyleSheet.absoluteFill,
|
|
266
272
|
pointerEvents: pointerEvents,
|
|
267
273
|
...bind
|
|
268
|
-
})]
|
|
274
|
+
}), gate]
|
|
269
275
|
});
|
|
270
276
|
}
|
|
271
277
|
|