fix(audio): handle spamming play

This commit is contained in:
2026-02-24 17:51:55 +01:00
parent 51a446d7b8
commit 61aec3da2e

View File

@@ -7,17 +7,14 @@ type Rect = [number, number, number, number];
let atlasImage: HTMLImageElement | null = null;
const modelCache = new Map<string, THREE.Group>();
const createAudio = (path: string) => {
const audio = import.meta.client ? new Audio(path) : null;
return {
const createAudio = (path: string) => ({
play: () => {
if (!audio) return;
audio.currentTime = 0;
if (!import.meta.client) return;
const audio = new Audio(path);
audio.addEventListener("ended", () => audio.remove(), { once: true });
audio.play().catch(() => {});
},
};
};
});
const loaded = ref(0);
const total = ref({{TOTAL}});