three-m2loader icon indicating copy to clipboard operation
three-m2loader copied to clipboard

Synchronize animations with different durations

Open Mat2095 opened this issue 5 months ago • 5 comments

I've noticed an issue with the WotLK-Version of the airelemental:

https://github.com/Mugen87/three-m2loader/assets/11258252/9ef99c1b-b53e-48e2-8fa1-e174122d81df

When playing the death-sequence, the "main body" of the elemental should disappear, but that doesn't work. This is because the sequence consists of animations with different duration. Some are 3 seconds long, but some (those that fade out the body) are only ~0.9 seconds long. They set the opacity to 0 right at the end of those 0.9 seconds, but then the animation already loops and opacity is back at 1. Instead the animation should wait until all animations of that sequence are finished. This is almost the opposite of #13.

I tried synchronizing the animations in this commit: https://github.com/Mugen87/three-m2loader/commit/fcbeb7b26b127678193d46dcdf27c908ad842b26 And it works for that case:

https://github.com/Mugen87/three-m2loader/assets/11258252/e75d9ae8-e0f5-4b72-868d-3309e9a93f25

That looks like it does in game, except the hands and eyes should disappear as well, not sure what's the issue with that.

But I'm not too happy with the code as it really takes active control over the animation-orchestration. I'd rather let tree.js handle it, but I don't think that's possible, since the animations might have different root-objects and thus different mixers, which is why I couldn't get it done with https://threejs.org/docs/index.html#api/en/animation/AnimationAction.syncWith (according to ChatGPT, I have no idea if that's true). Also I have no idea if doing it this way is always correct or if for some sequences this is wrong. Especially since the death-sequence doesn't really loop ingame anyway, so having the animations loop doesn't make sense. But for sequences like Stand/Walk/Run, maybe it is correct that animations loop individually instead of waiting.

Mat2095 avatar Jan 10 '24 23:01 Mat2095