feat(nds): add audio in all menus
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user