@threlte/extras
Version:
Utilities, abstractions and plugins for your Threlte apps
21 lines (20 loc) • 636 B
JavaScript
import { useThrelteAudio } from './useThrelteAudio';
export function useAudioListener(callbackOrId, id) {
const { getAudioListener } = useThrelteAudio();
if (typeof callbackOrId === 'function') {
const listener = getAudioListener(id);
if (!listener)
throw new Error('No AudioListener found.');
return callbackOrId({
listener,
context: listener.context
});
}
const listener = getAudioListener(callbackOrId);
if (!listener)
throw new Error('No AudioListener found.');
return {
listener,
context: listener.context
};
}