Breaking Changes In GLTF Loader

So @bghgary … I see there are some breaking changes (at least for me) in the 5.18.0 update to GLTF Loader.

First of all, i know i should not rely on PRIVATE functions as they might change. But in some cases, for the toolkit, i need to make some changes to the core GLTF loader. For example… i OVERRIDE the
_loadMeshPrimitiveAsync function so my version of the function allows me to setup SubMeshes and MultiMaterials. I also override loadAnimationsAsync because i need to tack on some animation.extras.metadata i store in the GLTF json. The way i was overriding these functions, was just declaring a local version of these functions in my GLTF Loader extension.

But as of 5.18.0 my overrides are no longer being called. SO i am kinda screwed there.

So what is the best way for me to override these functions ?

Do i need to make a whole separate GLTF Extension for each function i need to override ?

How do I properly override _loadMeshPrimitiveAsync and loadAnimationsAsync in the extension so i dont have to HACK an override of these functions like i been doing ?

Yo @bghgary … to be more specific… i have to get to the babylonMesh right after the


So I can setup sub meshes via my extra.metadata. Then right after that i create multi-material.

I dont know of any other way to turn the GLTF Primitive Mesh into a a Babylon Submesh than to do it exactly in the places im doing it… right after the call to babylonGeometry.applyToMesh

So thats where i am at with that :frowning:

I don’t see any recent changes to _loadMeshPrimitiveAsync. That should behave the same as before.

We did make a change to loadAnimationsAsync and that may have cause issues.

Do you have a link to your code?

This shouldn’t be happening. It sounds like a regression even if it’s private right now. All the overrides in GLTFLoaderExtension including the underscore versions are not supposed to have changed any time recently.

Ok @bghgary my override for _loadMeshPrimitiveAsync is still running… The body of that function changed a bit… from now to when i made a copy of it… But that is no problem…

My loadAnimationAsync function needs attention now

So @bghgary i got my _loadMeshPrimitiveAsync working again… But i dont know what i should do about loadAnimationAsync not being called ?

Im dead in the water with all my exported animations without the metadata i need. That is what i was overriding loadAnimationAsync.

How else can i get to the GLTF2.IAnimation extra metadata and associate it witht he new created BABYLON.AnimationGroup ???

loadAnimationAsync is sill in the gltf loader and I do not see why it would not get called.

but that is underscore loadAnimationAsync. Not the loadAnimationAsync

Before the latest 5.18.0 update i was able to define a function on my GLTF Extension class

class CVTOOLS_unity_metadata implements BABYLON.GLTF2.IGLTFLoaderExtension

This was my override that would actual create the new instance of the BABYLON.AnimationGroup that i would attach my extra metadata from BABYLON.GLTF2.IAnimation

Just by me defining that loadAnimationAsync on my subclass of IGLTFLoaderExtension the framework would call my custom override.

But after the update… my loadAnimationAsync defined on my subclass of the IGLTFLoaderExtension is no longer being called… Not getting the console log at top of function anymore. Something changed there

loadAnimationAsync should still be called on custom extensions.

This is what we use internally in our extensions for animation pointers or audio emitter. KHR animation pointer (#12767) · BabylonJS/Babylon.js@013d803 · GitHub

Could you repro the issue in a playground not necessarily with your toolkit but just to highlight that the function is not getting called ?

I think I know what is going with loadAnimationAsync not being called. I will try to make a fix for it soon.

1 Like

Thank you :pray:

Sorry for the delay @MackeyK24. I just wanted to let you know that I haven’t forgotten about this, but I am a bit swamped right now and it may take some time before I get to this.

1 Like

Ok… Gotcha

@MackeyK24 I’m working on this now, but the code needs to be changed quite a bit for it to work properly. This will take some time.

Ok… I’ll stay on 5.16 until then. Please let me know when you have it fixed. Thank you very much for fixing this issue.

1 Like

@MackeyK24 I have an updated version out in a draft PR. Can you check the (still not public) contract for the animation loading functions and see if it will suit your needs?

        context: string,
        animationContext: string,
        animation: IAnimation,
        channel: IAnimationChannel,
        onLoad: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void
    ): Nullable<Promise<void>>;

You can extend this function and call loader._loadAnimationChannelFromTargetInfoAsync if you want to change the target and/or use the onLoad callback to override where the animation is set.

@MackeyK24 The changes are now merged. Let me know if it works for you.