How to import gltf animation with bones from blender and set range to play

animation

#1

I current studying at importing bone animation from blender . I build small animation contain a walking cycle from frame 70-90. I load it in three and trim its range using the method in topic ClipAction select range to play

function loadOk(src) {
        source = src;
        for (let i = 0; i < src.animations.length; i++) {
            let clip=src.animations[i];
            clip.tracks.forEach((track) => track.trim(70, 90));
        }
    }

when play this trimed animatio in three.js . It played well if there is no trim. Once trimed ,It never play and display the last frame . Is there something wrong .I can’t figure it out , help please
my model file
walkingBomb.bin (13.6 KB)
walkingBomb.gltf (37.4 KB)
walkingBomb.blend (651.2 KB)


#2

glTF supports multiple animations unlike some other formats, so the best thing here would be to create separate Actions in Blender, Stash or Push Down each action as an NLA Track to mark it for export, and then you’ll have each available separately when you load it. You can test in http://gltf-viewer.donmccurdy.com/ to make sure the animations are all there.

If you are sure you want to use a range of keyframes this way, check out the code in this PR for an example of what to do.


#3

Oh , thank you . In fact , I really don’t like the old fashion of setting a range. If blender has a new way , I’d be glad to research it


#4

I have successfully load NLA Track to Three.js scene . I want to arrange them to achieve my needs. Now I encounter new problems. I build a animation use a bone to close a parachute. The result is not as accurate as its in blender. Do you have any idea? Does gltf support bone scale?

as you can see in the video. The parachute is not fully shrink back. Why?

I have use gltf viewer to check the model . It’s ok in the gltf viewer.
walkingBomb.bin (9.7 KB)
walkingBomb.gltf (55.8 KB)


#5

glTF does support bone scale – do you see the same incorrect animation in http://gltf-viewer.donmccurdy.com/ and http://sandbox.babylonjs.com/? If so, I would suggest filing a bug on the exporter.


#6

single animations displayed correct in your gltf viewer. The wrong result occur when I stop one and play another one . But I got correct result when I use the method fadeToAction , I copy it from example https://threejs.org/examples/?q=anim#webgl_animation_skinning_morph. I shall do more test and give more accurate questions
thank you