From fa28f1a79a7718868710f92290c160d514125723 Mon Sep 17 00:00:00 2001 From: Brian Peiris <brianpeiris@gmail.com> Date: Wed, 18 Apr 2018 17:36:14 -0700 Subject: [PATCH] only update fps if it has changed --- src/components/stats-plus.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/stats-plus.js b/src/components/stats-plus.js index c64100eea..2c4c14800 100644 --- a/src/components/stats-plus.js +++ b/src/components/stats-plus.js @@ -53,6 +53,7 @@ AFRAME.registerComponent("stats-plus", { this.fpsEl.classList.add("rs-fps-counter"); document.body.appendChild(this.fpsEl); this.lastFpsUpdate = performance.now(); + this.lastFps = 0; this.frameCount = 0; if (scene.isMobile) { @@ -88,8 +89,11 @@ AFRAME.registerComponent("stats-plus", { // Update the fps counter text once a second if (now >= this.lastFpsUpdate + 1000) { - const fps = this.frameCount / ((now - this.lastFpsUpdate) / 1000); - this.fpsEl.innerHTML = Math.round(fps) + " FPS"; + const fps = Math.round(this.frameCount / ((now - this.lastFpsUpdate) / 1000)); + if (fps !== this.lastFps) { + this.fpsEl.innerHTML = Math.round(fps) + " FPS"; + this.lastFps = fps; + } this.lastFpsUpdate = now; this.frameCount = 0; } -- GitLab