Im making a 3D website and just tried to place audio using PositionalAudio by using react-three-fiber drei. But it's not working due to google new autoplay policy. So I needed to play my website music using the PositionalAudio component and with a play/stop button, which plays and stops the music with the user's command. So is there any way to do an interactive audio player by using the PositionalAudio component in react-three-fiber drei?
Asked
Active
Viewed 294 times
1 Answers
1
You have to set some trigger for it. I fixed mine by conditionally rendering it with state.
<Suspense>
<mesh position={[0, 0, 0]}>
<boxBufferGeometry attach="geometry" args={[0.1, 0.1, 0.1]} />
<meshStandardMaterial color="red" />
{musicZoom && (
<PositionalAudio autoplay loop = {false} url="/discoSite.mp3" distance={3} />
)}
</mesh>
</Suspense>

Carl
- 11
- 1