Skip to content

AudioListener: Set the proper up-direction #31054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025

Conversation

WestLangley
Copy link
Collaborator

Fixes #31048.

The up-direction required by the AudioListener API is not the same as the three.js up-direction.

See https://developer.mozilla.org/en-US/docs/Web/API/AudioListener for an explanation.

@WestLangley WestLangley added this to the r177 milestone May 6, 2025
Copy link

github-actions bot commented May 6, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.29
78.32
336.29
78.32
+0 B
+0 B
WebGPU 548.2
152.02
548.2
152.02
+0 B
+0 B
WebGPU Nodes 547.55
151.86
547.55
151.86
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 466.23
112.58
466.23
112.58
+0 B
+0 B
WebGPU 622.98
168.71
622.98
168.71
+0 B
+0 B
WebGPU Nodes 577.85
158
577.85
158
+0 B
+0 B

@Mugen87
Copy link
Collaborator

Mugen87 commented May 6, 2025

I have tested the PR with the fiddle and a modified version of webaudio_timing and indeed the issue is fixed 🎉!

I initially wondered why this bug has not been detected earlier but I suspect in most use cases (e.g. when the camera and thus the listener is transformed via OrbitControls or PointerLockControls), the problematic rotations mentioned in #31048 have not been applied by the app. In any event, it's good to see the issue is fixed now.

@WestLangley WestLangley marked this pull request as ready for review May 6, 2025 08:33
@WestLangley
Copy link
Collaborator Author

@Mugen87 I also thought about the use case where the audio listener is added as a child of the camera, and camera.up is set to Z-up, for example. I believe that use case is also working correctly now.

Maybe your tests case can confirm that, too? 🙏

@Mugen87
Copy link
Collaborator

Mugen87 commented May 6, 2025

Tested and I did not hear any differences.

@Mugen87 Mugen87 merged commit 24ba60e into mrdoob:dev May 6, 2025
12 checks passed
@WestLangley WestLangley deleted the dev-audio_listener branch May 6, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rotating the AudioListener flips stereo channels
2 participants