优化框架性能,Time支持传入引擎dt

This commit is contained in:
yhh
2021-05-13 16:58:24 +08:00
parent 84922794fb
commit 9c7703eb2d
11 changed files with 374 additions and 417 deletions

View File

@@ -18,12 +18,19 @@ module es {
private static _lastTime = -1;
public static update(currentTime: number) {
if (currentTime == -1)
if (currentTime == -1) {
currentTime = Date.now();
}
if (this._lastTime == -1)
this._lastTime = currentTime;
let dt = (currentTime - this._lastTime) / 1000;
let dt = 0;
if (currentTime == -1) {
dt = (currentTime - this._lastTime) / 1000;
} else {
dt = currentTime;
}
if (dt > this.maxDeltaTime)
dt = this.maxDeltaTime;
this.totalTime += dt;