pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.27k stars 682 forks source link

PositionalAudio problem on iOS #1031

Open hecodeit opened 2 years ago

hecodeit commented 2 years ago

Problem description:

PositionalAudio no working on iOS

Relevant code:

I'm fork the original example from Lulaby city My version is here. It is exactly same with the original one, but update fiber and drei to latest version.

The original example working on iOS, the updating version don't. Can not find the problem from?

hecodeit commented 2 years ago

Update:

I find the problem is: iOS device "suspended" audio. Using "Click" or "Touchdown" mount PositionalAudio don't work on iOS.

Possible solution:

const audioRef = useRef<PositionalAudioImpl>();

useEffect(() => {
  // for iOS
  if (audioRef.current && audioRef.current.context.state !== "running") {
    audioRef.current.context.resume();
  }
})

Anyway, I don't understand why OLD VERSION Lulaby city is working?