y
This commit is contained in:
parent
61718e2981
commit
f657b6a4a4
94 changed files with 3970 additions and 1241 deletions
15
js/main.js
15
js/main.js
|
|
@ -16,8 +16,21 @@ function ensureWorldBootstrap() {
|
|||
let world = ensureWorldBootstrap();
|
||||
let last = nowSec();
|
||||
let statsTimer = 0;
|
||||
let statsRefreshPending = false;
|
||||
window.__tarinaiFps = 0;
|
||||
|
||||
function scheduleStatsRefresh() {
|
||||
if (statsRefreshPending) return;
|
||||
if (typeof colonyStatsUiVisible === "function" && !colonyStatsUiVisible()) return;
|
||||
statsRefreshPending = true;
|
||||
const run = () => {
|
||||
statsRefreshPending = false;
|
||||
if (!document.hidden) renderStats();
|
||||
};
|
||||
if (typeof window.requestIdleCallback === "function") window.requestIdleCallback(run, { timeout: 900 });
|
||||
else window.setTimeout(run, 0);
|
||||
}
|
||||
|
||||
const LOADING_SPRITES = SPRITES
|
||||
.filter(asset => asset && !asset.actionOnly)
|
||||
.slice(0, 11)
|
||||
|
|
@ -96,7 +109,7 @@ function loop() {
|
|||
statsTimer += dt;
|
||||
const statsInterval = 2.5;
|
||||
if (statsTimer > statsInterval) {
|
||||
renderStats();
|
||||
scheduleStatsRefresh();
|
||||
statsTimer = 0;
|
||||
}
|
||||
requestAnimationFrame(loop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue