@react-three/fiber 8.0.26 → 8.2.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 +18 -0
- package/dist/declarations/src/core/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +21 -21
- package/dist/declarations/src/core/index.d.ts +57 -60
- package/dist/declarations/src/core/loop.d.ts +13 -13
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/store.d.ts +95 -93
- package/dist/declarations/src/core/utils.d.ts +82 -82
- package/dist/declarations/src/index.d.ts +11 -10
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +10 -10
- package/dist/declarations/src/three-types.d.ts +331 -329
- package/dist/declarations/src/web/Canvas.d.ts +9 -9
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-7af14ac8.cjs.dev.js → index-0499a96a.cjs.dev.js} +69 -44
- package/dist/{index-bfdbf5d7.esm.js → index-6279214a.esm.js} +69 -44
- package/dist/{index-1301c9b6.cjs.prod.js → index-ca47b633.cjs.prod.js} +69 -44
- package/dist/react-three-fiber.cjs.dev.js +5 -10
- package/dist/react-three-fiber.cjs.prod.js +5 -10
- package/dist/react-three-fiber.esm.js +5 -11
- package/native/dist/react-three-fiber-native.cjs.dev.js +16 -6
- package/native/dist/react-three-fiber-native.cjs.prod.js +16 -6
- package/native/dist/react-three-fiber-native.esm.js +17 -7
- package/package.json +1 -1
|
@@ -855,7 +855,7 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
855
855
|
...objects
|
|
856
856
|
});
|
|
857
857
|
|
|
858
|
-
function createRenderer(
|
|
858
|
+
function createRenderer(_roots, _getEventPriority) {
|
|
859
859
|
function createInstance(type, {
|
|
860
860
|
args = [],
|
|
861
861
|
attach,
|
|
@@ -1071,10 +1071,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1071
1071
|
appendChild,
|
|
1072
1072
|
appendInitialChild: appendChild,
|
|
1073
1073
|
insertBefore,
|
|
1074
|
-
supportsMicrotask: true,
|
|
1075
|
-
warnsIfNotActing: true,
|
|
1076
1074
|
supportsMutation: true,
|
|
1077
1075
|
isPrimaryRenderer: false,
|
|
1076
|
+
supportsPersistence: false,
|
|
1077
|
+
supportsHydration: false,
|
|
1078
1078
|
noTimeout: -1,
|
|
1079
1079
|
appendChildToContainer: (container, child) => {
|
|
1080
1080
|
const scene = container.getState().scene; // Link current root to the default scene
|
|
@@ -1093,10 +1093,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1093
1093
|
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1094
1094
|
// Returning true will trigger commitMount
|
|
1095
1095
|
|
|
1096
|
-
return
|
|
1096
|
+
return Boolean(localState.handlers);
|
|
1097
1097
|
},
|
|
1098
1098
|
|
|
1099
|
-
prepareUpdate(instance,
|
|
1099
|
+
prepareUpdate(instance, _type, oldProps, newProps) {
|
|
1100
1100
|
// Create diff-sets
|
|
1101
1101
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1102
1102
|
return [true];
|
|
@@ -1113,7 +1113,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1113
1113
|
...restOld
|
|
1114
1114
|
} = oldProps; // Throw if an object or literal was passed for args
|
|
1115
1115
|
|
|
1116
|
-
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-
|
|
1116
|
+
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instantiated
|
|
1117
1117
|
|
|
1118
1118
|
if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
|
|
1119
1119
|
|
|
@@ -1124,13 +1124,13 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
},
|
|
1126
1126
|
|
|
1127
|
-
commitUpdate(instance, [reconstruct, diff], type,
|
|
1127
|
+
commitUpdate(instance, [reconstruct, diff], type, _oldProps, newProps, fiber) {
|
|
1128
1128
|
// Reconstruct when args or <primitive object={...} have changes
|
|
1129
1129
|
if (reconstruct) switchInstance(instance, type, newProps, fiber); // Otherwise just overwrite props
|
|
1130
1130
|
else applyProps$1(instance, diff);
|
|
1131
1131
|
},
|
|
1132
1132
|
|
|
1133
|
-
commitMount(instance,
|
|
1133
|
+
commitMount(instance, _type, _props, _int) {
|
|
1134
1134
|
var _instance$__r3f3;
|
|
1135
1135
|
|
|
1136
1136
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1143,13 +1143,11 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1143
1143
|
},
|
|
1144
1144
|
|
|
1145
1145
|
getPublicInstance: instance => instance,
|
|
1146
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1147
1146
|
prepareForCommit: () => null,
|
|
1148
1147
|
preparePortalMount: container => prepare(container.getState().scene),
|
|
1149
1148
|
resetAfterCommit: () => {},
|
|
1150
1149
|
shouldSetTextContent: () => false,
|
|
1151
1150
|
clearContainer: () => false,
|
|
1152
|
-
detachDeletedInstance: () => {},
|
|
1153
1151
|
|
|
1154
1152
|
hideInstance(instance) {
|
|
1155
1153
|
var _instance$__r3f4;
|
|
@@ -1177,20 +1175,23 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1177
1175
|
invalidateInstance(instance);
|
|
1178
1176
|
},
|
|
1179
1177
|
|
|
1180
|
-
createTextInstance: () => {
|
|
1178
|
+
createTextInstance: () => {
|
|
1179
|
+
throw new Error('Text is not allowed in the R3F tree.');
|
|
1180
|
+
},
|
|
1181
1181
|
hideTextInstance: () => {
|
|
1182
1182
|
throw new Error('Text is not allowed in the R3F tree.');
|
|
1183
1183
|
},
|
|
1184
1184
|
unhideTextInstance: () => {},
|
|
1185
|
-
|
|
1186
|
-
// @ts-ignore
|
|
1187
|
-
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
1185
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
|
|
1188
1186
|
// @ts-ignore
|
|
1187
|
+
getCurrentEventPriority: () => _getEventPriority ? _getEventPriority() : constants.DefaultEventPriority,
|
|
1188
|
+
beforeActiveInstanceBlur: () => {},
|
|
1189
|
+
afterActiveInstanceBlur: () => {},
|
|
1190
|
+
detachDeletedInstance: () => {},
|
|
1191
|
+
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : () => 0,
|
|
1192
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r920883503
|
|
1189
1193
|
scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1190
|
-
|
|
1191
|
-
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1192
|
-
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1193
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1194
|
+
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1194
1195
|
});
|
|
1195
1196
|
return {
|
|
1196
1197
|
reconciler,
|
|
@@ -1211,7 +1212,9 @@ const createStore = (invalidate, advance) => {
|
|
|
1211
1212
|
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
1212
1213
|
const {
|
|
1213
1214
|
width,
|
|
1214
|
-
height
|
|
1215
|
+
height,
|
|
1216
|
+
top,
|
|
1217
|
+
left
|
|
1215
1218
|
} = size;
|
|
1216
1219
|
const aspect = width / height;
|
|
1217
1220
|
if (target instanceof THREE__namespace.Vector3) tempTarget.copy(target);else tempTarget.set(...target);
|
|
@@ -1221,6 +1224,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1221
1224
|
return {
|
|
1222
1225
|
width: width / camera.zoom,
|
|
1223
1226
|
height: height / camera.zoom,
|
|
1227
|
+
top,
|
|
1228
|
+
left,
|
|
1224
1229
|
factor: 1,
|
|
1225
1230
|
distance,
|
|
1226
1231
|
aspect
|
|
@@ -1234,6 +1239,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1234
1239
|
return {
|
|
1235
1240
|
width: w,
|
|
1236
1241
|
height: h,
|
|
1242
|
+
top,
|
|
1243
|
+
left,
|
|
1237
1244
|
factor: width / w,
|
|
1238
1245
|
distance,
|
|
1239
1246
|
aspect
|
|
@@ -1250,7 +1257,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1250
1257
|
}));
|
|
1251
1258
|
|
|
1252
1259
|
const pointer = new THREE__namespace.Vector2();
|
|
1253
|
-
|
|
1260
|
+
const rootState = {
|
|
1254
1261
|
set,
|
|
1255
1262
|
get,
|
|
1256
1263
|
// Mock objects that have to be configured
|
|
@@ -1293,6 +1300,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1293
1300
|
size: {
|
|
1294
1301
|
width: 0,
|
|
1295
1302
|
height: 0,
|
|
1303
|
+
top: 0,
|
|
1304
|
+
left: 0,
|
|
1296
1305
|
updateStyle: false
|
|
1297
1306
|
},
|
|
1298
1307
|
viewport: {
|
|
@@ -1300,6 +1309,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1300
1309
|
dpr: 0,
|
|
1301
1310
|
width: 0,
|
|
1302
1311
|
height: 0,
|
|
1312
|
+
top: 0,
|
|
1313
|
+
left: 0,
|
|
1303
1314
|
aspect: 0,
|
|
1304
1315
|
distance: 0,
|
|
1305
1316
|
factor: 0,
|
|
@@ -1310,11 +1321,13 @@ const createStore = (invalidate, advance) => {
|
|
|
1310
1321
|
...events
|
|
1311
1322
|
}
|
|
1312
1323
|
})),
|
|
1313
|
-
setSize: (width, height, updateStyle) => {
|
|
1324
|
+
setSize: (width, height, updateStyle, top, left) => {
|
|
1314
1325
|
const camera = get().camera;
|
|
1315
1326
|
const size = {
|
|
1316
1327
|
width,
|
|
1317
1328
|
height,
|
|
1329
|
+
top: top || 0,
|
|
1330
|
+
left: left || 0,
|
|
1318
1331
|
updateStyle
|
|
1319
1332
|
};
|
|
1320
1333
|
set(state => ({
|
|
@@ -1388,6 +1401,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1388
1401
|
}
|
|
1389
1402
|
}
|
|
1390
1403
|
};
|
|
1404
|
+
return rootState;
|
|
1391
1405
|
});
|
|
1392
1406
|
const state = rootState.getState();
|
|
1393
1407
|
let oldSize = state.size;
|
|
@@ -1429,15 +1443,17 @@ const createStore = (invalidate, advance) => {
|
|
|
1429
1443
|
};
|
|
1430
1444
|
|
|
1431
1445
|
function createSubs(callback, subs) {
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1434
|
-
|
|
1446
|
+
const sub = {
|
|
1447
|
+
callback
|
|
1448
|
+
};
|
|
1449
|
+
subs.add(sub);
|
|
1450
|
+
return () => void subs.delete(sub);
|
|
1435
1451
|
}
|
|
1436
1452
|
|
|
1437
1453
|
let i;
|
|
1438
|
-
let globalEffects =
|
|
1439
|
-
let globalAfterEffects =
|
|
1440
|
-
let globalTailEffects =
|
|
1454
|
+
let globalEffects = new Set();
|
|
1455
|
+
let globalAfterEffects = new Set();
|
|
1456
|
+
let globalTailEffects = new Set();
|
|
1441
1457
|
/**
|
|
1442
1458
|
* Adds a global render callback which is called each frame.
|
|
1443
1459
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
@@ -1458,7 +1474,9 @@ const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
|
|
|
1458
1474
|
const addTail = callback => createSubs(callback, globalTailEffects);
|
|
1459
1475
|
|
|
1460
1476
|
function run(effects, timestamp) {
|
|
1461
|
-
|
|
1477
|
+
effects.forEach(({
|
|
1478
|
+
callback
|
|
1479
|
+
}) => callback(timestamp));
|
|
1462
1480
|
}
|
|
1463
1481
|
|
|
1464
1482
|
let subscribers;
|
|
@@ -1500,7 +1518,7 @@ function createLoop(roots) {
|
|
|
1500
1518
|
running = true;
|
|
1501
1519
|
repeat = 0; // Run effects
|
|
1502
1520
|
|
|
1503
|
-
if (globalEffects.
|
|
1521
|
+
if (globalEffects.size) run(globalEffects, timestamp); // Render all roots
|
|
1504
1522
|
|
|
1505
1523
|
roots.forEach(root => {
|
|
1506
1524
|
var _state$gl$xr;
|
|
@@ -1512,11 +1530,11 @@ function createLoop(roots) {
|
|
|
1512
1530
|
}
|
|
1513
1531
|
}); // Run after-effects
|
|
1514
1532
|
|
|
1515
|
-
if (globalAfterEffects.
|
|
1533
|
+
if (globalAfterEffects.size) run(globalAfterEffects, timestamp); // Stop the loop if nothing invalidates it
|
|
1516
1534
|
|
|
1517
1535
|
if (repeat === 0) {
|
|
1518
1536
|
// Tail call effects, they are called when rendering stops
|
|
1519
|
-
if (globalTailEffects.
|
|
1537
|
+
if (globalTailEffects.size) run(globalTailEffects, timestamp); // Flag end of operation
|
|
1520
1538
|
|
|
1521
1539
|
running = false;
|
|
1522
1540
|
return cancelAnimationFrame(frame);
|
|
@@ -1695,8 +1713,6 @@ function createRoot(canvas) {
|
|
|
1695
1713
|
let configured = false;
|
|
1696
1714
|
return {
|
|
1697
1715
|
configure(props = {}) {
|
|
1698
|
-
var _canvas$parentElement, _canvas$parentElement2, _canvas$parentElement3, _canvas$parentElement4;
|
|
1699
|
-
|
|
1700
1716
|
let {
|
|
1701
1717
|
gl: glConfig,
|
|
1702
1718
|
size,
|
|
@@ -1765,12 +1781,10 @@ function createRoot(canvas) {
|
|
|
1765
1781
|
|
|
1766
1782
|
|
|
1767
1783
|
const handleSessionChange = () => {
|
|
1768
|
-
const
|
|
1769
|
-
gl.xr.enabled = gl.xr.isPresenting;
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
gl.xr.setAnimationLoop(gl.xr.isPresenting ? handleXRFrame : null);
|
|
1784
|
+
const state = store.getState();
|
|
1785
|
+
state.gl.xr.enabled = state.gl.xr.isPresenting;
|
|
1786
|
+
state.gl.xr.setAnimationLoop(state.gl.xr.isPresenting ? handleXRFrame : null);
|
|
1787
|
+
if (!state.gl.xr.isPresenting) invalidate(state);
|
|
1774
1788
|
}; // WebXR session manager
|
|
1775
1789
|
|
|
1776
1790
|
|
|
@@ -1836,11 +1850,22 @@ function createRoot(canvas) {
|
|
|
1836
1850
|
|
|
1837
1851
|
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr); // Check size, allow it to take on container bounds initially
|
|
1838
1852
|
|
|
1839
|
-
size = size || {
|
|
1840
|
-
width:
|
|
1841
|
-
height:
|
|
1842
|
-
|
|
1843
|
-
|
|
1853
|
+
size = size || (canvas.parentElement ? {
|
|
1854
|
+
width: canvas.parentElement.clientWidth,
|
|
1855
|
+
height: canvas.parentElement.clientHeight,
|
|
1856
|
+
top: canvas.parentElement.clientTop,
|
|
1857
|
+
left: canvas.parentElement.clientLeft
|
|
1858
|
+
} : {
|
|
1859
|
+
width: 0,
|
|
1860
|
+
height: 0,
|
|
1861
|
+
top: 0,
|
|
1862
|
+
left: 0
|
|
1863
|
+
});
|
|
1864
|
+
|
|
1865
|
+
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1866
|
+
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1867
|
+
} // Check frameloop
|
|
1868
|
+
|
|
1844
1869
|
|
|
1845
1870
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop); // Check pointer missed
|
|
1846
1871
|
|
|
@@ -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-0499a96a.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -144,10 +144,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
144
144
|
// This will include the entire THREE namespace by default, users can extend
|
|
145
145
|
// their own elements by using the createRoot API instead
|
|
146
146
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
147
|
-
const [containerRef, {
|
|
148
|
-
width,
|
|
149
|
-
height
|
|
150
|
-
}] = useMeasure__default["default"]({
|
|
147
|
+
const [containerRef, containerRect] = useMeasure__default["default"]({
|
|
151
148
|
scroll: true,
|
|
152
149
|
debounce: {
|
|
153
150
|
scroll: 50,
|
|
@@ -168,7 +165,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
168
165
|
if (error) throw error;
|
|
169
166
|
const root = React__namespace.useRef(null);
|
|
170
167
|
|
|
171
|
-
if (width > 0 && height > 0 && canvas) {
|
|
168
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
172
169
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
173
170
|
root.current.configure({
|
|
174
171
|
gl,
|
|
@@ -183,10 +180,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
183
180
|
performance,
|
|
184
181
|
raycaster,
|
|
185
182
|
camera,
|
|
186
|
-
size:
|
|
187
|
-
width,
|
|
188
|
-
height
|
|
189
|
-
},
|
|
183
|
+
size: containerRect,
|
|
190
184
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
191
185
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
192
186
|
onCreated: state => {
|
|
@@ -241,6 +235,7 @@ exports.addTail = index.addTail;
|
|
|
241
235
|
exports.advance = index.advance;
|
|
242
236
|
exports.applyProps = index.applyProps;
|
|
243
237
|
exports.context = index.context;
|
|
238
|
+
exports.createEvents = index.createEvents;
|
|
244
239
|
exports.createPortal = index.createPortal;
|
|
245
240
|
exports.createRoot = index.createRoot;
|
|
246
241
|
exports.dispose = index.dispose;
|
|
@@ -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-ca47b633.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -144,10 +144,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
144
144
|
// This will include the entire THREE namespace by default, users can extend
|
|
145
145
|
// their own elements by using the createRoot API instead
|
|
146
146
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
147
|
-
const [containerRef, {
|
|
148
|
-
width,
|
|
149
|
-
height
|
|
150
|
-
}] = useMeasure__default["default"]({
|
|
147
|
+
const [containerRef, containerRect] = useMeasure__default["default"]({
|
|
151
148
|
scroll: true,
|
|
152
149
|
debounce: {
|
|
153
150
|
scroll: 50,
|
|
@@ -168,7 +165,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
168
165
|
if (error) throw error;
|
|
169
166
|
const root = React__namespace.useRef(null);
|
|
170
167
|
|
|
171
|
-
if (width > 0 && height > 0 && canvas) {
|
|
168
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
172
169
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
173
170
|
root.current.configure({
|
|
174
171
|
gl,
|
|
@@ -183,10 +180,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
183
180
|
performance,
|
|
184
181
|
raycaster,
|
|
185
182
|
camera,
|
|
186
|
-
size:
|
|
187
|
-
width,
|
|
188
|
-
height
|
|
189
|
-
},
|
|
183
|
+
size: containerRect,
|
|
190
184
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
191
185
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
192
186
|
onCreated: state => {
|
|
@@ -241,6 +235,7 @@ exports.addTail = index.addTail;
|
|
|
241
235
|
exports.advance = index.advance;
|
|
242
236
|
exports.applyProps = index.applyProps;
|
|
243
237
|
exports.context = index.context;
|
|
238
|
+
exports.createEvents = index.createEvents;
|
|
244
239
|
exports.createPortal = index.createPortal;
|
|
245
240
|
exports.createRoot = index.createRoot;
|
|
246
241
|
exports.dispose = index.dispose;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-6279214a.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-6279214a.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';
|
|
@@ -117,10 +117,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
117
117
|
// This will include the entire THREE namespace by default, users can extend
|
|
118
118
|
// their own elements by using the createRoot API instead
|
|
119
119
|
React.useMemo(() => extend(THREE), []);
|
|
120
|
-
const [containerRef, {
|
|
121
|
-
width,
|
|
122
|
-
height
|
|
123
|
-
}] = useMeasure({
|
|
120
|
+
const [containerRef, containerRect] = useMeasure({
|
|
124
121
|
scroll: true,
|
|
125
122
|
debounce: {
|
|
126
123
|
scroll: 50,
|
|
@@ -141,7 +138,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
141
138
|
if (error) throw error;
|
|
142
139
|
const root = React.useRef(null);
|
|
143
140
|
|
|
144
|
-
if (width > 0 && height > 0 && canvas) {
|
|
141
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
145
142
|
if (!root.current) root.current = createRoot(canvas);
|
|
146
143
|
root.current.configure({
|
|
147
144
|
gl,
|
|
@@ -156,10 +153,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
156
153
|
performance,
|
|
157
154
|
raycaster,
|
|
158
155
|
camera,
|
|
159
|
-
size:
|
|
160
|
-
width,
|
|
161
|
-
height
|
|
162
|
-
},
|
|
156
|
+
size: containerRect,
|
|
163
157
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
164
158
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
165
159
|
onCreated: state => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-0499a96a.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -258,10 +258,14 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
258
258
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
259
259
|
const [{
|
|
260
260
|
width,
|
|
261
|
-
height
|
|
261
|
+
height,
|
|
262
|
+
top,
|
|
263
|
+
left
|
|
262
264
|
}, setSize] = React__namespace.useState({
|
|
263
265
|
width: 0,
|
|
264
|
-
height: 0
|
|
266
|
+
height: 0,
|
|
267
|
+
top: 0,
|
|
268
|
+
left: 0
|
|
265
269
|
});
|
|
266
270
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
267
271
|
const [bind, setBind] = React__namespace.useState();
|
|
@@ -280,11 +284,15 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
280
284
|
const onLayout = React__namespace.useCallback(e => {
|
|
281
285
|
const {
|
|
282
286
|
width,
|
|
283
|
-
height
|
|
287
|
+
height,
|
|
288
|
+
x,
|
|
289
|
+
y
|
|
284
290
|
} = e.nativeEvent.layout;
|
|
285
291
|
setSize({
|
|
286
292
|
width,
|
|
287
|
-
height
|
|
293
|
+
height,
|
|
294
|
+
top: y,
|
|
295
|
+
left: x
|
|
288
296
|
});
|
|
289
297
|
}, []); // Called on context create or swap
|
|
290
298
|
// https://github.com/pmndrs/react-three-fiber/pull/2297
|
|
@@ -321,7 +329,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
321
329
|
dpr: reactNative.PixelRatio.get(),
|
|
322
330
|
size: {
|
|
323
331
|
width,
|
|
324
|
-
height
|
|
332
|
+
height,
|
|
333
|
+
top,
|
|
334
|
+
left
|
|
325
335
|
},
|
|
326
336
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
327
337
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-ca47b633.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -258,10 +258,14 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
258
258
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
259
259
|
const [{
|
|
260
260
|
width,
|
|
261
|
-
height
|
|
261
|
+
height,
|
|
262
|
+
top,
|
|
263
|
+
left
|
|
262
264
|
}, setSize] = React__namespace.useState({
|
|
263
265
|
width: 0,
|
|
264
|
-
height: 0
|
|
266
|
+
height: 0,
|
|
267
|
+
top: 0,
|
|
268
|
+
left: 0
|
|
265
269
|
});
|
|
266
270
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
267
271
|
const [bind, setBind] = React__namespace.useState();
|
|
@@ -280,11 +284,15 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
280
284
|
const onLayout = React__namespace.useCallback(e => {
|
|
281
285
|
const {
|
|
282
286
|
width,
|
|
283
|
-
height
|
|
287
|
+
height,
|
|
288
|
+
x,
|
|
289
|
+
y
|
|
284
290
|
} = e.nativeEvent.layout;
|
|
285
291
|
setSize({
|
|
286
292
|
width,
|
|
287
|
-
height
|
|
293
|
+
height,
|
|
294
|
+
top: y,
|
|
295
|
+
left: x
|
|
288
296
|
});
|
|
289
297
|
}, []); // Called on context create or swap
|
|
290
298
|
// https://github.com/pmndrs/react-three-fiber/pull/2297
|
|
@@ -321,7 +329,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
321
329
|
dpr: reactNative.PixelRatio.get(),
|
|
322
330
|
size: {
|
|
323
331
|
width,
|
|
324
|
-
height
|
|
332
|
+
height,
|
|
333
|
+
top,
|
|
334
|
+
left
|
|
325
335
|
},
|
|
326
336
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
327
337
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-
|
|
2
|
-
export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-6279214a.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-6279214a.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';
|
|
@@ -231,10 +231,14 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
231
231
|
React.useMemo(() => extend(THREE), []);
|
|
232
232
|
const [{
|
|
233
233
|
width,
|
|
234
|
-
height
|
|
234
|
+
height,
|
|
235
|
+
top,
|
|
236
|
+
left
|
|
235
237
|
}, setSize] = React.useState({
|
|
236
238
|
width: 0,
|
|
237
|
-
height: 0
|
|
239
|
+
height: 0,
|
|
240
|
+
top: 0,
|
|
241
|
+
left: 0
|
|
238
242
|
});
|
|
239
243
|
const [canvas, setCanvas] = React.useState(null);
|
|
240
244
|
const [bind, setBind] = React.useState();
|
|
@@ -253,11 +257,15 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
253
257
|
const onLayout = React.useCallback(e => {
|
|
254
258
|
const {
|
|
255
259
|
width,
|
|
256
|
-
height
|
|
260
|
+
height,
|
|
261
|
+
x,
|
|
262
|
+
y
|
|
257
263
|
} = e.nativeEvent.layout;
|
|
258
264
|
setSize({
|
|
259
265
|
width,
|
|
260
|
-
height
|
|
266
|
+
height,
|
|
267
|
+
top: y,
|
|
268
|
+
left: x
|
|
261
269
|
});
|
|
262
270
|
}, []); // Called on context create or swap
|
|
263
271
|
// https://github.com/pmndrs/react-three-fiber/pull/2297
|
|
@@ -294,7 +302,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
294
302
|
dpr: PixelRatio.get(),
|
|
295
303
|
size: {
|
|
296
304
|
width,
|
|
297
|
-
height
|
|
305
|
+
height,
|
|
306
|
+
top,
|
|
307
|
+
left
|
|
298
308
|
},
|
|
299
309
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
300
310
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|