Accessing scene sounds


I’m having some trouble getting all sounds attached to a scene. When calling scene.sounds, I get an empty array. When calling a single sound directly using scene.getSoundByName(), the expected <Sound> object is returned.

Am I using scene.sounds properly? Is there another (better) way to get all the sounds in a scene?

Please see lines 24-27 in this playground example:

Thanks for your help! This forum is awesome, btw :slight_smile:

1 Like

Hi, maybe you found this link to the docs:

Honestly, what I do, is go through it from the top to bottom.

For scene.sounds… it looks like it was introduced after the docs above.

Maybe it has a separate doc somewhere. Might be in the release notes.

A PG search is usually the best way to find examples.

Welcome to the forum.

:eagle: : )

Hi/ you can get access to your sounds from scene.mainSoundTrack.soundCollection
since now you add sounds just to the stage, they fall into the main tracks array? what are you trying to do?


@kvasss: Your solution is what I’m looking for - thank you! (To answer your question, I’m trying to get all the sounds in a scene and dispose() them before loading another set of sounds. Please let me know if there is a smarter way to go about this).

@aFalcon: I’m just using the docs off of, but I don’t see any versioning to indicate that a property like scene.sounds isn’t available in the current version. Is there another set of docs I should be referencing instead?

Also, I’ve got a novice question about the playground search. When I search for “.sounds”, I get results that include “sound” (e.g. BABYLON.Sound()). Is there a way to do an exact search? (Tried quotes but no results were returned.)

Thanks for your help!

1 Like