sounds
This commit is contained in:
parent
c6ba3e38a2
commit
37087d08a7
189 changed files with 12864 additions and 9589 deletions
37
js/debug_tools.js
Normal file
37
js/debug_tools.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
(function () {
|
||||
const params = new URLSearchParams(location.search || "");
|
||||
const enabled = params.get("debug") === "1" || params.get("debug") === "true";
|
||||
if (!enabled) return;
|
||||
const panel = document.createElement("div");
|
||||
panel.id = "debugOverlay";
|
||||
panel.style.cssText = [
|
||||
"position:fixed", "left:8px", "top:76px", "z-index:99999", "min-width:230px", "max-width:360px",
|
||||
"font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace", "color:#f7fbff",
|
||||
"background:rgba(18,24,30,.78)", "border:1px solid rgba(255,255,255,.18)", "border-radius:10px",
|
||||
"padding:8px 10px", "pointer-events:none", "white-space:pre-wrap", "box-shadow:0 8px 24px rgba(0,0,0,.22)"
|
||||
].join(";");
|
||||
document.addEventListener("DOMContentLoaded", () => document.body.appendChild(panel));
|
||||
let lastEvents = [];
|
||||
let lastAudio = [];
|
||||
window.TarinaiEvents?.on("*", ev => { lastEvents.unshift(ev.type); if (lastEvents.length > 10) lastEvents.length = 10; });
|
||||
window.TarinaiEvents?.on("audio:play", ev => { lastAudio.unshift(`${ev.detail?.id || "?"}:${ev.detail?.category || "?"}`); if (lastAudio.length > 8) lastAudio.length = 8; });
|
||||
window.setInterval(() => {
|
||||
const w = window.world;
|
||||
const perf = window.TarinaiPerformance?.debugSnapshot(w) || {};
|
||||
panel.textContent = [
|
||||
`tarinai v${window.TARINAI_VERSION || "?"}`,
|
||||
`fps ${perf.fps ?? window.__tarinaiFps ?? "?"} perf ${perf.level ?? "?"}`,
|
||||
`items ${(w?.items || []).length} tarinai ${(w?.tarinai || []).length} ants ${(w?.ants || []).length}`,
|
||||
`effects ${(w?.effects || []).length}`,
|
||||
`terrain v${w?.terrainVersion ?? 0} spatial v${w?.spatialVersion ?? 0}`,
|
||||
`drawList ${(w?.drawList || []).length} logs ${(w?.logs || []).length}`,
|
||||
`dpr ${uiCache?.canvasDpr || "?"} cache ${window.TARINAI_APP?.cacheName || "?"}`,
|
||||
`sw ${navigator.serviceWorker?.controller ? "controlled" : "uncontrolled"} soundPack ${window.TarinaiAudio?.soundPackVersion || "?"}`,
|
||||
`audio ${lastAudio.join(", ") || window.TarinaiAudio?.lastPlayedId || "-"}`,
|
||||
`effects ${window.TarinaiEffectRegistry?.debugSnapshot?.().length || 0} registered`,
|
||||
`events ${lastEvents.join(", ")}`,
|
||||
].join("\n");
|
||||
}, 500);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue