2026-06-18 18:59:56 +09:00
|
|
|
"use strict";
|
|
|
|
|
let last = nowSec();
|
|
|
|
|
let statsTimer = 0;
|
|
|
|
|
let fpsTimer = 0;
|
|
|
|
|
let fpsFrames = 0;
|
|
|
|
|
window.__tarinaiFps = 0;
|
|
|
|
|
function loop() {
|
|
|
|
|
const t = nowSec();
|
|
|
|
|
const rawDt = t - last;
|
|
|
|
|
const dt = clamp(rawDt, 0, 0.05);
|
|
|
|
|
last = t;
|
|
|
|
|
fpsTimer += rawDt;
|
|
|
|
|
fpsFrames += 1;
|
|
|
|
|
if (fpsTimer >= 0.5) {
|
|
|
|
|
window.__tarinaiFps = Math.round(fpsFrames / Math.max(fpsTimer, 0.001));
|
|
|
|
|
fpsTimer = 0;
|
|
|
|
|
fpsFrames = 0;
|
|
|
|
|
}
|
|
|
|
|
world.update(dt);
|
|
|
|
|
render();
|
|
|
|
|
statsTimer += dt;
|
2026-06-19 02:27:19 +09:00
|
|
|
const perf = world.performanceLevel ? world.performanceLevel() : 0;
|
|
|
|
|
const statsInterval = perf >= 3 ? 1.20 : perf === 2 ? 0.92 : perf === 1 ? 0.68 : 0.48;
|
|
|
|
|
if (statsTimer > statsInterval) {
|
2026-06-18 18:59:56 +09:00
|
|
|
renderStats();
|
|
|
|
|
statsTimer = 0;
|
|
|
|
|
}
|
|
|
|
|
requestAnimationFrame(loop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadImages().then(() => {
|
|
|
|
|
bindUI();
|
|
|
|
|
resizeCanvas();
|
|
|
|
|
world.reset();
|
|
|
|
|
selectTool("observe");
|
|
|
|
|
renderLog(world.logs);
|
|
|
|
|
renderArchive();
|
|
|
|
|
render();
|
|
|
|
|
renderStats();
|
|
|
|
|
syncTopButtons();
|
|
|
|
|
loop();
|
|
|
|
|
});
|