From eb21984063f368086fb4553e4300a4c5af0a929c Mon Sep 17 00:00:00 2001 From: Santy-Wang Date: Tue, 25 May 2021 16:11:56 +0800 Subject: [PATCH] adjust event name and introduce event_begin_frame (#8708) --- cocos/core/director.ts | 15 +++++++++++---- cocos/physics/physx/export-physx.ts | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cocos/core/director.ts b/cocos/core/director.ts index ac5cc0fd36..f3f652929b 100644 --- a/cocos/core/director.ts +++ b/cocos/core/director.ts @@ -232,12 +232,19 @@ export class Director extends EventTarget { */ public static readonly EVENT_AFTER_PHYSICS = 'director_after_physics'; + /** + * The event which will be triggered at the frame begin.
+ * 一帧开始时所触发的事件。 + * @event Director.EVENT_BEGIN_FRAME + */ + public static readonly EVENT_BEGIN_FRAME = 'director_begin_frame'; + /** * The event which will be triggered at the frame end.
* 一帧结束之后所触发的事件。 - * @event Director.EVENT_END_OF_FRAME + * @event Director.EVENT_END_FRAME */ - public static readonly EVENT_END_OF_FRAME = 'director_end_of_frame'; + public static readonly EVENT_END_FRAME = 'director_end_frame'; public static instance: Director; @@ -881,7 +888,7 @@ export class Director extends EventTarget { } else { this.calculateDeltaTime(time); } - + this.emit(Director.EVENT_BEGIN_FRAME); const dt = this._deltaTime; // Update @@ -914,7 +921,7 @@ export class Director extends EventTarget { eventManager.frameUpdateListeners(); Node.clearBooks(); - this.emit(Director.EVENT_END_OF_FRAME); + this.emit(Director.EVENT_END_FRAME); this._totalFrames++; } } diff --git a/cocos/physics/physx/export-physx.ts b/cocos/physics/physx/export-physx.ts index b131ec634d..a258f5abaa 100644 --- a/cocos/physics/physx/export-physx.ts +++ b/cocos/physics/physx/export-physx.ts @@ -749,7 +749,7 @@ function hackForMultiThread () { } } - director.on(Director.EVENT_END_OF_FRAME, () => { + director.on(Director.EVENT_END_FRAME, () => { if (!director.isPaused) { lastUpdate(PhysicsSystem.instance); }