Asset Container Internals?

We currently load a lot of models and in order to manage meshes and textures, we use setEnabled(false) on meshes that are not in use, and dispose of textures when a model is removed from the scene. This works OK, but when we add lots of models to hide and show, then the list of meshes to “unhide” becomes longer and the application performance suffers. In addition, we have to reload textures and apply them again.

In Asset Containers, there appears to be some black magic going on. When a mesh and its textures are added to an asset container and removeAllFromScene() is called, those entities no longer appear in the list of scene textures or meshes, and they don’t appear in the Inspector. But if I add them back in using addAllToScene() then the textures come back but I don’t see them loaded in the network tab in Chrome. So my questions:

  1. Are asset containers the right way to hide a mesh, its submeshes and their materials and textures?
  2. Where do the textures go? Are they still in the GPU or are they cached in RAM or local storage?
  3. Are there known limitations to how many Asset Containers I can have? What if each container holds an entire GLTF with submeshes and all their materials? Will that still be the most efficient way to solve the issue?

Thanks!

Yup, it is a convenient way to do so.

They are simply removed from scene.textures which the inspector is using to display its list :slight_smile: so no magic here and the memory is fully identical to having them in the list at the exception of the address of the texture being stored in the list (but fully irrelevant here).

The limit is your actual browser memory limit :frowning: This is definitely not a streaming solution, only a convenient way to preload things in a scene and put them aside.

3 Likes

So if we’re trying to manage GPU usage, because of textures, then we still need to dispose them?