I'm seeking inputs from people who have worked with Web Audio API in the react-vr. React-VR already has very cool components to place sounds in your scene, however, I need to go down one-step and access the audio buffer which is easily achieved by AudioContext provided by Web Audio.
In my client.js init()
I can find the audio context in the vr instance
function init(bundle, parent, options) {
const vr = new VRInstance(bundle, 'WelcomeToVR', parent, {
...options,
});
audioCtx = vr.rootView.context.AudioModule.audioContext._context; //HERE
vr.render = function() { };
vr.start();
return vr;
}
I am struggling to figure how to expose the audio context. It's scope ends once I exit the init() function. Is there another way to access the audio context in index.vr.js?