@react-three/fiber 8.15.16 → 8.15.18

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +938 -925
  2. package/dist/declarations/src/core/events.d.ts +93 -93
  3. package/dist/declarations/src/core/hooks.d.ts +57 -57
  4. package/dist/declarations/src/core/index.d.ts +87 -87
  5. package/dist/declarations/src/core/loop.d.ts +33 -33
  6. package/dist/declarations/src/core/renderer.d.ts +58 -58
  7. package/dist/declarations/src/core/store.d.ts +137 -137
  8. package/dist/declarations/src/core/utils.d.ts +131 -130
  9. package/dist/declarations/src/index.d.ts +12 -12
  10. package/dist/declarations/src/native/Canvas.d.ts +14 -14
  11. package/dist/declarations/src/native/events.d.ts +5 -5
  12. package/dist/declarations/src/native/polyfills.d.ts +1 -1
  13. package/dist/declarations/src/native.d.ts +12 -12
  14. package/dist/declarations/src/three-types.d.ts +393 -392
  15. package/dist/declarations/src/web/Canvas.d.ts +24 -24
  16. package/dist/declarations/src/web/events.d.ts +5 -5
  17. package/dist/{index-e6d94d30.cjs.dev.js → index-a6803957.cjs.dev.js} +87 -86
  18. package/dist/{index-f0ac6f0d.cjs.prod.js → index-c05f375c.cjs.prod.js} +87 -86
  19. package/dist/{index-8afac004.esm.js → index-e23db861.esm.js} +87 -86
  20. package/dist/react-three-fiber.cjs.dev.js +4 -4
  21. package/dist/react-three-fiber.cjs.prod.js +4 -4
  22. package/dist/react-three-fiber.esm.js +5 -5
  23. package/native/dist/react-three-fiber-native.cjs.dev.js +7 -7
  24. package/native/dist/react-three-fiber-native.cjs.prod.js +7 -7
  25. package/native/dist/react-three-fiber-native.esm.js +8 -8
  26. package/native/package.json +5 -5
  27. package/package.json +1 -1
  28. package/readme.md +253 -253
@@ -382,12 +382,12 @@ function createRenderer(_roots, _getEventPriority) {
382
382
  }
383
383
 
384
384
  var _window$document, _window$navigator;
385
- /**
386
- * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
385
+ /**
386
+ * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
387
387
  */
388
388
  const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
389
- /**
390
- * The current THREE.ColorManagement instance, if present.
389
+ /**
390
+ * The current THREE.ColorManagement instance, if present.
391
391
  */
392
392
  const getColorManagement = () => {
393
393
  var _ColorManagement;
@@ -396,14 +396,14 @@ const getColorManagement = () => {
396
396
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
397
397
  const isRef = obj => obj && obj.hasOwnProperty('current');
398
398
 
399
- /**
400
- * An SSR-friendly useLayoutEffect.
401
- *
402
- * React currently throws a warning when using useLayoutEffect on the server.
403
- * To get around it, we can conditionally useEffect on the server (no-op) and
404
- * useLayoutEffect elsewhere.
405
- *
406
- * @see https://github.com/facebook/react/issues/14927
399
+ /**
400
+ * An SSR-friendly useLayoutEffect.
401
+ *
402
+ * React currently throws a warning when using useLayoutEffect on the server.
403
+ * To get around it, we can conditionally useEffect on the server (no-op) and
404
+ * useLayoutEffect elsewhere.
405
+ *
406
+ * @see https://github.com/facebook/react/issues/14927
407
407
  */
408
408
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
409
409
  function useMutableCallback(fn) {
@@ -448,16 +448,16 @@ function calculateDpr(dpr) {
448
448
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
449
449
  }
450
450
 
451
- /**
452
- * Returns instance root state
451
+ /**
452
+ * Returns instance root state
453
453
  */
454
454
  const getRootState = obj => {
455
455
  var _r3f;
456
456
  return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
457
457
  };
458
458
 
459
- /**
460
- * Returns the instances initial (outmost) root
459
+ /**
460
+ * Returns the instances initial (outmost) root
461
461
  */
462
462
  function findInitialRoot(child) {
463
463
  let root = child.__r3f.root;
@@ -514,8 +514,8 @@ const is = {
514
514
  }
515
515
  };
516
516
 
517
- /**
518
- * Collects nodes and materials from a THREE.Object3D.
517
+ /**
518
+ * Collects nodes and materials from a THREE.Object3D.
519
519
  */
520
520
  function buildGraph(object) {
521
521
  const data = {
@@ -857,9 +857,9 @@ function getEventPriority() {
857
857
  }
858
858
  }
859
859
 
860
- /**
861
- * Release pointer captures.
862
- * This is called by releasePointerCapture in the API, and when an object is removed.
860
+ /**
861
+ * Release pointer captures.
862
+ * This is called by releasePointerCapture in the API, and when an object is removed.
863
863
  */
864
864
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
865
865
  const captureData = captures.get(obj);
@@ -1194,19 +1194,19 @@ function createEvents(store) {
1194
1194
  // Check presence of handlers
1195
1195
  if (!(instance != null && instance.eventCount)) return;
1196
1196
 
1197
- /*
1198
- MAYBE TODO, DELETE IF NOT:
1199
- Check if the object is captured, captured events should not have intersects running in parallel
1200
- But wouldn't it be better to just replace capturedMap with a single entry?
1201
- Also, are we OK with straight up making picking up multiple objects impossible?
1202
-
1203
- const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
1204
- if (pointerId !== undefined) {
1205
- const capturedMeshSet = internal.capturedMap.get(pointerId)
1206
- if (capturedMeshSet) {
1207
- const captured = capturedMeshSet.get(eventObject)
1208
- if (captured && captured.localState.stopped) return
1209
- }
1197
+ /*
1198
+ MAYBE TODO, DELETE IF NOT:
1199
+ Check if the object is captured, captured events should not have intersects running in parallel
1200
+ But wouldn't it be better to just replace capturedMap with a single entry?
1201
+ Also, are we OK with straight up making picking up multiple objects impossible?
1202
+
1203
+ const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
1204
+ if (pointerId !== undefined) {
1205
+ const capturedMeshSet = internal.capturedMap.get(pointerId)
1206
+ if (capturedMeshSet) {
1207
+ const captured = capturedMeshSet.get(eventObject)
1208
+ if (captured && captured.localState.stopped) return
1209
+ }
1210
1210
  }*/
1211
1211
 
1212
1212
  if (isPointerMove) {
@@ -1512,21 +1512,21 @@ let globalEffects = new Set();
1512
1512
  let globalAfterEffects = new Set();
1513
1513
  let globalTailEffects = new Set();
1514
1514
 
1515
- /**
1516
- * Adds a global render callback which is called each frame.
1517
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1515
+ /**
1516
+ * Adds a global render callback which is called each frame.
1517
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1518
1518
  */
1519
1519
  const addEffect = callback => createSubs(callback, globalEffects);
1520
1520
 
1521
- /**
1522
- * Adds a global after-render callback which is called each frame.
1523
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1521
+ /**
1522
+ * Adds a global after-render callback which is called each frame.
1523
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1524
1524
  */
1525
1525
  const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
1526
1526
 
1527
- /**
1528
- * Adds a global callback which is called when rendering stops.
1529
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1527
+ /**
1528
+ * Adds a global callback which is called when rendering stops.
1529
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1530
1530
  */
1531
1531
  const addTail = callback => createSubs(callback, globalTailEffects);
1532
1532
  function run(effects, timestamp) {
@@ -1608,7 +1608,7 @@ function createLoop(roots) {
1608
1608
  }
1609
1609
  function invalidate(state, frames = 1) {
1610
1610
  var _state$gl$xr2;
1611
- if (!state) return roots.forEach(root => invalidate(root.store.getState()), frames);
1611
+ if (!state) return roots.forEach(root => invalidate(root.store.getState(), frames));
1612
1612
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return;
1613
1613
  // Increase frames, do not go higher than 60
1614
1614
  state.internal.frames = Math.min(60, state.internal.frames + frames);
@@ -1625,24 +1625,24 @@ function createLoop(roots) {
1625
1625
  }
1626
1626
  return {
1627
1627
  loop,
1628
- /**
1629
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
1630
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1628
+ /**
1629
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
1630
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1631
1631
  */
1632
1632
  invalidate,
1633
- /**
1634
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
1635
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1633
+ /**
1634
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
1635
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1636
1636
  */
1637
1637
  advance
1638
1638
  };
1639
1639
  }
1640
1640
 
1641
- /**
1642
- * Exposes an object's {@link LocalState}.
1643
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1644
- *
1645
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1641
+ /**
1642
+ * Exposes an object's {@link LocalState}.
1643
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1644
+ *
1645
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1646
1646
  */
1647
1647
  function useInstanceHandle(ref) {
1648
1648
  const instance = React__namespace.useRef(null);
@@ -1655,18 +1655,18 @@ function useStore() {
1655
1655
  return store;
1656
1656
  }
1657
1657
 
1658
- /**
1659
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1660
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1658
+ /**
1659
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1660
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1661
1661
  */
1662
1662
  function useThree(selector = state => state, equalityFn) {
1663
1663
  return useStore()(selector, equalityFn);
1664
1664
  }
1665
1665
 
1666
- /**
1667
- * Executes a callback before render in a shared frame loop.
1668
- * Can order effects with render priority or manually render with a positive priority.
1669
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1666
+ /**
1667
+ * Executes a callback before render in a shared frame loop.
1668
+ * Can order effects with render priority or manually render with a positive priority.
1669
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1670
1670
  */
1671
1671
  function useFrame(callback, renderPriority = 0) {
1672
1672
  const store = useStore();
@@ -1678,9 +1678,9 @@ function useFrame(callback, renderPriority = 0) {
1678
1678
  return null;
1679
1679
  }
1680
1680
 
1681
- /**
1682
- * Returns a node graph of an object with named nodes & materials.
1683
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1681
+ /**
1682
+ * Returns a node graph of an object with named nodes & materials.
1683
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1684
1684
  */
1685
1685
  function useGraph(object) {
1686
1686
  return React__namespace.useMemo(() => buildGraph(object), [object]);
@@ -1702,11 +1702,11 @@ function loadingFn(extensions, onProgress) {
1702
1702
  }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1703
1703
  };
1704
1704
  }
1705
- /**
1706
- * Synchronously loads and caches assets with a three loader.
1707
- *
1708
- * Note: this hook's caller must be wrapped with `React.Suspense`
1709
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1705
+ /**
1706
+ * Synchronously loads and caches assets with a three loader.
1707
+ *
1708
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1709
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1710
1710
  */
1711
1711
  function useLoader(Proto, input, extensions, onProgress) {
1712
1712
  // Use suspense to load async assets
@@ -1718,16 +1718,16 @@ function useLoader(Proto, input, extensions, onProgress) {
1718
1718
  return Array.isArray(input) ? results : results[0];
1719
1719
  }
1720
1720
 
1721
- /**
1722
- * Preloads an asset into cache as a side-effect.
1721
+ /**
1722
+ * Preloads an asset into cache as a side-effect.
1723
1723
  */
1724
1724
  useLoader.preload = function (Proto, input, extensions) {
1725
1725
  const keys = Array.isArray(input) ? input : [input];
1726
1726
  return suspendReact.preload(loadingFn(extensions), [Proto, ...keys]);
1727
1727
  };
1728
1728
 
1729
- /**
1730
- * Removes a loaded asset from cache.
1729
+ /**
1730
+ * Removes a loaded asset from cache.
1731
1731
  */
1732
1732
  useLoader.clear = function (Proto, input) {
1733
1733
  const keys = Array.isArray(input) ? input : [input];
@@ -1984,14 +1984,15 @@ function createRoot(canvas) {
1984
1984
  if (ColorManagement) {
1985
1985
  if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
1986
1986
  }
1987
-
1988
- // Set color space and tonemapping preferences
1989
- const LinearEncoding = 3000;
1990
- const sRGBEncoding = 3001;
1991
- applyProps(gl, {
1992
- outputEncoding: linear ? LinearEncoding : sRGBEncoding,
1993
- toneMapping: flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping
1994
- });
1987
+ if (!configured) {
1988
+ // Set color space and tonemapping preferences, once
1989
+ const LinearEncoding = 3000;
1990
+ const sRGBEncoding = 3001;
1991
+ applyProps(gl, {
1992
+ outputEncoding: linear ? LinearEncoding : sRGBEncoding,
1993
+ toneMapping: flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping
1994
+ });
1995
+ }
1995
1996
 
1996
1997
  // Update color management state
1997
1998
  if (state.legacy !== legacy) state.set(() => ({
@@ -2123,10 +2124,10 @@ function Portal({
2123
2124
  children,
2124
2125
  container
2125
2126
  }) {
2126
- /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2127
- * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2128
- * the "R3F hooks can only be used within the Canvas component!" warning:
2129
- * <Canvas>
2127
+ /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2128
+ * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2129
+ * the "R3F hooks can only be used within the Canvas component!" warning:
2130
+ * <Canvas>
2130
2131
  * {createPortal(...)} */
2131
2132
  const {
2132
2133
  events,
@@ -355,12 +355,12 @@ function createRenderer(_roots, _getEventPriority) {
355
355
  }
356
356
 
357
357
  var _window$document, _window$navigator;
358
- /**
359
- * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
358
+ /**
359
+ * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
360
360
  */
361
361
  const hasColorSpace = object => 'colorSpace' in object || 'outputColorSpace' in object;
362
- /**
363
- * The current THREE.ColorManagement instance, if present.
362
+ /**
363
+ * The current THREE.ColorManagement instance, if present.
364
364
  */
365
365
  const getColorManagement = () => {
366
366
  var _ColorManagement;
@@ -369,14 +369,14 @@ const getColorManagement = () => {
369
369
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
370
370
  const isRef = obj => obj && obj.hasOwnProperty('current');
371
371
 
372
- /**
373
- * An SSR-friendly useLayoutEffect.
374
- *
375
- * React currently throws a warning when using useLayoutEffect on the server.
376
- * To get around it, we can conditionally useEffect on the server (no-op) and
377
- * useLayoutEffect elsewhere.
378
- *
379
- * @see https://github.com/facebook/react/issues/14927
372
+ /**
373
+ * An SSR-friendly useLayoutEffect.
374
+ *
375
+ * React currently throws a warning when using useLayoutEffect on the server.
376
+ * To get around it, we can conditionally useEffect on the server (no-op) and
377
+ * useLayoutEffect elsewhere.
378
+ *
379
+ * @see https://github.com/facebook/react/issues/14927
380
380
  */
381
381
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React.useLayoutEffect : React.useEffect;
382
382
  function useMutableCallback(fn) {
@@ -421,16 +421,16 @@ function calculateDpr(dpr) {
421
421
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
422
422
  }
423
423
 
424
- /**
425
- * Returns instance root state
424
+ /**
425
+ * Returns instance root state
426
426
  */
427
427
  const getRootState = obj => {
428
428
  var _r3f;
429
429
  return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
430
430
  };
431
431
 
432
- /**
433
- * Returns the instances initial (outmost) root
432
+ /**
433
+ * Returns the instances initial (outmost) root
434
434
  */
435
435
  function findInitialRoot(child) {
436
436
  let root = child.__r3f.root;
@@ -487,8 +487,8 @@ const is = {
487
487
  }
488
488
  };
489
489
 
490
- /**
491
- * Collects nodes and materials from a THREE.Object3D.
490
+ /**
491
+ * Collects nodes and materials from a THREE.Object3D.
492
492
  */
493
493
  function buildGraph(object) {
494
494
  const data = {
@@ -830,9 +830,9 @@ function getEventPriority() {
830
830
  }
831
831
  }
832
832
 
833
- /**
834
- * Release pointer captures.
835
- * This is called by releasePointerCapture in the API, and when an object is removed.
833
+ /**
834
+ * Release pointer captures.
835
+ * This is called by releasePointerCapture in the API, and when an object is removed.
836
836
  */
837
837
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
838
838
  const captureData = captures.get(obj);
@@ -1167,19 +1167,19 @@ function createEvents(store) {
1167
1167
  // Check presence of handlers
1168
1168
  if (!(instance != null && instance.eventCount)) return;
1169
1169
 
1170
- /*
1171
- MAYBE TODO, DELETE IF NOT:
1172
- Check if the object is captured, captured events should not have intersects running in parallel
1173
- But wouldn't it be better to just replace capturedMap with a single entry?
1174
- Also, are we OK with straight up making picking up multiple objects impossible?
1175
-
1176
- const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
1177
- if (pointerId !== undefined) {
1178
- const capturedMeshSet = internal.capturedMap.get(pointerId)
1179
- if (capturedMeshSet) {
1180
- const captured = capturedMeshSet.get(eventObject)
1181
- if (captured && captured.localState.stopped) return
1182
- }
1170
+ /*
1171
+ MAYBE TODO, DELETE IF NOT:
1172
+ Check if the object is captured, captured events should not have intersects running in parallel
1173
+ But wouldn't it be better to just replace capturedMap with a single entry?
1174
+ Also, are we OK with straight up making picking up multiple objects impossible?
1175
+
1176
+ const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
1177
+ if (pointerId !== undefined) {
1178
+ const capturedMeshSet = internal.capturedMap.get(pointerId)
1179
+ if (capturedMeshSet) {
1180
+ const captured = capturedMeshSet.get(eventObject)
1181
+ if (captured && captured.localState.stopped) return
1182
+ }
1183
1183
  }*/
1184
1184
 
1185
1185
  if (isPointerMove) {
@@ -1485,21 +1485,21 @@ let globalEffects = new Set();
1485
1485
  let globalAfterEffects = new Set();
1486
1486
  let globalTailEffects = new Set();
1487
1487
 
1488
- /**
1489
- * Adds a global render callback which is called each frame.
1490
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1488
+ /**
1489
+ * Adds a global render callback which is called each frame.
1490
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1491
1491
  */
1492
1492
  const addEffect = callback => createSubs(callback, globalEffects);
1493
1493
 
1494
- /**
1495
- * Adds a global after-render callback which is called each frame.
1496
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1494
+ /**
1495
+ * Adds a global after-render callback which is called each frame.
1496
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1497
1497
  */
1498
1498
  const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
1499
1499
 
1500
- /**
1501
- * Adds a global callback which is called when rendering stops.
1502
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1500
+ /**
1501
+ * Adds a global callback which is called when rendering stops.
1502
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1503
1503
  */
1504
1504
  const addTail = callback => createSubs(callback, globalTailEffects);
1505
1505
  function run(effects, timestamp) {
@@ -1581,7 +1581,7 @@ function createLoop(roots) {
1581
1581
  }
1582
1582
  function invalidate(state, frames = 1) {
1583
1583
  var _state$gl$xr2;
1584
- if (!state) return roots.forEach(root => invalidate(root.store.getState()), frames);
1584
+ if (!state) return roots.forEach(root => invalidate(root.store.getState(), frames));
1585
1585
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return;
1586
1586
  // Increase frames, do not go higher than 60
1587
1587
  state.internal.frames = Math.min(60, state.internal.frames + frames);
@@ -1598,24 +1598,24 @@ function createLoop(roots) {
1598
1598
  }
1599
1599
  return {
1600
1600
  loop,
1601
- /**
1602
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
1603
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1601
+ /**
1602
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
1603
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1604
1604
  */
1605
1605
  invalidate,
1606
- /**
1607
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
1608
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1606
+ /**
1607
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
1608
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1609
1609
  */
1610
1610
  advance
1611
1611
  };
1612
1612
  }
1613
1613
 
1614
- /**
1615
- * Exposes an object's {@link LocalState}.
1616
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1617
- *
1618
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1614
+ /**
1615
+ * Exposes an object's {@link LocalState}.
1616
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1617
+ *
1618
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1619
1619
  */
1620
1620
  function useInstanceHandle(ref) {
1621
1621
  const instance = React.useRef(null);
@@ -1628,18 +1628,18 @@ function useStore() {
1628
1628
  return store;
1629
1629
  }
1630
1630
 
1631
- /**
1632
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1633
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1631
+ /**
1632
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1633
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1634
1634
  */
1635
1635
  function useThree(selector = state => state, equalityFn) {
1636
1636
  return useStore()(selector, equalityFn);
1637
1637
  }
1638
1638
 
1639
- /**
1640
- * Executes a callback before render in a shared frame loop.
1641
- * Can order effects with render priority or manually render with a positive priority.
1642
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1639
+ /**
1640
+ * Executes a callback before render in a shared frame loop.
1641
+ * Can order effects with render priority or manually render with a positive priority.
1642
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1643
1643
  */
1644
1644
  function useFrame(callback, renderPriority = 0) {
1645
1645
  const store = useStore();
@@ -1651,9 +1651,9 @@ function useFrame(callback, renderPriority = 0) {
1651
1651
  return null;
1652
1652
  }
1653
1653
 
1654
- /**
1655
- * Returns a node graph of an object with named nodes & materials.
1656
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1654
+ /**
1655
+ * Returns a node graph of an object with named nodes & materials.
1656
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1657
1657
  */
1658
1658
  function useGraph(object) {
1659
1659
  return React.useMemo(() => buildGraph(object), [object]);
@@ -1675,11 +1675,11 @@ function loadingFn(extensions, onProgress) {
1675
1675
  }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1676
1676
  };
1677
1677
  }
1678
- /**
1679
- * Synchronously loads and caches assets with a three loader.
1680
- *
1681
- * Note: this hook's caller must be wrapped with `React.Suspense`
1682
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1678
+ /**
1679
+ * Synchronously loads and caches assets with a three loader.
1680
+ *
1681
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1682
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1683
1683
  */
1684
1684
  function useLoader(Proto, input, extensions, onProgress) {
1685
1685
  // Use suspense to load async assets
@@ -1691,16 +1691,16 @@ function useLoader(Proto, input, extensions, onProgress) {
1691
1691
  return Array.isArray(input) ? results : results[0];
1692
1692
  }
1693
1693
 
1694
- /**
1695
- * Preloads an asset into cache as a side-effect.
1694
+ /**
1695
+ * Preloads an asset into cache as a side-effect.
1696
1696
  */
1697
1697
  useLoader.preload = function (Proto, input, extensions) {
1698
1698
  const keys = Array.isArray(input) ? input : [input];
1699
1699
  return preload(loadingFn(extensions), [Proto, ...keys]);
1700
1700
  };
1701
1701
 
1702
- /**
1703
- * Removes a loaded asset from cache.
1702
+ /**
1703
+ * Removes a loaded asset from cache.
1704
1704
  */
1705
1705
  useLoader.clear = function (Proto, input) {
1706
1706
  const keys = Array.isArray(input) ? input : [input];
@@ -1957,14 +1957,15 @@ function createRoot(canvas) {
1957
1957
  if (ColorManagement) {
1958
1958
  if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
1959
1959
  }
1960
-
1961
- // Set color space and tonemapping preferences
1962
- const LinearEncoding = 3000;
1963
- const sRGBEncoding = 3001;
1964
- applyProps(gl, {
1965
- outputEncoding: linear ? LinearEncoding : sRGBEncoding,
1966
- toneMapping: flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping
1967
- });
1960
+ if (!configured) {
1961
+ // Set color space and tonemapping preferences, once
1962
+ const LinearEncoding = 3000;
1963
+ const sRGBEncoding = 3001;
1964
+ applyProps(gl, {
1965
+ outputEncoding: linear ? LinearEncoding : sRGBEncoding,
1966
+ toneMapping: flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping
1967
+ });
1968
+ }
1968
1969
 
1969
1970
  // Update color management state
1970
1971
  if (state.legacy !== legacy) state.set(() => ({
@@ -2096,10 +2097,10 @@ function Portal({
2096
2097
  children,
2097
2098
  container
2098
2099
  }) {
2099
- /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2100
- * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2101
- * the "R3F hooks can only be used within the Canvas component!" warning:
2102
- * <Canvas>
2100
+ /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2101
+ * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2102
+ * the "R3F hooks can only be used within the Canvas component!" warning:
2103
+ * <Canvas>
2103
2104
  * {createPortal(...)} */
2104
2105
  const {
2105
2106
  events,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-e6d94d30.cjs.dev.js');
5
+ var index = require('./index-a6803957.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -251,9 +251,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
251
251
  }, fallback)));
252
252
  });
253
253
 
254
- /**
255
- * A DOM canvas which accepts threejs elements as children.
256
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
254
+ /**
255
+ * A DOM canvas which accepts threejs elements as children.
256
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
257
257
  */
258
258
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
259
259
  return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-f0ac6f0d.cjs.prod.js');
5
+ var index = require('./index-c05f375c.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -251,9 +251,9 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
251
251
  }, fallback)));
252
252
  });
253
253
 
254
- /**
255
- * A DOM canvas which accepts threejs elements as children.
256
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
254
+ /**
255
+ * A DOM canvas which accepts threejs elements as children.
256
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
257
257
  */
258
258
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
259
259
  return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {