GLTF Split animations and CrossFade them


I have a model .GLTF with 3 animations in an array.

I make this to split the animations with successful

So, when I call the crossFadeTo not work.

Please have a look at this example:

It uses crossfading in order to transition into a new animation.

I made this.

SetWeight and play action, but the animation subclip is wrong… my model animates and freezes, after 2 seconds, he continues playing.

When I play full animation works fine, however, when I split the animations (subclip), it break.

var idleClip = THREE.AnimationUtils.subclip(animations[0],'idle', 30,40)
var idleAction = mixer.clipAction(idleClip); //don't work fine.

@Denis_Ken please provide enough information for us to fully reproduce the problem — code, your model, and ideally a demo. And please explain what you mean when saying it doesn’t work — does it look incorrect? does nothing happen at all? are there errors in the JS console?

Demo is attached. (Scripts, mongoose localhost and model)

Sorry, for the texture, but I can’t share.

Pay attention in animation, he plays, stop and play again, but I set “subclip” 30 to 40.

It works fine If I play mixerAnimations without subclip. But sequential

The model has blend shape and normal animation. (1.0 MB)

1 Like

Without the original .blend file I am guessing a bit, but to confirm — you want keyframes 30–39 to be split into a separate clip and played? The glTF file contains many keyframes, some tracks more than others:


I’m guessing that’s not your intention… Note that the Blender exporter may “bake” your animation at 24-30fps under certain circumstances. If that happens, you won’t be able to split the animation cleanly like you want to do. Some options:

  1. Try using linear interpolation for all keyframes, which may prevent the Blender exporter from baking keyframes.
  2. Try using the (WIP) version of the Blender exporter here, which can export multiple animations as separate clips.

The 3D artist have just one timeline with bone animation and shape key animations of the character. And want to export it as one, like the flow with Unity. one animation sequence of bone and shape animations, and in code split the frames in sub loops to cross fade between them.

(blend file)
bot.blend (1.5 MB)

I see. The issue you’re running into is discussed here — the exporter is not providing data that can be split into frames.

Until that is fixed, you can try the two suggestions above, or perhaps export to another format. I tried COLLADA and FBX quickly — COLLADA didn’t load, but FBX and FBXLoader might work. The keyframes looked much closer to your original timing.

Perhaps there are changes to .subclip() that would support this better (slice by time, rather than number of frames, and automatically appending starting frames where needed?) but at the moment I don’t have time to investigate that.