I would never publicly admit the ridiculous amount of time it took me to figure this out, especially for iOS. So here it is, to hopefully save someone else the same pain.
What it does:
-
Records video of your Three.js scene WITH audio (Howler.js or any WebAudio)
-
Takes screenshots
-
Works on desktop, Android, AND iOS
-
Desktop captures HTML overlays (HUD elements) via getDisplayMedia / html2canvas
-
Mobile captures canvas only, but gets native Share tray
The hard-won lessons:
-
iOS MediaRecorder: Pass NO options - no
mimeType, novideoBitsPerSecond, notimeslice. Justnew MediaRecorder(stream). -
Codec priority: Prefer WebM (
vp9,opus) over MP4 - better player compatibility on desktop. MP4/H264 as fallback. -
Howler audio capture: Connect
Howler.masterGaintoctx.createMediaStreamDestination(). But get fresh references when recording starts, as Howler doesn’t create its AudioContext until first sound plays. -
iOS file extension: Use
.mp4or social apps won’t recognize it. -
Screenshots: It helps having
preserveDrawingBuffer: trueon your renderer.
The demo is a graveyard with spatial crow sounds and mobile touch controls. Full ThreeRecorder class is in there, just copy it.