feat(nds): add audio in all menus

This commit is contained in:
2026-02-25 14:52:48 +01:00
parent 4af6de5329
commit 858082e151
45 changed files with 240 additions and 117 deletions

View File

@@ -7,14 +7,18 @@ type Rect = [number, number, number, number];
let atlasImage: HTMLImageElement | null = null;
const modelCache = new Map<string, THREE.Group>();
const createAudio = (path: string) => ({
play: () => {
if (!import.meta.client) return;
const audio = new Audio(path);
const createAudio = (path: string) => {
const source = import.meta.client ? new Audio(path) : null;
return {
play: (volume = 1) => {
if (!source) return;
const audio = source.cloneNode() as HTMLAudioElement;
audio.volume = volume;
audio.addEventListener("ended", () => audio.remove(), { once: true });
audio.play().catch(() => {});
},
});
};
};
const loaded = ref(0);
const total = ref({{TOTAL}});
@@ -104,6 +108,7 @@ type ModelTree = {
export type AudioEntry = ReturnType<typeof createAudio>;
type AudioTree = {
[key: string]: AudioEntry | AudioTree;
};