Skip to content

AudioListener: Set the proper up-direction#31054

Merged
Mugen87 merged 1 commit into
mrdoob:devfrom
WestLangley:dev-audio_listener
May 6, 2025
Merged

AudioListener: Set the proper up-direction#31054
Mugen87 merged 1 commit into
mrdoob:devfrom
WestLangley:dev-audio_listener

Conversation

@WestLangley

Copy link
Copy Markdown
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
@github-actions

github-actions Bot commented May 6, 2025

Copy link
Copy Markdown

📦 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

Mugen87 commented May 6, 2025

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

Mugen87 commented May 6, 2025

Copy link
Copy Markdown
Collaborator

Tested and I did not hear any differences.

@Mugen87 Mugen87 merged commit 24ba60e into mrdoob:dev May 6, 2025
@WestLangley WestLangley deleted the dev-audio_listener branch May 6, 2025 10:06
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
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