@react-three/fiber 8.2.2 → 9.0.0-alpha.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.
@@ -338,12 +338,7 @@ function applyProps$1(instance, data) {
338
338
 
339
339
  if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
340
340
  else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) targetProp.mask = value.mask; // Otherwise just set ...
341
- else targetProp.set(value); // For versions of three which don't support THREE.ColorManagement,
342
- // Auto-convert sRGB colors
343
- // https://github.com/pmndrs/react-three-fiber/issues/344
344
-
345
- const supportsColorManagement = ('ColorManagement' in THREE);
346
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
341
+ else targetProp.set(value);
347
342
  } // Else, just overwrite the value
348
343
 
349
344
  } else {
@@ -398,15 +393,6 @@ function updateCamera(camera, size) {
398
393
  camera.updateMatrixWorld();
399
394
  }
400
395
  }
401
- /**
402
- * Safely sets a deeply-nested value on an object.
403
- */
404
-
405
- function setDeep(obj, value, keys) {
406
- const key = keys.pop();
407
- const target = keys.reduce((acc, key) => acc[key], obj);
408
- return target[key] = value;
409
- }
410
396
 
411
397
  function makeId(event) {
412
398
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
@@ -1185,6 +1171,7 @@ function createRenderer(_roots, _getEventPriority) {
1185
1171
  };
1186
1172
  }
1187
1173
 
1174
+ // Keys that shouldn't be copied between R3F stores
1188
1175
  const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
1189
1176
  const isRenderer = def => !!(def != null && def.render);
1190
1177
  const context = /*#__PURE__*/React.createContext(null);
@@ -1332,8 +1319,14 @@ const createStore = (invalidate, advance) => {
1332
1319
  }
1333
1320
  };
1334
1321
  }),
1335
- setFrameloop: (frameloop = 'always') => {
1336
- const clock = get().clock; // if frameloop === "never" clock.elapsedTime is updated using advance(timestamp)
1322
+ setFrameloop: frameloop => {
1323
+ var _frameloop$mode, _frameloop$render, _frameloop$maxDelta;
1324
+
1325
+ const state = get();
1326
+ const mode = typeof frameloop === 'string' ? frameloop : (frameloop == null ? void 0 : frameloop.mode) === 'auto' ? 'always' : (_frameloop$mode = frameloop == null ? void 0 : frameloop.mode) != null ? _frameloop$mode : state.frameloop;
1327
+ const render = typeof frameloop === 'string' ? state.internal.render : (_frameloop$render = frameloop == null ? void 0 : frameloop.render) != null ? _frameloop$render : state.internal.render;
1328
+ const maxDelta = typeof frameloop === 'string' ? state.internal.maxDelta : (_frameloop$maxDelta = frameloop == null ? void 0 : frameloop.maxDelta) != null ? _frameloop$maxDelta : state.internal.maxDelta;
1329
+ const clock = state.clock; // if frameloop === "never" clock.elapsedTime is updated using advance(timestamp)
1337
1330
 
1338
1331
  clock.stop();
1339
1332
  clock.elapsedTime = 0;
@@ -1344,28 +1337,44 @@ const createStore = (invalidate, advance) => {
1344
1337
  }
1345
1338
 
1346
1339
  set(() => ({
1347
- frameloop
1340
+ frameloop: mode,
1341
+ internal: { ...state.internal,
1342
+ render,
1343
+ maxDelta
1344
+ }
1348
1345
  }));
1349
1346
  },
1350
1347
  previousRoot: undefined,
1351
1348
  internal: {
1352
- active: false,
1353
- priority: 0,
1354
- frames: 0,
1355
- lastEvent: /*#__PURE__*/React.createRef(),
1349
+ // Events
1356
1350
  interaction: [],
1357
1351
  hovered: new Map(),
1358
1352
  subscribers: [],
1359
1353
  initialClick: [0, 0],
1360
1354
  initialHits: [],
1361
1355
  capturedMap: new Map(),
1356
+ lastEvent: /*#__PURE__*/React.createRef(),
1357
+ // Updates
1358
+ active: false,
1359
+ frames: 0,
1360
+ stages: [],
1361
+ render: 'auto',
1362
+ maxDelta: 1 / 10,
1363
+ priority: 0,
1362
1364
  subscribe: (ref, priority, store) => {
1363
- const internal = get().internal; // If this subscription was given a priority, it takes rendering into its own hands
1365
+ const state = get();
1366
+ const internal = state.internal; // If this subscription was given a priority, it takes rendering into its own hands
1364
1367
  // For that reason we switch off automatic rendering and increase the manual flag
1365
1368
  // As long as this flag is positive there can be no internal rendering at all
1366
1369
  // because there could be multiple render subscriptions
1367
1370
 
1368
- internal.priority = internal.priority + (priority > 0 ? 1 : 0);
1371
+ internal.priority = internal.priority + (priority > 0 ? 1 : 0); // We use the render flag and deprecate priority
1372
+
1373
+ if (internal.priority && state.internal.render === 'auto') set(() => ({
1374
+ internal: { ...state.internal,
1375
+ render: 'manual'
1376
+ }
1377
+ }));
1369
1378
  internal.subscribers.push({
1370
1379
  ref,
1371
1380
  priority,
@@ -1375,11 +1384,18 @@ const createStore = (invalidate, advance) => {
1375
1384
 
1376
1385
  internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
1377
1386
  return () => {
1378
- const internal = get().internal;
1387
+ const state = get();
1388
+ const internal = state.internal;
1379
1389
 
1380
1390
  if (internal != null && internal.subscribers) {
1381
1391
  // Decrease manual flag if this subscription had a priority
1382
- internal.priority = internal.priority - (priority > 0 ? 1 : 0); // Remove subscriber from list
1392
+ internal.priority = internal.priority - (priority > 0 ? 1 : 0); // We use the render flag and deprecate priority
1393
+
1394
+ if (!internal.priority && state.internal.render === 'manual') set(() => ({
1395
+ internal: { ...state.internal,
1396
+ render: 'auto'
1397
+ }
1398
+ })); // Remove subscriber from list
1383
1399
 
1384
1400
  internal.subscribers = internal.subscribers.filter(s => s.ref !== ref);
1385
1401
  }
@@ -1435,8 +1451,6 @@ function createSubs(callback, subs) {
1435
1451
  subs.add(sub);
1436
1452
  return () => void subs.delete(sub);
1437
1453
  }
1438
-
1439
- let i;
1440
1454
  let globalEffects = new Set();
1441
1455
  let globalAfterEffects = new Set();
1442
1456
  let globalTailEffects = new Set();
@@ -1465,10 +1479,7 @@ function run(effects, timestamp) {
1465
1479
  }) => callback(timestamp));
1466
1480
  }
1467
1481
 
1468
- let subscribers;
1469
- let subscription;
1470
-
1471
- function render$1(timestamp, state, frame) {
1482
+ function update(timestamp, state, frame) {
1472
1483
  // Run local effects
1473
1484
  let delta = state.clock.getDelta(); // In frameloop='never' mode, clock times are updated using the provided timestamp
1474
1485
 
@@ -1476,18 +1487,14 @@ function render$1(timestamp, state, frame) {
1476
1487
  delta = timestamp - state.clock.elapsedTime;
1477
1488
  state.clock.oldTime = state.clock.elapsedTime;
1478
1489
  state.clock.elapsedTime = timestamp;
1479
- } // Call subscribers (useFrame)
1490
+ } else {
1491
+ delta = Math.max(Math.min(delta, state.internal.maxDelta), 0);
1492
+ } // Call subscribers (useUpdate)
1480
1493
 
1481
1494
 
1482
- subscribers = state.internal.subscribers;
1483
-
1484
- for (i = 0; i < subscribers.length; i++) {
1485
- subscription = subscribers[i];
1486
- subscription.ref.current(subscription.store.getState(), delta, frame);
1487
- } // Render content
1488
-
1489
-
1490
- if (!state.internal.priority && state.gl.render) state.gl.render(state.scene, state.camera); // Decrease frame count
1495
+ for (const stage of state.internal.stages) {
1496
+ stage.frame(delta, frame);
1497
+ }
1491
1498
 
1492
1499
  state.internal.frames = Math.max(0, state.internal.frames - 1);
1493
1500
  return state.frameloop === 'always' ? 1 : state.internal.frames;
@@ -1512,7 +1519,7 @@ function createLoop(roots) {
1512
1519
  state = root.store.getState(); // If the frameloop is invalidated, do not run another frame
1513
1520
 
1514
1521
  if (state.internal.active && (state.frameloop === 'always' || state.internal.frames > 0) && !((_state$gl$xr = state.gl.xr) != null && _state$gl$xr.isPresenting)) {
1515
- repeat += render$1(timestamp, state);
1522
+ repeat += update(timestamp, state);
1516
1523
  }
1517
1524
  }); // Run after-effects
1518
1525
 
@@ -1543,7 +1550,7 @@ function createLoop(roots) {
1543
1550
 
1544
1551
  function advance(timestamp, runGlobalEffects = true, state, frame) {
1545
1552
  if (runGlobalEffects) run(globalEffects, timestamp);
1546
- if (!state) roots.forEach(root => render$1(timestamp, root.store.getState()));else render$1(timestamp, state, frame);
1553
+ if (!state) roots.forEach(root => update(timestamp, root.store.getState()));else update(timestamp, state, frame);
1547
1554
  if (runGlobalEffects) run(globalAfterEffects, timestamp);
1548
1555
  }
1549
1556
 
@@ -1564,6 +1571,154 @@ function createLoop(roots) {
1564
1571
  };
1565
1572
  }
1566
1573
 
1574
+ /**
1575
+ * Class representing a stage that updates every frame.
1576
+ * Stages are used to build a lifecycle of effects for an app's frameloop.
1577
+ */
1578
+ class Stage {
1579
+ constructor() {
1580
+ this.subscribers = [];
1581
+ this._frameTime = 0;
1582
+ }
1583
+ /**
1584
+ * Executes all callback subscriptions on the stage.
1585
+ * @param delta - Delta time between frame calls.
1586
+ * @param [frame] - The XR frame if it exists.
1587
+ */
1588
+
1589
+
1590
+ frame(delta, frame) {
1591
+ const subs = this.subscribers;
1592
+ const initialTime = performance.now();
1593
+
1594
+ for (let i = 0; i < subs.length; i++) {
1595
+ subs[i].ref.current(subs[i].store.getState(), delta, frame);
1596
+ }
1597
+
1598
+ this._frameTime = performance.now() - initialTime;
1599
+ }
1600
+ /**
1601
+ * Adds a callback subscriber to the stage.
1602
+ * @param ref - The mutable callback reference.
1603
+ * @param store - The store to be used with the callback execution.
1604
+ * @returns A function to remove the subscription.
1605
+ */
1606
+
1607
+
1608
+ add(ref, store) {
1609
+ this.subscribers.push({
1610
+ ref,
1611
+ store
1612
+ });
1613
+ return () => {
1614
+ this.subscribers = this.subscribers.filter(sub => {
1615
+ return sub.ref !== ref;
1616
+ });
1617
+ };
1618
+ }
1619
+
1620
+ get frameTime() {
1621
+ return this._frameTime;
1622
+ }
1623
+
1624
+ } // Using Unity's fixedStep default.
1625
+
1626
+ const FPS_50 = 1 / 50;
1627
+ /**
1628
+ * Class representing a stage that updates every frame at a fixed rate.
1629
+ * @param name - Name of the stage.
1630
+ * @param [fixedStep] - Fixed step rate.
1631
+ * @param [maxSubsteps] - Maximum number of substeps.
1632
+ */
1633
+
1634
+ class FixedStage extends Stage {
1635
+ constructor(fixedStep, maxSubSteps) {
1636
+ super();
1637
+ this._fixedStep = fixedStep != null ? fixedStep : FPS_50;
1638
+ this._maxSubsteps = maxSubSteps != null ? maxSubSteps : 6;
1639
+ this._accumulator = 0;
1640
+ this._alpha = 0;
1641
+ this._fixedFrameTime = 0;
1642
+ this._substepTimes = [];
1643
+ }
1644
+ /**
1645
+ * Executes all callback subscriptions on the stage.
1646
+ * @param delta - Delta time between frame calls.
1647
+ * @param [frame] - The XR frame if it exists.
1648
+ */
1649
+
1650
+
1651
+ frame(delta, frame) {
1652
+ const initialTime = performance.now();
1653
+ let substeps = 0;
1654
+ this._substepTimes = [];
1655
+ this._accumulator += delta;
1656
+
1657
+ while (this._accumulator >= this._fixedStep && substeps < this._maxSubsteps) {
1658
+ this._accumulator -= this._fixedStep;
1659
+ substeps++;
1660
+ super.frame(this._fixedStep, frame);
1661
+
1662
+ this._substepTimes.push(super.frameTime);
1663
+ }
1664
+
1665
+ this._fixedFrameTime = performance.now() - initialTime; // The accumulator will only be larger than the fixed step if we had to
1666
+ // bail early due to hitting the max substep limit or execution time lagging.
1667
+ // In that case, we want to shave off the excess so we don't fall behind next frame.
1668
+
1669
+ this._accumulator = this._accumulator % this._fixedStep;
1670
+ this._alpha = this._accumulator / this._fixedStep;
1671
+ }
1672
+
1673
+ get frameTime() {
1674
+ return this._fixedFrameTime;
1675
+ }
1676
+
1677
+ get substepTimes() {
1678
+ return this._substepTimes;
1679
+ }
1680
+
1681
+ get fixedStep() {
1682
+ return this._fixedStep;
1683
+ }
1684
+
1685
+ set fixedStep(fixedStep) {
1686
+ this._fixedStep = fixedStep;
1687
+ }
1688
+
1689
+ get maxSubsteps() {
1690
+ return this._maxSubsteps;
1691
+ }
1692
+
1693
+ set maxSubsteps(maxSubsteps) {
1694
+ this._maxSubsteps = maxSubsteps;
1695
+ }
1696
+
1697
+ get accumulator() {
1698
+ return this._accumulator;
1699
+ }
1700
+
1701
+ get alpha() {
1702
+ return this._alpha;
1703
+ }
1704
+
1705
+ }
1706
+ const Early = new Stage();
1707
+ const Fixed = new FixedStage();
1708
+ const Update = new Stage();
1709
+ const Late = new Stage();
1710
+ const Render = new Stage();
1711
+ const After = new Stage();
1712
+ const Stages = {
1713
+ Early,
1714
+ Fixed,
1715
+ Update,
1716
+ Late,
1717
+ Render,
1718
+ After
1719
+ };
1720
+ const Lifecycle = [Early, Fixed, Update, Late, Render, After];
1721
+
1567
1722
  function useStore() {
1568
1723
  const store = React.useContext(context);
1569
1724
  if (!store) throw `R3F hooks can only be used within the Canvas component!`;
@@ -1592,6 +1747,21 @@ function useFrame(callback, renderPriority = 0) {
1592
1747
  useIsomorphicLayoutEffect(() => subscribe(ref, renderPriority, store), [renderPriority, subscribe, store]);
1593
1748
  return null;
1594
1749
  }
1750
+ /**
1751
+ * Executes a callback in a given update stage.
1752
+ * Uses the stage instance to indetify which stage to target in the lifecycle.
1753
+ */
1754
+
1755
+ function useUpdate(callback, stage = Stages.Update) {
1756
+ const store = useStore();
1757
+ const stages = store.getState().internal.stages; // Memoize ref
1758
+
1759
+ const ref = useMutableCallback(callback); // Throw an error if a stage does not exist in the lifecycle
1760
+
1761
+ if (!stages.includes(stage)) throw new Error(`An invoked stage does not exist in the lifecycle.`); // Subscribe on mount, unsubscribe on unmount
1762
+
1763
+ useIsomorphicLayoutEffect(() => stage.add(ref, store), [stage]);
1764
+ }
1595
1765
  /**
1596
1766
  * Returns a node graph of an object with named nodes & materials.
1597
1767
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
@@ -1673,6 +1843,43 @@ const createRendererInstance = (gl, canvas) => {
1673
1843
  });
1674
1844
  };
1675
1845
 
1846
+ const createStages = (stages, store) => {
1847
+ var _stages;
1848
+
1849
+ const state = store.getState();
1850
+ let subscribers;
1851
+ let subscription;
1852
+ stages = (_stages = stages) != null ? _stages : Lifecycle;
1853
+ if (!stages.includes(Stages.Update)) throw 'The Stages.Update stage is required for R3F.';
1854
+ if (!stages.includes(Stages.Render)) throw 'The Stages.Render stage is required for R3F.';
1855
+ state.set(({
1856
+ internal
1857
+ }) => ({
1858
+ internal: { ...internal,
1859
+ stages: stages
1860
+ }
1861
+ })); // Add useFrame loop to update stage
1862
+
1863
+ const frameCallback = {
1864
+ current: (state, delta, frame) => {
1865
+ subscribers = state.internal.subscribers;
1866
+
1867
+ for (let i = 0; i < subscribers.length; i++) {
1868
+ subscription = subscribers[i];
1869
+ subscription.ref.current(subscription.store.getState(), delta, frame);
1870
+ }
1871
+ }
1872
+ };
1873
+ Stages.Update.add(frameCallback, store); // Add render callback to render stage
1874
+
1875
+ const renderCallback = {
1876
+ current: state => {
1877
+ if (state.internal.render === 'auto' && state.gl.render) state.gl.render(state.scene, state.camera);
1878
+ }
1879
+ };
1880
+ Stages.Render.add(renderCallback, store);
1881
+ };
1882
+
1676
1883
  function createRoot(canvas) {
1677
1884
  // Check against mistaken use of createRoot
1678
1885
  let prevRoot = roots.get(canvas);
@@ -1714,7 +1921,8 @@ function createRoot(canvas) {
1714
1921
  performance,
1715
1922
  raycaster: raycastOptions,
1716
1923
  camera: cameraOptions,
1717
- onPointerMissed
1924
+ onPointerMissed,
1925
+ stages
1718
1926
  } = props;
1719
1927
  let state = store.getState(); // Set up renderer (one time only!)
1720
1928
 
@@ -1805,14 +2013,8 @@ function createRoot(canvas) {
1805
2013
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE.PCFSoftShadowMap;
1806
2014
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1807
2015
  }
1808
- } // Safely set color management if available.
1809
- // Avoid accessing THREE.ColorManagement to play nice with older versions
1810
-
1811
-
1812
- if ('ColorManagement' in THREE) {
1813
- setDeep(THREE, legacy, ['ColorManagement', 'legacyMode']);
1814
- }
1815
-
2016
+ } // Set color management
2017
+ THREE.ColorManagement.legacyMode = legacy;
1816
2018
  const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
1817
2019
  const toneMapping = flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
1818
2020
  if (gl.outputEncoding !== outputEncoding) gl.outputEncoding = outputEncoding;
@@ -1863,7 +2065,9 @@ function createRoot(canvas) {
1863
2065
  performance: { ...state.performance,
1864
2066
  ...performance
1865
2067
  }
1866
- })); // Set locals
2068
+ })); // Create update stages.
2069
+
2070
+ if (stages !== state.internal.stages) createStages(stages, store); // Set locals
1867
2071
 
1868
2072
  onCreated = onCreatedCallback;
1869
2073
  configured = true;
@@ -2075,4 +2279,4 @@ reconciler.injectIntoDevTools({
2075
2279
  });
2076
2280
  const act = React.unstable_act;
2077
2281
 
2078
- export { Block as B, ErrorBoundary as E, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, applyProps as i, dispose as j, invalidate as k, advance as l, addEffect as m, addAfterEffect as n, addTail as o, getRootState as p, act as q, render as r, roots as s, threeTypes as t, useMutableCallback as u, useStore as v, useThree as w, useFrame as x, useGraph as y, useLoader as z };
2282
+ export { useGraph as A, Block as B, useLoader as C, ErrorBoundary as E, FixedStage as F, Stage as S, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, Stages as f, context as g, createPortal as h, reconciler as i, applyProps as j, dispose as k, invalidate as l, advance as m, addEffect as n, addAfterEffect as o, addTail as p, getRootState as q, render as r, act as s, threeTypes as t, useMutableCallback as u, roots as v, useStore as w, useThree as x, useFrame as y, useUpdate as z };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-2a5b06d3.cjs.dev.js');
5
+ var index = require('./index-b3be5a63.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -138,6 +138,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
138
138
  camera,
139
139
  onPointerMissed,
140
140
  onCreated,
141
+ stages,
141
142
  ...props
142
143
  }, forwardedRef) {
143
144
  // Create a known catalogue of Threejs-native elements
@@ -180,6 +181,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
180
181
  performance,
181
182
  raycaster,
182
183
  camera,
184
+ stages,
183
185
  size: containerRect,
184
186
  // Pass mutable reference to onPointerMissed so it's free to update
185
187
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
@@ -226,7 +228,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
226
228
  }, fallback)));
227
229
  });
228
230
 
231
+ exports.FixedStage = index.FixedStage;
229
232
  exports.ReactThreeFiber = index.threeTypes;
233
+ exports.Stage = index.Stage;
234
+ exports.Stages = index.Stages;
230
235
  exports._roots = index.roots;
231
236
  exports.act = index.act;
232
237
  exports.addAfterEffect = index.addAfterEffect;
@@ -250,5 +255,6 @@ exports.useGraph = index.useGraph;
250
255
  exports.useLoader = index.useLoader;
251
256
  exports.useStore = index.useStore;
252
257
  exports.useThree = index.useThree;
258
+ exports.useUpdate = index.useUpdate;
253
259
  exports.Canvas = Canvas;
254
260
  exports.events = createPointerEvents;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-876a6569.cjs.prod.js');
5
+ var index = require('./index-b12f488b.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -138,6 +138,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
138
138
  camera,
139
139
  onPointerMissed,
140
140
  onCreated,
141
+ stages,
141
142
  ...props
142
143
  }, forwardedRef) {
143
144
  // Create a known catalogue of Threejs-native elements
@@ -180,6 +181,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
180
181
  performance,
181
182
  raycaster,
182
183
  camera,
184
+ stages,
183
185
  size: containerRect,
184
186
  // Pass mutable reference to onPointerMissed so it's free to update
185
187
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
@@ -226,7 +228,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
226
228
  }, fallback)));
227
229
  });
228
230
 
231
+ exports.FixedStage = index.FixedStage;
229
232
  exports.ReactThreeFiber = index.threeTypes;
233
+ exports.Stage = index.Stage;
234
+ exports.Stages = index.Stages;
230
235
  exports._roots = index.roots;
231
236
  exports.act = index.act;
232
237
  exports.addAfterEffect = index.addAfterEffect;
@@ -250,5 +255,6 @@ exports.useGraph = index.useGraph;
250
255
  exports.useLoader = index.useLoader;
251
256
  exports.useStore = index.useStore;
252
257
  exports.useThree = index.useThree;
258
+ exports.useUpdate = index.useUpdate;
253
259
  exports.Canvas = Canvas;
254
260
  exports.events = createPointerEvents;
@@ -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-af244448.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-af244448.esm.js';
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-e27d4a05.esm.js';
2
+ export { F as FixedStage, t as ReactThreeFiber, S as Stage, f as Stages, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, g as context, c as createEvents, h as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, i as reconciler, r as render, d as unmountComponentAtNode, y as useFrame, A as useGraph, C as useLoader, w as useStore, x as useThree, z as useUpdate } from './index-e27d4a05.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';
@@ -111,6 +111,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
111
111
  camera,
112
112
  onPointerMissed,
113
113
  onCreated,
114
+ stages,
114
115
  ...props
115
116
  }, forwardedRef) {
116
117
  // Create a known catalogue of Threejs-native elements
@@ -153,6 +154,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
153
154
  performance,
154
155
  raycaster,
155
156
  camera,
157
+ stages,
156
158
  size: containerRect,
157
159
  // Pass mutable reference to onPointerMissed so it's free to update
158
160
  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-2a5b06d3.cjs.dev.js');
5
+ var index = require('../../dist/index-b3be5a63.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -250,6 +250,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
250
250
  camera,
251
251
  onPointerMissed,
252
252
  onCreated,
253
+ stages,
253
254
  ...props
254
255
  }, forwardedRef) => {
255
256
  // Create a known catalogue of Threejs-native elements
@@ -324,6 +325,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
324
325
  performance,
325
326
  raycaster,
326
327
  camera,
328
+ stages,
327
329
  // expo-gl can only render at native dpr/resolution
328
330
  // https://github.com/expo/expo-three/issues/39
329
331
  dpr: reactNative.PixelRatio.get(),
@@ -402,5 +404,6 @@ exports.useGraph = index.useGraph;
402
404
  exports.useLoader = index.useLoader;
403
405
  exports.useStore = index.useStore;
404
406
  exports.useThree = index.useThree;
407
+ exports.useUpdate = index.useUpdate;
405
408
  exports.Canvas = Canvas;
406
409
  exports.events = createTouchEvents;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-876a6569.cjs.prod.js');
5
+ var index = require('../../dist/index-b12f488b.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -250,6 +250,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
250
250
  camera,
251
251
  onPointerMissed,
252
252
  onCreated,
253
+ stages,
253
254
  ...props
254
255
  }, forwardedRef) => {
255
256
  // Create a known catalogue of Threejs-native elements
@@ -324,6 +325,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
324
325
  performance,
325
326
  raycaster,
326
327
  camera,
328
+ stages,
327
329
  // expo-gl can only render at native dpr/resolution
328
330
  // https://github.com/expo/expo-three/issues/39
329
331
  dpr: reactNative.PixelRatio.get(),
@@ -402,5 +404,6 @@ exports.useGraph = index.useGraph;
402
404
  exports.useLoader = index.useLoader;
403
405
  exports.useStore = index.useStore;
404
406
  exports.useThree = index.useThree;
407
+ exports.useUpdate = index.useUpdate;
405
408
  exports.Canvas = Canvas;
406
409
  exports.events = createTouchEvents;
@@ -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-af244448.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-af244448.esm.js';
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-e27d4a05.esm.js';
2
+ export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, g as context, h as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, i as reconciler, r as render, d as unmountComponentAtNode, y as useFrame, A as useGraph, C as useLoader, w as useStore, x as useThree, z as useUpdate } from '../../dist/index-e27d4a05.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';
@@ -223,6 +223,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
223
223
  camera,
224
224
  onPointerMissed,
225
225
  onCreated,
226
+ stages,
226
227
  ...props
227
228
  }, forwardedRef) => {
228
229
  // Create a known catalogue of Threejs-native elements
@@ -297,6 +298,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
297
298
  performance,
298
299
  raycaster,
299
300
  camera,
301
+ stages,
300
302
  // expo-gl can only render at native dpr/resolution
301
303
  // https://github.com/expo/expo-three/issues/39
302
304
  dpr: PixelRatio.get(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.2.2",
3
+ "version": "9.0.0-alpha.0",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -51,13 +51,13 @@
51
51
  "zustand": "^3.7.1"
52
52
  },
53
53
  "peerDependencies": {
54
- "expo": ">=43.0",
55
- "expo-asset": ">=8.4",
56
- "expo-gl": ">=11.0",
54
+ "expo": ">=46.0",
55
+ "expo-asset": ">=8.6",
56
+ "expo-gl": ">=11.4",
57
57
  "react": ">=18.0",
58
58
  "react-dom": ">=18.0",
59
- "react-native": ">=0.64",
60
- "three": ">=0.133"
59
+ "react-native": ">=0.69",
60
+ "three": ">=0.141"
61
61
  },
62
62
  "peerDependenciesMeta": {
63
63
  "react-dom": {