Morph target id not loaded from glTF model

Hi!

I am having a glTF model with animated morph targets, see PG example.
This works fine in general, but when serializing the scene to a .babylon file and loading it again in the sandbox, the animations are broken.

The reason for this is, that the .babylon file loader tries to link the animation to the morph target id, which is undefined.
It’s undefined already in the working PG scene, as the gltf loader doesn’t seem to set this id.
Infact the morph target id is only set inside the morph target Parse function, which is not called for glTF imports.

On first glance I’d suggest to simply set the id in the morph target constructor to the same value as the name.

I’m not sure either this topic is a question or a suggestion, then :grin:

@Tricotou well call it as you like.
Since I am addressing some misbehaviour here it’s probably some kind of bug .
Anyway suggesting a solution should benefit the discussion IMO :slight_smile:

Fixed here: Set missing morph target id for serialization by bghgary · Pull Request #15715 · BabylonJS/Babylon.js · GitHub

2 Likes