Asynchronous loading of game assets

I’m looking for a demo that can load various assets (pictures, models, etc.) asynchronously. Please get help

Hi @tanbing629,

Check this example:

https://developer.playcanvas.com/en/tutorials/load-multiple-assets-at-runtime

2 Likes

Hi @Leonidas ,
Thanks for your quick reply,But it seems that none of the official loading demos is asynchronous loading.

What is not asynchronous about the demo? It kicks off requests to load the assets and is free to do other things while waiting for the assets to load.

3 Likes

app.assets.load() seems to be a synchronous loading method. During the loading process I found that it will cause the animation to freeze

It shouldn’t do :thinking: can you create an example project where you see this freeze please? There may be a frame drop when the asset is processed after it ls loaded depending on the size of the animation but the actual network load wouldn’t do that.

often when the asset is finished loading, and is added for rendering, its shaders need to compile, and that is blocking sync command.

That’s right, thank you

Is there any way to eliminate this lag caused by loading?

Compiling shaders is always a blocking operation for the browser. Usually what developers do is load/enable all their materials when the app starts, for a single frame.

That will force all materials to compile their shaders at the same time. Since it will happen as part of the app loading it won’t be that noticable.

Later on any model loading that uses those materials won’t lag/block the main thread.

2 Likes

So the best way is to preload all the materials in advance. To avoid shader compiling during gameplay?

First, it’s best to check if that is what’s causing your frame drop. An example project would help a lot here.

1 Like