@woosh/meep-engine 2.86.7 → 2.87.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/build/meep.cjs CHANGED
@@ -71704,6 +71704,14 @@ class EntityManager {
71704
71704
  */
71705
71705
  fixedUpdateStepSize = 0.015;
71706
71706
 
71707
+ /**
71708
+ * How long can any given system run it's fixedUpdate, per simulation update
71709
+ * This is value allows us to avoid cases where fixedUpdate takes longer that its time step and causes a runaway freeze
71710
+ * In milliseconds
71711
+ * @type {number}
71712
+ */
71713
+ fixedUpdatePerSystemExecutionTimeLimit = 15;
71714
+
71707
71715
  /**
71708
71716
  *
71709
71717
  * @type {EntityComponentDataset}
@@ -71925,6 +71933,7 @@ class EntityManager {
71925
71933
  return null;
71926
71934
  }
71927
71935
 
71936
+
71928
71937
  /**
71929
71938
  * Advance simulation forward by a specified amount of time
71930
71939
  * @param {number} timeDelta in seconds
@@ -71954,7 +71963,7 @@ class EntityManager {
71954
71963
  if (system.fixedUpdate !== noop) {
71955
71964
  let accumulated_time = accumulatedTime.get(system) + timeDelta;
71956
71965
 
71957
-
71966
+ const t0 = performance.now();
71958
71967
  while (accumulated_time >= fixed_step) {
71959
71968
 
71960
71969
  try {
@@ -71963,6 +71972,10 @@ class EntityManager {
71963
71972
  }
71964
71973
 
71965
71974
  accumulated_time -= fixed_step;
71975
+
71976
+ if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
71977
+ break;
71978
+ }
71966
71979
  }
71967
71980
 
71968
71981
  // record whatever remains
@@ -72040,9 +72053,9 @@ class EntityManager {
72040
72053
  }
72041
72054
 
72042
72055
  // Link EntityManager
72043
- if(system.entityManager === null){
72056
+ if (system.entityManager === null) {
72044
72057
  system.entityManager = this;
72045
- }else if(system.entityManager !== this){
72058
+ } else if (system.entityManager !== this) {
72046
72059
  throw new Error(`System is bound to another EntityManager`);
72047
72060
  }
72048
72061