ClipAction select range to play

Hello,
I’m trying to develop a speaking avatar. I have all the visemes in a unique animation (FBX) (I don’t know too much about this topic, I think it’s just one track…).
With next lines I can play the full animation.


var action = model.mixer.clipAction( animation_visemes.animations[ 0 ] );
action.play();

What I want to do is to play a range of the animation depending on the viseme.
For example:
For “A” viseme i want to animate frames from 2 to 4.
For “C” viseme frames from 8 to 10.

I have tried several things but without success.

Someone knows how could it be done? Help would be appreciated.

Thanks in advance.

1 Like

same here buddy, been giving me headache lately

Good luck.
I am going to be busy some days… Then I’ll keep looking for a solution. If I find it I’ll share it.

FBX only support a single animation track per file, and as far as I know there is no (easy) way to split the animation up like that in three.js. At least, I’ve spent a while trying it and never found a way.

So the best solution is to export multiple FBX files - one with just the model, and and then others with each section of animation, and then apply the animations to your model.

1 Like

Hello,
i’m also trying to find a solution for using multiple small animated actions made in Blender.
The best way could be to export all actions in a JSON file but unfortunately the Blender exporter doesn’t allow to export all actions :sob:… only the one selected in the Dope Sheet. ( am i wrong ? )
So actually ( before waiting the Blender exporter allow to export all animated actions ), the possible best idea could be to use one only looonnnggggg action and cutting it for making multiple actions. And in this case it could be great to play the ClipAction (From frame (x) To frame (y)…).
The other solution i found, could be to export each of my animated actions in multiple JSON files and eventually conbine them manually ( by copy/paste the "animations node content of each file and rename the initial “name”:“default”) into one single JSON file :unamused:
If someone here have a good way for dealing with multiple Blender animated actions, i take it ! or if someone here know how improve the Blender exporter :wink: !

The other solution i found, could be to export each of my animated actions in multiple JSON files and eventually conbine them manually ( by copy/paste the "animations node content of each file and rename the initial “name”:“default”) into one single JSON file

If you have to do this many times then you could easily write a script to do this.

Yes you right but before merging animations together i still need to dive into each exported JSON file for manually rewrite the “default” name

Hello,
because actually it’s just allowed to export one “Big” Action (and try to split it for doing small strips with different ranges to play…), i tried to modify the Blender exporter for making it available to export all Actions of the .blend file.

I am really really novice in Python scripting (for being honest : since this morning…) and really new on Github, so if someone experienced can watch what i did, check it and tell me if it’s good :wink:
Here is the pull request i did : https://github.com/mrdoob/three.js/pull/12646
Thank you for your help and advices

1 Like

Hi all,
i have the same problem. Having one animationclip and have to play it, for example, from second 5 to 8.

Are there any new ideas or methods to do so?

Lol I think there’s much demand for this playAnimation (begin frame, endframe)…tbh this killed off one of my project

Could anyone share a model with different animations in different ranges of the same clip? I would think you could do this, but haven’t tested:

// loaded from model or whatever
var clip; 

// poor man's "clip.clone()"
var clip2 = THREE.AnimationClip.parse(THREE.AnimationClip.toJSON(clip)); 

// trim each clip to times
clip.tracks.forEach((track) => track.trim(0, 5));
clip2.tracks.forEach((track) => track.trim(5, 10));

Perhaps a utility method to split clips in one step would be a good addition to the library.

Kupoman/blendergltf exporters also supports multiple actions directly, and is an option if you’re using Blender.

1 Like

here’s is one
mech(github link)

1 Like

Highly agreed. Exporting assets with animations set up something like:

Walk: frames 1-100
Run: frames 100-200
Jump: frames 200 - 250
etc…

is very common and recommended in many tutorials and books. Currently, there is no easy way to split these animations with three.js.

1 Like

Never quite that simple, I suppose. :sweat_smile:

Here’s a PR: AnimationUtils: Add .subclip(). by donmccurdy · Pull Request #13430 · mrdoob/three.js · GitHub

4 Likes