[claude] 3D audio positioning — sounds come from their source (#239) #352
Reference in New Issue
Block a user
Delete Branch "claude/issue-239"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #239
What changed
updateAudioListener()— called every animation frame to sync the Web Audio APIlistenerposition and orientation with the Three.js camera. This is the core of spatial audio: as the camera moves or orbits, the left/right/distance cues update in real time.createPanner(x, y, z)— helper that creates an HRTFPannerNodeat a world-space coordinate. Uses inverse rolloff so distant sources fade naturally.Portal hums —
startPortalHums()attaches a quiet positional sine hum to each portal at its world position. The Morrowind portal (right), Bannerlord portal (left), and Workshop portal (behind) each have a distinct sub-bass pitch. They pan as the listener orbits. Safe to call multiple times; triggers from bothstartAmbient()andloadPortals()whichever fires second.Positional sparkle plucks — Previously sparkles went directly to
masterGain(mono-everywhere). Now each pluck spawns at a random 3D point floating above the platform, so sparkles drift in from different directions and heights. Panners are self-cleaning viaosc.addEventListener("ended", ...).stopAmbient()cleanup — disconnects and clearspositionedPanners, resetsportalHumsStartedso a fresh restart is clean.