Load assets at runtime

dear community

i have a question about the function of loading assets at runtime and how it works and whats possible and what not.

i am building a 3d website with various positional audio files. i’d like to add around 50-100 songs which have the size of approx. 2-3mb. and of course i am running into the problem now of creating a super heavy website of 200mb that takes way too long to load for any visitor.

If i have a free orbit camera where i attach the audio listener to, is it possible to only load an audio at the moment the camera approaches the range of the positional audio? by adding some “load at runtime code” to almost every entity in my project…
so you can move through space and the website needs to update / load data in real time. your browser would not load everything from the beginning but load and play in real time each audio asset when needed.

is that possible with coding something based on “Load assets at runtime” ?
And is the user experience better and faster because smaller data packages are loaded ?

thanks so much for your answers in advance :slight_smile:

Hi @asnras,

It’s good thinking to research and plan this accordingly.

Definitely preloading all audio files doesn’t really make sense. The common strategy is to set preload to false and then each audio file will be loaded as soon as it’s requested by the scene hierarchy.

That basically means the moment an entity referencing it (via a sound component) is enabled. That won’t take into account the proximity to the active audio listener if it’s a 3D audio, so you will have to program that system.

You could have the entity disabled and only enable it from your audio manager system to have the required audio file downloaded. This system will create a small pause between the moment a sound is required and the moment it actually starts playing, but that is expected.

1 Like