diff --git a/cocos/core/director.js b/cocos/core/director.js index b64845f582..0e2e398abf 100644 --- a/cocos/core/director.js +++ b/cocos/core/director.js @@ -481,6 +481,7 @@ class Director extends EventTarget { CC_BUILD && CC_DEBUG && console.timeEnd('Activate'); //start scene + this._root.resetCumulativeTime(); this.startAnimation(); if (onLaunched) { diff --git a/cocos/core/root.ts b/cocos/core/root.ts index baf7a93dd6..e5fd0251a1 100644 --- a/cocos/core/root.ts +++ b/cocos/core/root.ts @@ -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; diff --git a/cocos/pipeline/render-pipeline.ts b/cocos/pipeline/render-pipeline.ts index 2a68be57e0..41efa27713 100644 --- a/cocos/pipeline/render-pipeline.ts +++ b/cocos/pipeline/render-pipeline.ts @@ -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;