extra-game-loop 0.2.0 → 0.3.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.
@@ -17469,11 +17469,6 @@
17469
17469
 
17470
17470
  } (es2018$6));
17471
17471
 
17472
- exports.Mode = void 0;
17473
- (function (Mode) {
17474
- Mode[Mode["UpdateFirst"] = 0] = "UpdateFirst";
17475
- Mode[Mode["FixedUpdateFirst"] = 1] = "FixedUpdateFirst";
17476
- })(exports.Mode || (exports.Mode = {}));
17477
17472
  var State;
17478
17473
  (function (State) {
17479
17474
  State["Stopped"] = "stopped";
@@ -17502,16 +17497,10 @@
17502
17497
  this.fixedDeltaTime = options.fixedDeltaTime;
17503
17498
  this.maximumDeltaTime = options.maximumDeltaTime;
17504
17499
  es2018$6.assert(this.maximumDeltaTime >= this.fixedDeltaTime, 'maximumDeltaTime must be greater than or equal to fixedDeltaTime');
17505
- this.fixedUpdate = options.fixedUpdate;
17506
17500
  this.update = options.update;
17501
+ this.fixedUpdate = options.fixedUpdate;
17502
+ this.lateUpdate = options.lateUpdate;
17507
17503
  this.render = options.render;
17508
- this.nextFrame = es2018$6.go(() => {
17509
- switch (options.mode) {
17510
- case exports.Mode.UpdateFirst: return this.nextFrameUpdateFirst.bind(this);
17511
- case exports.Mode.FixedUpdateFirst: return this.nextFrameFixedUpdateFirst.bind(this);
17512
- default: throw new Error('Unknown mode');
17513
- }
17514
- });
17515
17504
  }
17516
17505
  start() {
17517
17506
  this.fsm.send('start');
@@ -17542,30 +17531,14 @@
17542
17531
  * 注意, 如果渲染帧率比物理帧率快, 且运行性能良好, 则物理帧不一定会在此帧更新.
17543
17532
  * 3. 渲染经过更新后的最新状态, 渲染器可以根据alpha参数执行插值渲染.
17544
17533
  */
17545
- nextFrameUpdateFirst(deltaTime) {
17534
+ nextFrame(deltaTime) {
17546
17535
  this.deltaTimeAccumulator = Math.min(this.deltaTimeAccumulator + deltaTime, this.maximumDeltaTime);
17547
17536
  this.update(deltaTime);
17548
17537
  while (this.deltaTimeAccumulator >= this.fixedDeltaTime) {
17549
17538
  this.fixedUpdate(this.fixedDeltaTime);
17550
17539
  this.deltaTimeAccumulator -= this.fixedDeltaTime;
17551
17540
  }
17552
- const alpha = this.deltaTimeAccumulator / this.fixedDeltaTime;
17553
- this.render(alpha);
17554
- }
17555
- /**
17556
- * nextFrameFixedUpdateFirst依序做以下几件事:
17557
- * 1. 响应游戏世界从上一帧更新后到这一帧更新之前发生的物理变化.
17558
- * 注意, 如果渲染帧率比物理帧率快, 且运行性能良好, 则物理帧不一定会在此帧更新.
17559
- * 2. 响应用户输入, 为这一帧的游戏世界做出非物理方面的更新, 例如角色转向, 改变武器瞄准角度等.
17560
- * 3. 渲染经过更新后的最新状态, 渲染器可以根据alpha参数执行插值渲染.
17561
- */
17562
- nextFrameFixedUpdateFirst(deltaTime) {
17563
- this.deltaTimeAccumulator = Math.min(this.deltaTimeAccumulator + deltaTime, this.maximumDeltaTime);
17564
- while (this.deltaTimeAccumulator >= this.fixedDeltaTime) {
17565
- this.fixedUpdate(this.fixedDeltaTime);
17566
- this.deltaTimeAccumulator -= this.fixedDeltaTime;
17567
- }
17568
- this.update(deltaTime);
17541
+ this.lateUpdate(deltaTime);
17569
17542
  const alpha = this.deltaTimeAccumulator / this.fixedDeltaTime;
17570
17543
  this.render(alpha);
17571
17544
  }