Using Scene methods on loaded .glb assets

I’d like to be able to do things like get the animation by name for my various loaded assets. I know that the Scene class includes .getAnimationGroupByName, but when I load my assets like so:

SceneLoader.ImportMeshAsync("", BASE_FILE_PATH, path, this.scene);

I don’t get a scene but a ISceneLoaderAsyncResult so I can’t use the method. Is there another way to load the assets so they are considered to be a Scene and therefore have access to Scene’s methods? Or is it wrong to load each .glb as a Scene since there should only be one Scene? If so, is there another way to use all the helpful Scene methods that would be useful on loaded .glb assets?

or you can access all of these and much more after you load your model via the scene object:

   scene.meshes
   scene.animatables
   scene.animationGroups
   scene.materials
   scene.textures
   ..etc
1 Like

If I load two character models into the scene and then I want to get the animation called Idle for character A, how could I do that? Since there are two assets loaded, each with an animation called Idle, how can scene.getAnimationGroupByName know which one I want? That is why I was wondering if there was some way to get an animation group by name for a particular loaded asset. Currently I wrote my own function to do so but I was wondering if there was a built in way to access all the helper methods that a Scene has but for a particular loaded asset.

Here is the example of loading 2 same character models and finding their own animation groups - Babylon.js Playground

If you want more helper methods (like dispose) it is better to use Asset Container.

Here is scene.getMeshByName source code:

2 Likes