Improve cc_time calculation (#4400)

This commit is contained in:
pandamicro
2019-05-10 08:44:27 +08:00
committed by Weiliang Wang
parent 3bdd342961
commit b89ddd3eb6
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -481,6 +481,7 @@ class Director extends EventTarget {
CC_BUILD && CC_DEBUG && console.timeEnd('Activate');
//start scene
this._root.resetCumulativeTime();
this.startAnimation();
if (onLaunched) {
+10
View File
@@ -52,6 +52,10 @@ export class Root {
return this._views;
}
public get cumulativeTime (): number {
return this._time;
}
public get frameTime (): number {
return this._frameTime;
}
@@ -75,6 +79,7 @@ export class Root {
private _ui: UI | null = null;
private _scenes: RenderScene[] = [];
private _views: RenderView[] = [];
private _time: number = 0;
private _frameTime: number = 0;
private _fpsTime: number = 0;
private _frameCount: number = 0;
@@ -164,10 +169,15 @@ export class Root {
this._curWindow = window;
}
public resetCumulativeTime () {
this._time = 0;
}
public frameMove (deltaTime: number) {
this._frameTime = deltaTime;
++this._frameCount;
this._time += this._frameTime;
this._fpsTime += this._frameTime;
if (this._fpsTime > 1.0) {
this._fps = this._frameCount;
+1 -1
View File
@@ -896,7 +896,7 @@ export abstract class RenderPipeline {
const ambient = scene.ambient;
// update UBOGlobal
_vec4Array[0] = this._root.frameTime;
_vec4Array[0] = this._root.cumulativeTime;
_vec4Array[1] = 0.0;
_vec4Array[2] = 0.0;
_vec4Array[3] = 0.0;