@react-three/fiber 9.0.0-rc.0 → 9.0.0-rc.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 +24 -0
- package/dist/declarations/src/core/events.d.ts +1 -0
- package/dist/declarations/src/core/hooks.d.ts +13 -12
- package/dist/declarations/src/core/index.d.ts +1 -1
- package/dist/declarations/src/core/reconciler.d.ts +0 -5
- package/dist/declarations/src/core/renderer.d.ts +5 -3
- package/dist/declarations/src/core/utils.d.ts +80 -31
- package/dist/declarations/src/native/Canvas.d.ts +2 -3
- package/dist/declarations/src/three-types.d.ts +5 -1
- package/dist/declarations/src/web/Canvas.d.ts +3 -4
- package/dist/{events-5a08b43f.esm.js → events-aba3c3d1.esm.js} +972 -979
- package/dist/{events-aef54ace.cjs.prod.js → events-b02714fc.cjs.dev.js} +970 -977
- package/dist/{events-fa0fb3db.cjs.dev.js → events-bd708dc8.cjs.prod.js} +970 -978
- package/dist/react-three-fiber.cjs.dev.js +60 -252
- package/dist/react-three-fiber.cjs.prod.js +60 -252
- package/dist/react-three-fiber.esm.js +59 -251
- package/native/dist/react-three-fiber-native.cjs.dev.js +63 -63
- package/native/dist/react-three-fiber-native.cjs.prod.js +63 -63
- package/native/dist/react-three-fiber-native.esm.js +64 -63
- package/package.json +11 -12
- package/dist/declarations/src/web/use-measure.d.ts +0 -34
|
@@ -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-bd708dc8.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -15,9 +15,9 @@ var base64Js = require('base64-js');
|
|
|
15
15
|
var buffer = require('buffer');
|
|
16
16
|
require('react-reconciler/constants');
|
|
17
17
|
require('zustand/traditional');
|
|
18
|
-
require('suspend-react');
|
|
19
18
|
require('react-reconciler');
|
|
20
19
|
require('scheduler');
|
|
20
|
+
require('suspend-react');
|
|
21
21
|
|
|
22
22
|
function _interopNamespace(e) {
|
|
23
23
|
if (e && e.__esModule) return e;
|
|
@@ -43,11 +43,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
|
43
43
|
|
|
44
44
|
// TODO: React 19 needs support from react-native
|
|
45
45
|
const _View = reactNative.View;
|
|
46
|
-
|
|
47
|
-
* A native canvas which accepts threejs elements as children.
|
|
48
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
49
|
-
*/
|
|
50
|
-
const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
46
|
+
function CanvasImpl({
|
|
51
47
|
children,
|
|
52
48
|
style,
|
|
53
49
|
gl,
|
|
@@ -64,8 +60,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
64
60
|
scene,
|
|
65
61
|
onPointerMissed,
|
|
66
62
|
onCreated,
|
|
63
|
+
ref,
|
|
67
64
|
...props
|
|
68
|
-
}
|
|
65
|
+
}) {
|
|
69
66
|
// Create a known catalogue of Threejs-native elements
|
|
70
67
|
// This will include the entire THREE namespace by default, users can extend
|
|
71
68
|
// their own elements by using the createRoot API instead
|
|
@@ -84,7 +81,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
84
81
|
});
|
|
85
82
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
86
83
|
const [bind, setBind] = React__namespace.useState();
|
|
87
|
-
React__namespace.useImperativeHandle(
|
|
84
|
+
React__namespace.useImperativeHandle(ref, () => viewRef.current);
|
|
88
85
|
const handlePointerMissed = events.useMutableCallback(onPointerMissed);
|
|
89
86
|
const [block, setBlock] = React__namespace.useState(false);
|
|
90
87
|
const [error, setError] = React__namespace.useState(undefined);
|
|
@@ -196,55 +193,60 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
196
193
|
});
|
|
197
194
|
setBind(responder.panHandlers);
|
|
198
195
|
}, []);
|
|
199
|
-
|
|
200
|
-
root.current
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
196
|
+
events.useIsomorphicLayoutEffect(() => {
|
|
197
|
+
if (root.current && width > 0 && height > 0) {
|
|
198
|
+
async function run() {
|
|
199
|
+
await root.current.configure({
|
|
200
|
+
gl,
|
|
201
|
+
events: events$1,
|
|
202
|
+
shadows,
|
|
203
|
+
linear,
|
|
204
|
+
flat,
|
|
205
|
+
legacy,
|
|
206
|
+
orthographic,
|
|
207
|
+
frameloop,
|
|
208
|
+
performance,
|
|
209
|
+
raycaster,
|
|
210
|
+
camera,
|
|
211
|
+
scene,
|
|
212
|
+
// expo-gl can only render at native dpr/resolution
|
|
213
|
+
// https://github.com/expo/expo-three/issues/39
|
|
214
|
+
dpr: reactNative.PixelRatio.get(),
|
|
215
|
+
size: {
|
|
216
|
+
width,
|
|
217
|
+
height,
|
|
218
|
+
top,
|
|
219
|
+
left
|
|
220
|
+
},
|
|
221
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
222
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
223
|
+
// Overwrite onCreated to apply RN bindings
|
|
224
|
+
onCreated: state => {
|
|
225
|
+
// Bind render to RN bridge
|
|
226
|
+
const context = state.gl.getContext();
|
|
227
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
228
|
+
state.gl.render = (scene, camera) => {
|
|
229
|
+
renderFrame(scene, camera);
|
|
230
|
+
context.endFrameEXP();
|
|
231
|
+
};
|
|
232
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
|
|
236
|
+
children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
|
|
237
|
+
set: setError,
|
|
238
|
+
children: /*#__PURE__*/jsxRuntime.jsx(React__namespace.Suspense, {
|
|
239
|
+
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
240
|
+
set: setBlock
|
|
241
|
+
}),
|
|
242
|
+
children: children
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
}));
|
|
234
246
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
set: setError,
|
|
239
|
-
children: /*#__PURE__*/jsxRuntime.jsx(React__namespace.Suspense, {
|
|
240
|
-
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
241
|
-
set: setBlock
|
|
242
|
-
}),
|
|
243
|
-
children: children
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
}));
|
|
247
|
-
}
|
|
247
|
+
run();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
248
250
|
React__namespace.useEffect(() => {
|
|
249
251
|
if (canvas) {
|
|
250
252
|
return () => events.unmountComponentAtNode(canvas);
|
|
@@ -265,20 +267,19 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
265
267
|
style: reactNative.StyleSheet.absoluteFill
|
|
266
268
|
})
|
|
267
269
|
});
|
|
268
|
-
}
|
|
270
|
+
}
|
|
269
271
|
|
|
270
272
|
/**
|
|
271
273
|
* A native canvas which accepts threejs elements as children.
|
|
272
274
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
273
275
|
*/
|
|
274
|
-
|
|
276
|
+
function Canvas(props) {
|
|
275
277
|
return /*#__PURE__*/jsxRuntime.jsx(itsFine.FiberProvider, {
|
|
276
278
|
children: /*#__PURE__*/jsxRuntime.jsx(CanvasImpl, {
|
|
277
|
-
...props
|
|
278
|
-
ref: ref
|
|
279
|
+
...props
|
|
279
280
|
})
|
|
280
281
|
});
|
|
281
|
-
}
|
|
282
|
+
}
|
|
282
283
|
|
|
283
284
|
/** Default R3F event manager for react-native */
|
|
284
285
|
function createTouchEvents(store) {
|
|
@@ -542,7 +543,6 @@ exports.flushGlobalEffects = events.flushGlobalEffects;
|
|
|
542
543
|
exports.getRootState = events.getRootState;
|
|
543
544
|
exports.invalidate = events.invalidate;
|
|
544
545
|
exports.reconciler = events.reconciler;
|
|
545
|
-
exports.render = events.render;
|
|
546
546
|
exports.unmountComponentAtNode = events.unmountComponentAtNode;
|
|
547
547
|
exports.useFrame = events.useFrame;
|
|
548
548
|
exports.useGraph = events.useGraph;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots,
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-aba3c3d1.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-aba3c3d1.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
|
|
@@ -12,17 +12,13 @@ import { fromByteArray } from 'base64-js';
|
|
|
12
12
|
import { Buffer } from 'buffer';
|
|
13
13
|
import 'react-reconciler/constants';
|
|
14
14
|
import 'zustand/traditional';
|
|
15
|
-
import 'suspend-react';
|
|
16
15
|
import 'react-reconciler';
|
|
17
16
|
import 'scheduler';
|
|
17
|
+
import 'suspend-react';
|
|
18
18
|
|
|
19
19
|
// TODO: React 19 needs support from react-native
|
|
20
20
|
const _View = View;
|
|
21
|
-
|
|
22
|
-
* A native canvas which accepts threejs elements as children.
|
|
23
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
24
|
-
*/
|
|
25
|
-
const CanvasImpl = /*#__PURE__*/React.forwardRef(({
|
|
21
|
+
function CanvasImpl({
|
|
26
22
|
children,
|
|
27
23
|
style,
|
|
28
24
|
gl,
|
|
@@ -39,8 +35,9 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
|
|
|
39
35
|
scene,
|
|
40
36
|
onPointerMissed,
|
|
41
37
|
onCreated,
|
|
38
|
+
ref,
|
|
42
39
|
...props
|
|
43
|
-
}
|
|
40
|
+
}) {
|
|
44
41
|
// Create a known catalogue of Threejs-native elements
|
|
45
42
|
// This will include the entire THREE namespace by default, users can extend
|
|
46
43
|
// their own elements by using the createRoot API instead
|
|
@@ -59,7 +56,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
|
|
|
59
56
|
});
|
|
60
57
|
const [canvas, setCanvas] = React.useState(null);
|
|
61
58
|
const [bind, setBind] = React.useState();
|
|
62
|
-
React.useImperativeHandle(
|
|
59
|
+
React.useImperativeHandle(ref, () => viewRef.current);
|
|
63
60
|
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
64
61
|
const [block, setBlock] = React.useState(false);
|
|
65
62
|
const [error, setError] = React.useState(undefined);
|
|
@@ -171,55 +168,60 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
|
|
|
171
168
|
});
|
|
172
169
|
setBind(responder.panHandlers);
|
|
173
170
|
}, []);
|
|
174
|
-
|
|
175
|
-
root.current
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
171
|
+
useIsomorphicLayoutEffect(() => {
|
|
172
|
+
if (root.current && width > 0 && height > 0) {
|
|
173
|
+
async function run() {
|
|
174
|
+
await root.current.configure({
|
|
175
|
+
gl,
|
|
176
|
+
events,
|
|
177
|
+
shadows,
|
|
178
|
+
linear,
|
|
179
|
+
flat,
|
|
180
|
+
legacy,
|
|
181
|
+
orthographic,
|
|
182
|
+
frameloop,
|
|
183
|
+
performance,
|
|
184
|
+
raycaster,
|
|
185
|
+
camera,
|
|
186
|
+
scene,
|
|
187
|
+
// expo-gl can only render at native dpr/resolution
|
|
188
|
+
// https://github.com/expo/expo-three/issues/39
|
|
189
|
+
dpr: PixelRatio.get(),
|
|
190
|
+
size: {
|
|
191
|
+
width,
|
|
192
|
+
height,
|
|
193
|
+
top,
|
|
194
|
+
left
|
|
195
|
+
},
|
|
196
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
197
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
198
|
+
// Overwrite onCreated to apply RN bindings
|
|
199
|
+
onCreated: state => {
|
|
200
|
+
// Bind render to RN bridge
|
|
201
|
+
const context = state.gl.getContext();
|
|
202
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
203
|
+
state.gl.render = (scene, camera) => {
|
|
204
|
+
renderFrame(scene, camera);
|
|
205
|
+
context.endFrameEXP();
|
|
206
|
+
};
|
|
207
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
root.current.render( /*#__PURE__*/jsx(Bridge, {
|
|
211
|
+
children: /*#__PURE__*/jsx(ErrorBoundary, {
|
|
212
|
+
set: setError,
|
|
213
|
+
children: /*#__PURE__*/jsx(React.Suspense, {
|
|
214
|
+
fallback: /*#__PURE__*/jsx(Block, {
|
|
215
|
+
set: setBlock
|
|
216
|
+
}),
|
|
217
|
+
children: children
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
}));
|
|
209
221
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
set: setError,
|
|
214
|
-
children: /*#__PURE__*/jsx(React.Suspense, {
|
|
215
|
-
fallback: /*#__PURE__*/jsx(Block, {
|
|
216
|
-
set: setBlock
|
|
217
|
-
}),
|
|
218
|
-
children: children
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
}));
|
|
222
|
-
}
|
|
222
|
+
run();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
223
225
|
React.useEffect(() => {
|
|
224
226
|
if (canvas) {
|
|
225
227
|
return () => unmountComponentAtNode(canvas);
|
|
@@ -240,20 +242,19 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
|
|
|
240
242
|
style: StyleSheet.absoluteFill
|
|
241
243
|
})
|
|
242
244
|
});
|
|
243
|
-
}
|
|
245
|
+
}
|
|
244
246
|
|
|
245
247
|
/**
|
|
246
248
|
* A native canvas which accepts threejs elements as children.
|
|
247
249
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
248
250
|
*/
|
|
249
|
-
|
|
251
|
+
function Canvas(props) {
|
|
250
252
|
return /*#__PURE__*/jsx(FiberProvider, {
|
|
251
253
|
children: /*#__PURE__*/jsx(CanvasImpl, {
|
|
252
|
-
...props
|
|
253
|
-
ref: ref
|
|
254
|
+
...props
|
|
254
255
|
})
|
|
255
256
|
});
|
|
256
|
-
}
|
|
257
|
+
}
|
|
257
258
|
|
|
258
259
|
/** Default R3F event manager for react-native */
|
|
259
260
|
function createTouchEvents(store) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/fiber",
|
|
3
|
-
"version": "9.0.0-rc.
|
|
3
|
+
"version": "9.0.0-rc.10",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,27 +43,26 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.17.8",
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/react-reconciler": "^0.28.8",
|
|
46
|
+
"@types/react-reconciler": "^0.28.9",
|
|
48
47
|
"@types/webxr": "*",
|
|
49
48
|
"base64-js": "^1.5.1",
|
|
50
49
|
"buffer": "^6.0.3",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"react-
|
|
54
|
-
"scheduler": "0.25.0
|
|
50
|
+
"its-fine": "^2.0.0",
|
|
51
|
+
"react-reconciler": "^0.31.0",
|
|
52
|
+
"react-use-measure": "^2.1.7",
|
|
53
|
+
"scheduler": "^0.25.0",
|
|
55
54
|
"suspend-react": "^0.1.3",
|
|
56
|
-
"zustand": "^
|
|
55
|
+
"zustand": "^5.0.3"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
58
|
"expo": ">=43.0",
|
|
60
59
|
"expo-asset": ">=8.4",
|
|
61
60
|
"expo-gl": ">=11.0",
|
|
62
61
|
"expo-file-system": ">=11.0",
|
|
63
|
-
"react": "
|
|
64
|
-
"react-dom": "
|
|
65
|
-
"react-native": ">=0.
|
|
66
|
-
"three": ">=0.
|
|
62
|
+
"react": "^19.0.0",
|
|
63
|
+
"react-dom": "^19.0.0",
|
|
64
|
+
"react-native": ">=0.78",
|
|
65
|
+
"three": ">=0.156"
|
|
67
66
|
},
|
|
68
67
|
"peerDependenciesMeta": {
|
|
69
68
|
"react-dom": {
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
declare type ResizeObserverCallback = (entries: any[], observer: ResizeObserver) => void;
|
|
2
|
-
declare class ResizeObserver {
|
|
3
|
-
constructor(callback: ResizeObserverCallback);
|
|
4
|
-
observe(target: Element, options?: any): void;
|
|
5
|
-
unobserve(target: Element): void;
|
|
6
|
-
disconnect(): void;
|
|
7
|
-
static toString(): string;
|
|
8
|
-
}
|
|
9
|
-
export interface RectReadOnly {
|
|
10
|
-
readonly x: number;
|
|
11
|
-
readonly y: number;
|
|
12
|
-
readonly width: number;
|
|
13
|
-
readonly height: number;
|
|
14
|
-
readonly top: number;
|
|
15
|
-
readonly right: number;
|
|
16
|
-
readonly bottom: number;
|
|
17
|
-
readonly left: number;
|
|
18
|
-
[key: string]: number;
|
|
19
|
-
}
|
|
20
|
-
type HTMLOrSVGElement = HTMLElement | SVGElement;
|
|
21
|
-
type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void];
|
|
22
|
-
export type Options = {
|
|
23
|
-
debounce?: number | {
|
|
24
|
-
scroll: number;
|
|
25
|
-
resize: number;
|
|
26
|
-
};
|
|
27
|
-
scroll?: boolean;
|
|
28
|
-
polyfill?: {
|
|
29
|
-
new (cb: ResizeObserverCallback): ResizeObserver;
|
|
30
|
-
};
|
|
31
|
-
offsetSize?: boolean;
|
|
32
|
-
};
|
|
33
|
-
export declare function useMeasure({ debounce, scroll, polyfill, offsetSize }?: Options): Result;
|
|
34
|
-
export {};
|