@react-three/fiber 8.16.0 → 8.16.1

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 503efc2e: fix: prevent invalidate from piling up frames
8
+
3
9
  ## 8.16.0
4
10
 
5
11
  ### Minor Changes
@@ -1576,6 +1576,7 @@ function render$1(timestamp, state, frame) {
1576
1576
  }
1577
1577
  function createLoop(roots) {
1578
1578
  let running = false;
1579
+ let useFrameInProgress = false;
1579
1580
  let repeat;
1580
1581
  let frame;
1581
1582
  let state;
@@ -1588,6 +1589,7 @@ function createLoop(roots) {
1588
1589
  flushGlobalEffects('before', timestamp);
1589
1590
 
1590
1591
  // Render all roots
1592
+ useFrameInProgress = true;
1591
1593
  for (const root of roots.values()) {
1592
1594
  var _state$gl$xr;
1593
1595
  state = root.store.getState();
@@ -1596,6 +1598,7 @@ function createLoop(roots) {
1596
1598
  repeat += render$1(timestamp, state);
1597
1599
  }
1598
1600
  }
1601
+ useFrameInProgress = false;
1599
1602
 
1600
1603
  // Run after-effects
1601
1604
  flushGlobalEffects('after', timestamp);
@@ -1614,8 +1617,20 @@ function createLoop(roots) {
1614
1617
  var _state$gl$xr2;
1615
1618
  if (!state) return roots.forEach(root => invalidate(root.store.getState(), frames));
1616
1619
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return;
1617
- // Increase frames, do not go higher than 60
1618
- state.internal.frames = Math.min(60, state.internal.frames + frames);
1620
+ if (frames > 1) {
1621
+ // legacy support for people using frames parameters
1622
+ // Increase frames, do not go higher than 60
1623
+ state.internal.frames = Math.min(60, state.internal.frames + frames);
1624
+ } else {
1625
+ if (useFrameInProgress) {
1626
+ //called from within a useFrame, it means the user wants an additional frame
1627
+ state.internal.frames = 2;
1628
+ } else {
1629
+ //the user need a new frame, no need to increment further than 1
1630
+ state.internal.frames = 1;
1631
+ }
1632
+ }
1633
+
1619
1634
  // If the render-loop isn't active, start it
1620
1635
  if (!running) {
1621
1636
  running = true;
@@ -1549,6 +1549,7 @@ function render$1(timestamp, state, frame) {
1549
1549
  }
1550
1550
  function createLoop(roots) {
1551
1551
  let running = false;
1552
+ let useFrameInProgress = false;
1552
1553
  let repeat;
1553
1554
  let frame;
1554
1555
  let state;
@@ -1561,6 +1562,7 @@ function createLoop(roots) {
1561
1562
  flushGlobalEffects('before', timestamp);
1562
1563
 
1563
1564
  // Render all roots
1565
+ useFrameInProgress = true;
1564
1566
  for (const root of roots.values()) {
1565
1567
  var _state$gl$xr;
1566
1568
  state = root.store.getState();
@@ -1569,6 +1571,7 @@ function createLoop(roots) {
1569
1571
  repeat += render$1(timestamp, state);
1570
1572
  }
1571
1573
  }
1574
+ useFrameInProgress = false;
1572
1575
 
1573
1576
  // Run after-effects
1574
1577
  flushGlobalEffects('after', timestamp);
@@ -1587,8 +1590,20 @@ function createLoop(roots) {
1587
1590
  var _state$gl$xr2;
1588
1591
  if (!state) return roots.forEach(root => invalidate(root.store.getState(), frames));
1589
1592
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return;
1590
- // Increase frames, do not go higher than 60
1591
- state.internal.frames = Math.min(60, state.internal.frames + frames);
1593
+ if (frames > 1) {
1594
+ // legacy support for people using frames parameters
1595
+ // Increase frames, do not go higher than 60
1596
+ state.internal.frames = Math.min(60, state.internal.frames + frames);
1597
+ } else {
1598
+ if (useFrameInProgress) {
1599
+ //called from within a useFrame, it means the user wants an additional frame
1600
+ state.internal.frames = 2;
1601
+ } else {
1602
+ //the user need a new frame, no need to increment further than 1
1603
+ state.internal.frames = 1;
1604
+ }
1605
+ }
1606
+
1592
1607
  // If the render-loop isn't active, start it
1593
1608
  if (!running) {
1594
1609
  running = true;
@@ -1576,6 +1576,7 @@ function render$1(timestamp, state, frame) {
1576
1576
  }
1577
1577
  function createLoop(roots) {
1578
1578
  let running = false;
1579
+ let useFrameInProgress = false;
1579
1580
  let repeat;
1580
1581
  let frame;
1581
1582
  let state;
@@ -1588,6 +1589,7 @@ function createLoop(roots) {
1588
1589
  flushGlobalEffects('before', timestamp);
1589
1590
 
1590
1591
  // Render all roots
1592
+ useFrameInProgress = true;
1591
1593
  for (const root of roots.values()) {
1592
1594
  var _state$gl$xr;
1593
1595
  state = root.store.getState();
@@ -1596,6 +1598,7 @@ function createLoop(roots) {
1596
1598
  repeat += render$1(timestamp, state);
1597
1599
  }
1598
1600
  }
1601
+ useFrameInProgress = false;
1599
1602
 
1600
1603
  // Run after-effects
1601
1604
  flushGlobalEffects('after', timestamp);
@@ -1614,8 +1617,20 @@ function createLoop(roots) {
1614
1617
  var _state$gl$xr2;
1615
1618
  if (!state) return roots.forEach(root => invalidate(root.store.getState(), frames));
1616
1619
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return;
1617
- // Increase frames, do not go higher than 60
1618
- state.internal.frames = Math.min(60, state.internal.frames + frames);
1620
+ if (frames > 1) {
1621
+ // legacy support for people using frames parameters
1622
+ // Increase frames, do not go higher than 60
1623
+ state.internal.frames = Math.min(60, state.internal.frames + frames);
1624
+ } else {
1625
+ if (useFrameInProgress) {
1626
+ //called from within a useFrame, it means the user wants an additional frame
1627
+ state.internal.frames = 2;
1628
+ } else {
1629
+ //the user need a new frame, no need to increment further than 1
1630
+ state.internal.frames = 1;
1631
+ }
1632
+ }
1633
+
1619
1634
  // If the render-loop isn't active, start it
1620
1635
  if (!running) {
1621
1636
  running = true;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-a75b61c3.cjs.dev.js');
5
+ var index = require('./index-382d4f47.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-76e11619.cjs.prod.js');
5
+ var index = require('./index-e8d6e828.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-5712f892.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-5712f892.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-d98fd1c7.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-d98fd1c7.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';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-a75b61c3.cjs.dev.js');
5
+ var index = require('../../dist/index-382d4f47.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-76e11619.cjs.prod.js');
5
+ var index = require('../../dist/index-e8d6e828.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-5712f892.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-5712f892.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-d98fd1c7.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-d98fd1c7.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.16.0",
3
+ "version": "8.16.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",