Using Asynchronous call to load asset then getMeshByName right after


In a prototype application I use addMeshTask to load glb asset and right “after” make to call getMeshByName. Here is the pseudo code :

CreateAssets(string names[]);// will call addMeshTask for every mesh to be added from glb assets
UpdateAssets(string names[]);// will update position of all meshes, and use getMeshByName to retrieve each mesh

I have tried to reproduce my issue here :

To be sure getMeshByName could be called I also tried something like
await assetsManager.loadAsync();

But this does not solve my issue, getMeshByName returns null.

The only way I solved it is to add a tiny invisible box when initializing the canvas and scene at first glance, then right after all calls to getMeshByName will work


Hi pcarret,

I’m not 100% sure this aligns with what you’re going for – the camera moved when I did this, for reasons I haven’t explored – but does ImportMeshAsync work as an alternative?

meshes library : github from githubusercontent | Babylon.js Playground (

I changed a few things around, but it finds the mesh root now. Hope this helps, and best of luck!

Thank for you answer @syntheticmagus
Do you have a working Playground sample ?

That link shows a version of your Playground which outputs the “find mesh root” console log.

1 Like

@syntheticmagus The graphic result looks weird

Try zooming in. As mentioned above, the camera moved, but what I was going for was to get the model to load such that you can find it. I hadn’t spent time to explore why the camera moved, though I have now: it’s because timings changed relative to where you were creating the camera (which also the thing that makes your mesh name query work). The following link has that changed, too.

meshes library : github from githubusercontent | Babylon.js Playground (

Hope this helps, and best of luck!

1 Like