In a prototype application I use addMeshTask to load glb asset and right “after” make to call getMeshByName. Here is the pseudo code :
UpdateView()
{
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
}
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
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?
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.