Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 815 Bytes

use-threlte-audio.mdx

File metadata and controls

22 lines (20 loc) · 815 Bytes
order category sourcePath name type
1.5
@threlte/extras
packages/extras/src/lib/audio/useThrelteAudio.ts
useThrelteAudio
hook

When invoking the hook useThrelteAudio and there's no Threlte audio context yet, it will be created and returned, otherwise, the existing audio context will be returned. The components <AudioListener>, <Audio> and <PositionalAudio> will create an audio context if mounted.

const {
  audioListeners, // Map<string, AudioListener>
  getAudioListener, // (id?: string) => AudioListener | undefined
  addAudioListener, // (listener: AudioListener, id?: string) => void
  removeAudioListener // (id?: string) => void
} = useThrelteAudio()