Babylon.js Editor: AnimationGroup names change when instantiating a scene

Hi everyone,

I’m using Babylon.js Editor 5.5.0 and I’m creating reusable .scene files that I instantiate from another scene.

I have a farmer.scene containing a model with AnimationGroups such as:

  • farmidle

  • farmrunning

  • farmdie

When I run farmer.scene directly, the AnimationGroup names are exactly as expected.

However, when I instantiate the scene:

const farmer = this._farmer.instantiate();

the AnimationGroup names become something like:

farmdie-65cfd3e7-93cc-4a6a-ade3-f71262128dbb

Because of this, something like:

@animationGroupFromScene("farmdie")
private _die: AnimationGroup | null = null;

returns null.

I can make it work by searching with startsWith():

this._die = this.mesh.getScene().animationGroups.find(
    group => group.name.startsWith("farmdie")
) ?? null;

My question is: is this the expected behavior when instantiating a .scene in Babylon.js Editor?

If so, what is the recommended way to reference AnimationGroups from an instantiated scene? Is using startsWith()the correct approach, or is there a better way to keep/reference the original AnimationGroup names?

@julien-moreau Can you help me with this?

Thanks!
Maxi

Hey @Maxi !

It’s absolutely not the expecting behavior and I can confirm that the cause is the exact same as the @nodeFromDescendants decorator. It’ll be available in the next version this week (I’m amost done with the fix for the GUI).

Meanwhile you can still use the @visibleAsEntity but using the type animationGroup as parameter (Babylon.js Editor Documentation)

Again sorry for this inconvenience :frowning:

Thanks a lot! I tried the @visibleAsEntity workaround with the animationGroup type, and it worked perfectly.

Really appreciate your help! Looking forward to the next version.

Just to let you know, I just deployed the v5.5.1!