mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
Improve cc_time calculation (#4400)
This commit is contained in:
committed by
Weiliang Wang
parent
3bdd342961
commit
b89ddd3eb6
@@ -481,6 +481,7 @@ class Director extends EventTarget {
|
||||
CC_BUILD && CC_DEBUG && console.timeEnd('Activate');
|
||||
|
||||
//start scene
|
||||
this._root.resetCumulativeTime();
|
||||
this.startAnimation();
|
||||
|
||||
if (onLaunched) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user