@woosh/meep-engine 2.86.6 → 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
@@ -58331,25 +58331,20 @@ class TerrainTileManager {
58331
58331
 
58332
58332
  const tiles = this.tiles;
58333
58333
 
58334
- const self = this;
58335
-
58336
- function ensureBuilt(x, y) {
58337
- return function (resolve) {
58338
- self.obtain(x, y).then(resolve);
58339
- }
58340
- }
58341
-
58342
58334
  //populate tiles
58343
- for (let y = 0; y < gridSize.y; y++) {
58335
+ const tile_resolution_y = gridSize.y;
58336
+ const tile_resolution_x = gridSize.x;
58344
58337
 
58345
- const tY = y < gridSize.y - 1 ? time_size.y : (total_size.y - time_size.y * y);
58338
+ for (let y = 0; y < tile_resolution_y; y++) {
58346
58339
 
58347
- for (let x = 0; x < gridSize.x; x++) {
58340
+ const tY = y < tile_resolution_y - 1 ? time_size.y : (total_size.y - time_size.y * y);
58348
58341
 
58349
- const tX = x < gridSize.x - 1 ? time_size.x : (total_size.x - time_size.x * x);
58342
+ for (let x = 0; x < tile_resolution_x; x++) {
58343
+
58344
+ const tX = x < tile_resolution_x - 1 ? time_size.x : (total_size.x - time_size.x * x);
58350
58345
 
58351
58346
  const tile = new TerrainTile();
58352
- const index = y * gridSize.x + x;
58347
+ const index = y * tile_resolution_x + x;
58353
58348
  tiles[index] = tile;
58354
58349
 
58355
58350
  this.assignTileMaterial(tile);
@@ -58364,9 +58359,6 @@ class TerrainTileManager {
58364
58359
  tile.setInitialHeightBounds(this.heightRange.min, this.heightRange.max);
58365
58360
  tile.computeBoundingBox();
58366
58361
 
58367
- //hook for building
58368
- tile.ensureBuilt = ensureBuilt(x, y);
58369
-
58370
58362
  tile.external_bvh.link(this.bvh, index);
58371
58363
  }
58372
58364
  }
@@ -71712,6 +71704,14 @@ class EntityManager {
71712
71704
  */
71713
71705
  fixedUpdateStepSize = 0.015;
71714
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
+
71715
71715
  /**
71716
71716
  *
71717
71717
  * @type {EntityComponentDataset}
@@ -71933,6 +71933,7 @@ class EntityManager {
71933
71933
  return null;
71934
71934
  }
71935
71935
 
71936
+
71936
71937
  /**
71937
71938
  * Advance simulation forward by a specified amount of time
71938
71939
  * @param {number} timeDelta in seconds
@@ -71962,7 +71963,7 @@ class EntityManager {
71962
71963
  if (system.fixedUpdate !== noop) {
71963
71964
  let accumulated_time = accumulatedTime.get(system) + timeDelta;
71964
71965
 
71965
-
71966
+ const t0 = performance.now();
71966
71967
  while (accumulated_time >= fixed_step) {
71967
71968
 
71968
71969
  try {
@@ -71971,6 +71972,10 @@ class EntityManager {
71971
71972
  }
71972
71973
 
71973
71974
  accumulated_time -= fixed_step;
71975
+
71976
+ if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
71977
+ break;
71978
+ }
71974
71979
  }
71975
71980
 
71976
71981
  // record whatever remains
@@ -72048,9 +72053,9 @@ class EntityManager {
72048
72053
  }
72049
72054
 
72050
72055
  // Link EntityManager
72051
- if(system.entityManager === null){
72056
+ if (system.entityManager === null) {
72052
72057
  system.entityManager = this;
72053
- }else if(system.entityManager !== this){
72058
+ } else if (system.entityManager !== this) {
72054
72059
  throw new Error(`System is bound to another EntityManager`);
72055
72060
  }
72056
72061