I am actually working on a understanding the concept of a animation mixer and animation action objects for two different cases.
A. when different parts of a model each have one animation clip.
B. when only single part have multiple animation clips.
In case A I seem to notice the start time and end time for clip are in relation with the other animation clips for example first animation is of duration 4 where start time is 0 and end time is 4. the next clip is of duration 9 (Previous duration(4) + current duration(5)) where start time is 4 and end time is 9 and so on. which makes sense totally.
In case B the start time and end time is independent of the other animations for example first animation duration is 2 and start time is 0 and end time is 3, for second animation the duration is 4 and start time is 0 and end time is 4. and so on.
Is that how three.js animation mixer works internally? If I am not wrong.
everything seems to work fine in case A I can create action and play pause the specific animation as I want. Similarly for Case B implementing some code I can also play and pause the animation.
But i want to delete a specific clip for case B. Below is my function which gets the selected clip i want to delete with object id and index of the clip. I then remove the clip from my global ClipObject and animation object. But the issue is since start time for every animation is 0 for case B i cannot create a gap for that perticular timeframe. After deleting when i play all the actions the animation is performed in very weird manner. it sometimes play the last animation first after deleting the clip, action and mixer.
RemoveAnimationClip(clip, cId, index) {
const animationClipsByPart = AnimationClass.animationClipsByPart;// Object contains all animation clips
const animationActionsByPart = AnimationClass.animationActionsByPart;// Object contains all animation actions
if (animationClipsByPart[cId].animations.length > 1) {// CaseB if single part have mltiple animations
if (clip.name === animationClipsByPart[cId].animations[index].clip.name) {
animationClipsByPart[cId].animations.splice(index, 1);
animationClipsByPart[cId].part.userData.animationData.splice(index, 1);
animationActionsByPart[cId][index]._mixer._actions.splice(index,1); // As the hierarchy for animation action objects holds all animation actions for that part removing this specific mixer might be also creating a problem i am not sure. is it the right way?
animationActionsByPart[cId].splice(index, 1);
}
}
else {// CaseA if part have single animations
if (clip.name === animationClipsByPart[cId].animations[index].clip.name) {
animationClipsByPart[cId].part.userData.animationData.splice(index, 1);
animationClipsByPart[cId].animations.splice(index, 1)
animationActionsByPart[cId][0]._mixer._actions.forEach(function (item, i) {
if (parseInt(item._clip.name) == cId) {
animationActionsByPart[cId][0]._mixer._actions.splice(i, 1);
}
});
delete animationActionsByPart[cId];
}
}
};