Scene with 2 animation clips to merge into one "animation action" in the exported GLTF

I am able to export two rotation animations on corresponding two objects.

However what is created in the GLTF file is actually two animation sections called “action1” and “action2”.

What I need is just one final “action” since I want my 2 animations to be started at the same time.
I know GLTF can do this, because I have managed to manipulate the exported GLTF file so that my two animations are merged correctly into one single “action”.

This is the GLTF from three (only the animation part):

"animations": [
    {
      "name": "Action1",
      "samplers": [
        {
          "input": 8,
          "output": 9,
          "interpolation": "LINEAR"
        }
      ],
      "channels": [
        {
          "sampler": 0,
          "target": {
            "node": 0,
            "path": "rotation"
          }
        }
      ]
    },
    {
      "name": "Action2",
      "samplers": [
        {
          "input": 10,
          "output": 11,
          "interpolation": "LINEAR"
        }
      ],
      "channels": [
        {
          "sampler": 0,
          "target": {
            "node": 1,
            "path": "rotation"
          }
        }
      ]
    }
  ]

and here is my manipulated animation part:

"animations": [
    {
      "name": "Action",
      "samplers": [
        {
          "input": 8,
          "output": 9,
          "interpolation": "LINEAR"
        },
        {
          "input": 10,
          "output": 11,
          "interpolation": "LINEAR"
        }
      ],
      "channels": [
        {
          "sampler": 0,
          "target": {
            "node": 0,
            "path": "rotation"
          }
        },
        {
          "sampler": 0,
          "target": {
            "node": 1,
            "path": "rotation"
          }
        }
      ]
    }
  ]

So instead of having two separate samplers and channels they are joined. How can I do this in three?

CodePen here

Please help?

To export as a single glTF animation, you’ll need to put both KeyframeTracks into a single AnimationClip.

To do that, each track must specify its target object, rather than relying on the .quaternion track name implicitly being the root object of the mixer. So for example the name would be pentagon1.quaternion instead, and the mixer root would be any common parent of the two objects.

Thanks, that worked like a charm! However I then end up with a new problem, which is the fact that my pentagons are not spinning in the same speed, but with one clip they need to have the same length to avoid them to stop spinning. I will try to solve that with the keyframes.