AssetContainer with dynamically loaded meshes / textures

Hi

My situation is like this:

I got an app that loads scene elements that are created by code. On top of that, I will like to load and reuse small assets and I mean a lot of times.

I do not use StandardMaterial at all. I moved everything to NodeMaterial. And here is my problem.

I got 1 model for assets and 2 textures for it separately.

I’m creating 3 tasks with AssetsManager. Put that in PromiseAll. On load I’m cloning NodeMaterial, assign textures to it, and put that on the model. Otherwise, I got “StandardMaterial not imported error” and I do not use it so I

All is fine but this is 1 asset that I will like to keep in memory and reuse.

But AssetContainer is not taking a single model to store it within. It takes all from the scene and I got their stuff that I do not want to add to it and do not want to add it to keep method. It’s too much of it. I need a method to add only this asset. And also it’s now in the scene, I need to remove it from it cause I’m not using it yet.

Also, I will load another asset like that in some time. Will also like to keep it. Do I need to create another AssetContainer and keep them in an object like this:

const assets = {
   model1: assetsContainer1,
   model2: assetsContainer2,
   [...]
}

Or is there a better way to have the asset loaded along the way, but not put them in the scene until you need its instance (cause this is exactly what I need with this)?

Regards
Peter

Interesting question for @sebavan

I already noticed that making instances of assetContainer boosts the number of Draw calls so it’s less performant than having a model in the scene with setEnabled to false. So not so cool TBH.

Regards
Peter

That should not be the case
Can you repro in the PG?

I will try later on.

I am not sure why several instance of AssetContainer would generate more draw calls, this sounds really strange and probably a bug ?

About the other one keeping several asset containers should be a nice way to handle it.

Also, another simplistic way is to parent your meshes to a transform node and simply enable/disable it :slight_smile:

I’m actually doing this now. But is it the most optimal way to keep loaded assets? I’m trying to find the most performance-wise way possible.