Load material after model is loaded completely

I am loading my model asset during runtime. It loads with materials that have large textures. Is there a way to load the materials + textures on this model after the model itself is loaded?

Hi @saifs,

I think with the legacy model component/asset that is a bit hard to do. You can inspect the model materials and try to find the required textures based on their names.

So basically you will generate a list of materials + textures assets, which you will have to load manually, and only after all finish you will show the model.

This is a simple example on how to wait for multiple assets to load:

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

I think with the new render component/asset it’s easier to find the referenced assets. You can use this property to get all referenced material assets on the render component:

https://developer.playcanvas.com/api/pc.RenderComponent.html#materialAssets

And then you can inspect each material and I think you will find a referenced assets property that you can use to get the texture assets as well (that may a private property).

Hope that helps.

1 Like