新增TimeRuler用于分析游戏平均帧率

This commit is contained in:
yhh
2021-01-20 15:35:59 +08:00
parent 1be5862dc4
commit f6b6a8aa1b
9 changed files with 792 additions and 65 deletions

View File

@@ -13,10 +13,15 @@ module es {
public static frameCount = 0;
/** 自场景加载以来的总时间 */
public static timeSinceSceneLoad: number = 0;
private static _lastTime = 0;
private static _lastTime = -1;
public static update(currentTime: number) {
let dt = (currentTime - this._lastTime) / 1000;
if (currentTime == -1)
currentTime = Date.now();
if (this._lastTime == -1)
this._lastTime = currentTime;
let dt = currentTime - this._lastTime;
this.totalTime += dt;
this.deltaTime = dt * this.timeScale;
this.unscaledDeltaTime = dt;