@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.
@@ -71702,6 +71702,14 @@ class EntityManager {
71702
71702
  */
71703
71703
  fixedUpdateStepSize = 0.015;
71704
71704
 
71705
+ /**
71706
+ * How long can any given system run it's fixedUpdate, per simulation update
71707
+ * This is value allows us to avoid cases where fixedUpdate takes longer that its time step and causes a runaway freeze
71708
+ * In milliseconds
71709
+ * @type {number}
71710
+ */
71711
+ fixedUpdatePerSystemExecutionTimeLimit = 15;
71712
+
71705
71713
  /**
71706
71714
  *
71707
71715
  * @type {EntityComponentDataset}
@@ -71923,6 +71931,7 @@ class EntityManager {
71923
71931
  return null;
71924
71932
  }
71925
71933
 
71934
+
71926
71935
  /**
71927
71936
  * Advance simulation forward by a specified amount of time
71928
71937
  * @param {number} timeDelta in seconds
@@ -71952,7 +71961,7 @@ class EntityManager {
71952
71961
  if (system.fixedUpdate !== noop) {
71953
71962
  let accumulated_time = accumulatedTime.get(system) + timeDelta;
71954
71963
 
71955
-
71964
+ const t0 = performance.now();
71956
71965
  while (accumulated_time >= fixed_step) {
71957
71966
 
71958
71967
  try {
@@ -71961,6 +71970,10 @@ class EntityManager {
71961
71970
  }
71962
71971
 
71963
71972
  accumulated_time -= fixed_step;
71973
+
71974
+ if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
71975
+ break;
71976
+ }
71964
71977
  }
71965
71978
 
71966
71979
  // record whatever remains
@@ -72038,9 +72051,9 @@ class EntityManager {
72038
72051
  }
72039
72052
 
72040
72053
  // Link EntityManager
72041
- if(system.entityManager === null){
72054
+ if (system.entityManager === null) {
72042
72055
  system.entityManager = this;
72043
- }else if(system.entityManager !== this){
72056
+ } else if (system.entityManager !== this) {
72044
72057
  throw new Error(`System is bound to another EntityManager`);
72045
72058
  }
72046
72059
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.86.7",
8
+ "version": "2.87.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAkBU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;OAGG;IACH,gCAFU,iCAAQ,CAES;IAE3B;;;OAGG;IACH,0BAFU,cAAc,EAAE,CAEL;IAErB;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;OAIG;IACH,gDAA2C;IAE3C;;;;OAIG;IACH,qBAFU,MAAM,CAEY;IAE5B;;;OAGG;IACH,gCAAe;IAEf;;;;OAIG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BA8EC;IAED,sBAcC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,qDAsBC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAcC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAezB;IAED;;;OAGG;IACH,oBAFW,MAAM,QA6DhB;IAED;;;;;OAKG;IACH,iEA0EC;IAED;;;;OAIG;IACH,uDAFa,QAAQ,OAAO,CAAC,CAyC5B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;;OAKG;IACH,oBAwCC;IAED;;;;OAIG;IACH,gEAwEC;IAED;;;;OAIG;IACH,mCAFa,wCAAgB,CA0B5B;IAED;;;;;OAKG;IACH,8DAFa,wCAAgB,CAsB5B;IAED;;;;OAIG;IACH,iEAkEC;CACJ;uBAtxBsD,aAAa;+BADrC,qBAAqB;mBALjC,oCAAoC"}
1
+ {"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityManager.js"],"names":[],"mappings":";;;wBAkBU,MAAM;;;;;;iCAWN,MAAM;;;;;;;;;AAWhB;IAEI;;;OAGG;IACH,kBAFU,iCAAQ,CAEL;IAEb;;;OAGG;IACH,gCAFU,iCAAQ,CAES;IAE3B;;;OAGG;IACH,0BAFU,cAAc,EAAE,CAEL;IAErB;;OAEG;IACH;;;QAGI;;WAEG;qBADO,uCAAc;;MAI1B;IAEF;;;OAGG;IACH,OAFU,kBAAkB,CAEO;IAEnC;;;;OAIG;IACH,gDAA2C;IAE3C;;;;OAIG;IACH,qBAFU,MAAM,CAEY;IAE5B;;;;;OAKG;IACH,wCAFU,MAAM,CAE4B;IAE5C;;;OAGG;IACH,gCAAe;IAEf;;;;OAIG;IACH,uCAAsC;IAEtC;;;OAGG;IACH,6BA8EC;IAED,sBAcC;IAED;;;OAGG;IACH,uBAFa,OAAO,CAuBnB;IAED;;;;;OAKG;IACH,qDAsBC;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,6CAcC;IAED;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,IAAI,aAAS,CAezB;IAGD;;;OAGG;IACH,oBAFW,MAAM,QAkEhB;IAED;;;;;OAKG;IACH,iEA0EC;IAED;;;;OAIG;IACH,uDAFa,QAAQ,OAAO,CAAC,CAyC5B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;;OAKG;IACH,oBAwCC;IAED;;;;OAIG;IACH,gEAwEC;IAED;;;;OAIG;IACH,mCAFa,wCAAgB,CA0B5B;IAED;;;;;OAKG;IACH,8DAFa,wCAAgB,CAsB5B;IAED;;;;OAIG;IACH,iEAkEC;CACJ;uBApyBsD,aAAa;+BADrC,qBAAqB;mBALjC,oCAAoC"}
@@ -91,6 +91,14 @@ export class EntityManager {
91
91
  */
92
92
  fixedUpdateStepSize = 0.015;
93
93
 
94
+ /**
95
+ * How long can any given system run it's fixedUpdate, per simulation update
96
+ * This is value allows us to avoid cases where fixedUpdate takes longer that its time step and causes a runaway freeze
97
+ * In milliseconds
98
+ * @type {number}
99
+ */
100
+ fixedUpdatePerSystemExecutionTimeLimit = 15;
101
+
94
102
  /**
95
103
  *
96
104
  * @type {EntityComponentDataset}
@@ -312,6 +320,7 @@ export class EntityManager {
312
320
  return null;
313
321
  }
314
322
 
323
+
315
324
  /**
316
325
  * Advance simulation forward by a specified amount of time
317
326
  * @param {number} timeDelta in seconds
@@ -347,7 +356,7 @@ export class EntityManager {
347
356
  if (system.fixedUpdate !== noop) {
348
357
  let accumulated_time = accumulatedTime.get(system) + timeDelta;
349
358
 
350
-
359
+ const t0 = performance.now();
351
360
  while (accumulated_time >= fixed_step) {
352
361
 
353
362
  try {
@@ -357,6 +366,11 @@ export class EntityManager {
357
366
  }
358
367
 
359
368
  accumulated_time -= fixed_step;
369
+
370
+ if (performance.now() - t0 > this.fixedUpdatePerSystemExecutionTimeLimit) {
371
+ console.warn(`.fixedUpdate of system '${computeSystemName(system)}' is falling behind current clock due to slow execution. Retardation is done to avoid severe performance impact.`);
372
+ break;
373
+ }
360
374
  }
361
375
 
362
376
  // record whatever remains
@@ -438,9 +452,9 @@ export class EntityManager {
438
452
  }
439
453
 
440
454
  // Link EntityManager
441
- if(system.entityManager === null){
455
+ if (system.entityManager === null) {
442
456
  system.entityManager = this;
443
- }else if(system.entityManager !== this){
457
+ } else if (system.entityManager !== this) {
444
458
  throw new Error(`System is bound to another EntityManager`);
445
459
  }
446
460