GLTF Separate animiation from model. no targeted animations

Anyone able to see why maybe i cannot import the animation and attach it to the model. when it gets imported, an animation group is created, however, the targetedAnimations variable isn’t loaded, so there’s nothing to actually attach to the model. both the model and animation pass kronos validator. Something must obviously be missing or wrong in the exporter i’m making for unreal 2k4 models…

cannot save the playground:
XHROPTIONShttps://snippet.babylonjs.com/CORS Preflight Did Not Succeed

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://snippet.babylonjs.com/. (Reason: CORS preflight response did not succeed). Status code: 400.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://snippet.babylonjs.com/. (Reason: CORS request did not succeed). Status code: (null).

playground source:

export const createScene = function () {
const scene = new BABYLON.Scene(engine);

scene.clearColor = new BABYLON.Color4(0.1, 0.1, 0.2, 1);



const camera = new BABYLON.ArcRotateCamera("cam", Math.PI / 2, Math.PI / 3.5, 15, BABYLON.Vector3.Zero(), scene);

camera.attachControl(canvas, true);



const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);



let skeleton = null;



BABYLON.SceneLoader.ImportMeshAsync("", "https://raw.githubusercontent.com/reddozen/split_animations/refs/heads/main/", "Sophie_Tristan.gltf", scene).then((result) => {

    const npcMesh = result.meshes\[0\];

    npcMesh.npcId = 0;

    skeleton = result.skeletons\[0\];



    BABYLON.SceneLoader.LoadAssetContainerAsync("https://raw.githubusercontent.com/reddozen/split_animations/refs/heads/main/Animations/", "NPC_G_Stand01.gltf", scene).then((container) => {

        const sourceGroup = container.animationGroups\[0\];



        console.log("Source animationGroup name:", sourceGroup.name);

        console.log("Source targetedAnimations count:", sourceGroup.targetedAnimations.length); // ← this will be 0 or small



        const newGroup = new BABYLON.AnimationGroup("NPC_G_Stand01_i0", scene);



        for (const ta of sourceGroup.targetedAnimations) {

            const boneName = ta.target.name;

            const bone = skeleton.getBoneByName(boneName);

            if (bone) {

                console.log("Retargeting bone:", boneName);

                newGroup.addTargetedAnimation(ta.animation.clone(), bone);

            } else {

                console.warn("Bone not found:", boneName);

            }

        }



        newGroup.normalize(0, sourceGroup.to);

        scene.addAnimationGroup(newGroup);

        newGroup.start(true);



        container.dispose();

    }).catch(e => console.error(e));

});



return scene;

};

I made a playground from the pasted code, and I see the console.log saying targetedAnimations is zero, but I don’t see the CORS errors.

The errors were coming from saving it to give the link here. I’m not worried about that. Trying to figure out what’s potentially wrong with the gltf files or the loader.

Thanks for posting a link

1 Like

I don’t think Babylon recognizes the animation data generated by the UE exporter. @alexchuber may know more.

I’ve been rewriting the gltf exporter from scratch. Normal animated models work fine. My ultimate issue is that the character model has 300 plus animations and thousands and thousands of keyframes. So the idea is to separate the animation files from the models because I also have to apply the same animations to hundreds of player equipment. Looking through the Babylon source code I don’t think that this idea is supported for skeletal meshes. I’m still testing ideas

If the skeletons are the same you may just retarget animations, importing them from GLB.

For example https://playground.babylonjs.com/#C2LL1F#18

2 Likes

@labris I may decode your glbs to see what tags are there. I could be missing something in my exports since they’re all custom unreal 2k4 to gltf exports uggg.

All my bones and child hierarchy matches between the base mesh gltf and the animation gltf. In theory it should all be there. Babylon creates the skeleton on the animation file, and the animation group, but no actual targetedAnimations.

@labris Thanks again for the working example. My issue was child bone definitions on 2 bones, and how i was loading the animations. Updating my export tool now.

3 Likes