Questions about bone Animations

So if i had a situation where I had a set of bones that had a few animation ranges on them and wanted to copy it over to another skeleton (let’s assume they are the same rig) but wanted to do it manually for certain reasons. What data for each bone would I need to grab?

I see bone.animations[…]._keys and all the frame data, so I assume all that. The reason I want to do it manually is because I have situations where skeletons might not have the same bone structure but through a secondary function I have already identified what bone matches to which and am remapping the animations to the second skeleton. I said make the assumption that the skeletons are the same just to simplify the question the end goal will not have this always true though.

Looking at the serialize function of the skeleton, you can find the needed data to serialize each bone. I guess this will be the data required to duplicate it and apply it somewhere else:

for (var index = 0; index < this.bones.length; index++) {
            var bone = this.bones[index];
            let parent = bone.getParent();

            var serializedBone: any = {
                parentBoneIndex: parent ? this.bones.indexOf(parent) : -1,
                matrix: bone.getBaseMatrix().toArray(),
                rest: bone.getRestPose().toArray()


            if (bone.length) {
                serializedBone.length = bone.length;

            if (bone.metadata) {
                serializedBone.metadata = bone.metadata;

            if (bone.animations && bone.animations.length > 0) {
                serializedBone.animation = bone.animations[0].serialize();

            serializationObject.ranges = [];
            for (var name in this._ranges) {
                let source = this._ranges[name];

                if (!source) {

                var range: any = {};
       = name;
                range.from = source.from;
1 Like

Thank you, looks like I should look at the animations serialize as well.