space-game/public/assets/themes/default/audio/metal.wav
Michael Mainguy dfec655b6c
All checks were successful
Build / build (push) Successful in 1m20s
Fix explosion sound by migrating to AudioEngineV2 spatial audio API
Root cause: The old Sound API (new Sound()) is incompatible with
AudioEngineV2 in BabylonJS 8.32.0, causing silent failures where the
explosion.mp3 file was never fetched from the network.

Audio System Fixes:
- Migrate explosion sound from Sound class to AudioEngineV2.createSoundAsync()
- Use StaticSound with spatial property instead of old Sound API
- Configure audio engine with listenerEnabled and listenerAutoUpdate
- Attach audio listener to camera for proper 3D positioning

Spatial Audio Implementation:
- Use spatialEnabled: true with spatial-prefixed properties
- Attach sound to explosion node using sound.spatial.attach()
- Properly detach and cleanup after explosion finishes (850ms)
- Configure exponential distance model with 500 unit max distance

Technical Changes:
- Replace new Sound() with await audioEngine.createSoundAsync()
- Change _explosionSound type from Sound to StaticSound
- Update imports: Sound → StaticSound
- Use sound.spatial.attach(node) instead of attachToMesh()
- Use sound.spatial.detach() for cleanup
- Remove incompatible getVolume() calls

Audio Engine Configuration:
- Add CreateAudioEngineAsync options for spatial audio support
- Attach listener to camera after unlock in both level flows
- Enable listener auto-update for VR camera movement tracking

This fixes the explosion sound loading and enables proper 3D spatial
audio with distance attenuation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 16:05:40 -06:00

1.9 MiB