From ea7fd176feeb35aa5e1e7fbdfaa084a3e61bf7f8 Mon Sep 17 00:00:00 2001 From: FurryR Date: Sat, 26 Oct 2024 14:39:52 +0800 Subject: [PATCH] fix renderTime Signed-off-by: FurryR --- src/engine/tw-frame-loop.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/tw-frame-loop.js b/src/engine/tw-frame-loop.js index 630e243d29a..3b30fd0d617 100644 --- a/src/engine/tw-frame-loop.js +++ b/src/engine/tw-frame-loop.js @@ -80,6 +80,8 @@ class FrameLoop { if (!document.hidden) { this.runtime._renderInterpolatedPositions(); } + this.runtime.screenRefreshTime = renderTime - this._lastRenderTime; // Screen refresh time (from rate) + this._lastRenderTime = renderTime; } else if ( renderTime - this._lastRenderTime >= this.runtime.currentStepTime @@ -101,12 +103,12 @@ class FrameLoop { if (this.runtime.profiler !== null) { this.runtime.profiler.stop(); } + this.runtime.screenRefreshTime = renderTime - this._lastRenderTime; // Screen refresh time (from rate) + this._lastRenderTime = renderTime; + if (this.framerate === 0) { + this.runtime.currentStepTime = this.runtime.screenRefreshTime; + } } - this.runtime.screenRefreshTime = renderTime - this._lastRenderTime; // Screen refresh time (from rate) - if (this.framerate === 0) { - this.runtime.currentStepTime = this.runtime.screenRefreshTime; - } - this._lastRenderTime = renderTime; } }