Skip to content
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

Fix spatial audio init issues #16279

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

docEdub
Copy link
Contributor

@docEdub docEdub commented Mar 12, 2025

If spatial audio is not enabled at init time using the spatialEnabled option, accessing the spatial property on a sound or bus throws error "Sub node not found".

This change fixes the issue by creating the underlying spatial audio subnode if it doesn't exist, instead of throwing an error.

If spatial audio is not enabled at init time using the `spatialEnabled` option, accessing the `spatial` property on a sound or bus throws error "Sub node not found".

This change fixes the issue by creating the underlying spatial audio subnode if it doesn't exist, instead of throwing an error.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes initialization issues for spatial audio by ensuring that the spatial subnode is created when missing, instead of throwing an error. Key changes include:

  • Updating the spatial audio property initialization to clone default values and create the subnode if absent.
  • Converting several methods to async and awaiting subnode creation to enforce proper initialization order.
  • Adjusting type annotations in subgraph files for consistency.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/dev/core/src/AudioV2/abstractAudio/subProperties/spatialAudio.ts Replaces error throwing with default cloning and subnode creation for spatial audio.
packages/dev/core/src/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.ts Converts callOnSubNode to async and adjusts type annotations.
packages/dev/core/src/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.ts Awaits subnode creation to ensure proper asynchronous initialization.
packages/dev/core/src/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.ts Applies similar asynchronous handling for spatial and stereo subnodes.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@docEdub docEdub enabled auto-merge (squash) March 12, 2025 05:03
@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2025

@docEdub docEdub merged commit 04206c9 into BabylonJS:master Mar 12, 2025
16 checks passed
@docEdub docEdub deleted the 250312-fix-spatial-audio-init-issue branch April 7, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants