p3nGu1nZz commited on
Commit
480409f
1 Parent(s): ffea1eb
Files changed (2) hide show
  1. index.js +3 -3
  2. wgpu-state.js +1 -0
index.js CHANGED
@@ -79,13 +79,13 @@ function GenerateIndices(maxGlyphs) {
79
  }
80
 
81
  function GameLoop() {
82
- let lastTime = performance.now();
83
  state.timing.accumulator = 0;
84
 
85
  function Tick() {
86
  state.timing.currentTime = performance.now();
87
- state.timing.frameTime = (state.timing.currentTime - lastTime) / 1000;
88
- lastTime = state.timing.currentTime;
89
 
90
  state.timing.deltaTime = Math.min(state.timing.frameTime, state.timing.maxFrameTime);
91
  state.timing.accumulator += state.timing.deltaTime;
 
79
  }
80
 
81
  function GameLoop() {
82
+ state.lastTime = performance.now();
83
  state.timing.accumulator = 0;
84
 
85
  function Tick() {
86
  state.timing.currentTime = performance.now();
87
+ state.timing.frameTime = (state.timing.currentTime - state.lastTime) / 1000;
88
+ state.lastTime = state.timing.currentTime;
89
 
90
  state.timing.deltaTime = Math.min(state.timing.frameTime, state.timing.maxFrameTime);
91
  state.timing.accumulator += state.timing.deltaTime;
wgpu-state.js CHANGED
@@ -32,6 +32,7 @@ export function createState(config) {
32
  deltaTime: 0,
33
  currentTime: 0,
34
  frameTime: 0,
 
35
  }
36
  };
37
  }
 
32
  deltaTime: 0,
33
  currentTime: 0,
34
  frameTime: 0,
35
+ lastTime: 0,
36
  }
37
  };
38
  }