Best way to load a list of glbs

Hi All, Ive been trying to load a list of glb blobs. We want to pre-load the blobs first to memory (asynchronously), then add them to the scene later after all the glb blobs are loaded. The requirement therefore is to have the meshes preloaded but only add them to the scene as needed. Trying to use what is suggested here:

the only difference is we have an array of glb blobs. And then we cherry pick the ones we want to append to the scene later.

it works great but there is an issue. I need access to the newly created mesh to then perform some operations on that mesh.

so i try to use scene.meshes after each iteration and what im seeing in the meshes list isnt making sense. Im seeing a “ground” object and several other meshes. What I expect to see is only the data for the newly created mesh. Our glbs are simple… just a single mesh with a parent node.

Is this the wrong path to go down? Perhaps the right thing to do is load all meshes into an asset container. The asset container is then contains all possible meshes, then add only the meshes we want from the container to the scene?

scene.meshes is the list of ALL the meshes in a scene. You can access the loaded ones only in the result of the append call.

thats what i thought too. But still getting a huge list of 50 meshes even though I know the blob being loaded is a root node with a parented mesh thats it.

        SceneLoader.AppendAsync(model.bloburl, undefined, scene, undefined, ".glb").then(res=>{
          var meshes = res.meshes;

meshes looks like this:

if I use this I do just get one mesh and a root node to that mesh. so a total of 2 objects as expected not 50.
SceneLoader.ImportMeshAsync(’’, model.fullurl, ‘’, scene).then(res=>{
var mesh = res.meshes;

but the problem to this approach is the model is loaded and added to the scene right away. We dont want that… we want to preload a library of models, and only add them to the scene as needed.

Perhaps AssetManager and AssetContainers is the right architecture for what we’re trying to acheive. Having a pool of objects and cherry picking which ones to add to the scene based on some logic. Will keep playing.

1 Like

True, completely missed you were using AppendAsync which returns the scene and not ImportMeshAsync.

Why not relying on ImportMeshAsync in your case ? it will load in the same way with glbs.

1 Like

Hello @Anupam_Das just checking in, was your question answered?