修复Time不传入dt获取deltaTime错误问题
This commit is contained in:
Vendored
+1
-1
@@ -2189,7 +2189,7 @@ declare module es {
|
|||||||
/** 自场景加载以来的总时间 */
|
/** 自场景加载以来的总时间 */
|
||||||
static timeSinceSceneLoad: number;
|
static timeSinceSceneLoad: number;
|
||||||
private static _lastTime;
|
private static _lastTime;
|
||||||
static update(currentTime: number): void;
|
static update(currentTime: number, useEngineTime: boolean): void;
|
||||||
static sceneChanged(): void;
|
static sceneChanged(): void;
|
||||||
/**
|
/**
|
||||||
* 允许在间隔检查。只应该使用高于delta的间隔值,否则它将始终返回true。
|
* 允许在间隔检查。只应该使用高于delta的间隔值,否则它将始终返回true。
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ var es;
|
|||||||
if (Core.paused) {
|
if (Core.paused) {
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
es.Time.update(currentTime);
|
es.Time.update(currentTime, currentTime != -1);
|
||||||
if (this._scene != null) {
|
if (this._scene != null) {
|
||||||
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
if (this._globalManagers[i].enabled)
|
if (this._globalManagers[i].enabled)
|
||||||
@@ -5680,19 +5680,19 @@ var es;
|
|||||||
var Time = /** @class */ (function () {
|
var Time = /** @class */ (function () {
|
||||||
function Time() {
|
function Time() {
|
||||||
}
|
}
|
||||||
Time.update = function (currentTime) {
|
Time.update = function (currentTime, useEngineTime) {
|
||||||
|
var dt = 0;
|
||||||
|
if (useEngineTime) {
|
||||||
|
dt = currentTime;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (currentTime == -1) {
|
if (currentTime == -1) {
|
||||||
currentTime = Date.now();
|
currentTime = Date.now();
|
||||||
}
|
}
|
||||||
if (this._lastTime == -1)
|
if (this._lastTime == -1)
|
||||||
this._lastTime = currentTime;
|
this._lastTime = currentTime;
|
||||||
var dt = 0;
|
|
||||||
if (currentTime == -1) {
|
|
||||||
dt = (currentTime - this._lastTime) / 1000;
|
dt = (currentTime - this._lastTime) / 1000;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
dt = currentTime;
|
|
||||||
}
|
|
||||||
if (dt > this.maxDeltaTime)
|
if (dt > this.maxDeltaTime)
|
||||||
dt = this.maxDeltaTime;
|
dt = this.maxDeltaTime;
|
||||||
this.totalTime += dt;
|
this.totalTime += dt;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -182,7 +182,7 @@ module es {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Time.update(currentTime);
|
Time.update(currentTime, currentTime != -1);
|
||||||
if (this._scene != null) {
|
if (this._scene != null) {
|
||||||
for (let i = this._globalManagers.length - 1; i >= 0; i--) {
|
for (let i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
if (this._globalManagers[i].enabled)
|
if (this._globalManagers[i].enabled)
|
||||||
|
|||||||
@@ -17,18 +17,19 @@ module es {
|
|||||||
public static timeSinceSceneLoad: number = 0;
|
public static timeSinceSceneLoad: number = 0;
|
||||||
private static _lastTime = -1;
|
private static _lastTime = -1;
|
||||||
|
|
||||||
public static update(currentTime: number) {
|
public static update(currentTime: number, useEngineTime: boolean) {
|
||||||
|
let dt = 0;
|
||||||
|
if (useEngineTime) {
|
||||||
|
dt = currentTime;
|
||||||
|
} else {
|
||||||
if (currentTime == -1) {
|
if (currentTime == -1) {
|
||||||
currentTime = Date.now();
|
currentTime = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._lastTime == -1)
|
if (this._lastTime == -1)
|
||||||
this._lastTime = currentTime;
|
this._lastTime = currentTime;
|
||||||
|
|
||||||
let dt = 0;
|
|
||||||
if (currentTime == -1) {
|
|
||||||
dt = (currentTime - this._lastTime) / 1000;
|
dt = (currentTime - this._lastTime) / 1000;
|
||||||
} else {
|
|
||||||
dt = currentTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dt > this.maxDeltaTime)
|
if (dt > this.maxDeltaTime)
|
||||||
|
|||||||
Reference in New Issue
Block a user