[clarified] Model cache?

Hello monkeys!

Currently, I load a model for each Spatial I put on the scene:
assetManager.loadModel(“Models/mymodel.j3o”);

So if I have 100 models, I do something like this:

for (int i=0;i<100;i++){
Spatial s=assetManager.loadModel(“Models/mymodel.j3o”);
//…
}

I suspect this isn’t necessary but instead I should load the model only once. How should I do?
Thanks!

It’s not necessary, the model is cached by the assetManager, it will be loaded from the file system the first time then you’ll be served a clone of the cached model each time you load it.

1 Like

Great! I’ve seen somewhere that is useful to cache Materials (instead of instancing a new one for each objects). I guess caching is useful only for Materials then?

Neither, every asset works the same way.

1 Like