Uses gltf-transform to process multple gltf files with different animations (shared joint hierarchy) and merge them into a single output file containing the collected animations. The original use case was taking Miximo mocap data files which had been exported to fbx's and converted to glb's. To have one glb file per character with all animations, blender could be used to manually gather the animations onto one skin in the NLE. This can be a bit slow and error prone with many animations, so gltf-transform scripting to the rescue! The merged glb can be further optimized by running gltf-transform-cli with the options to recompress textures and geometry (draco).
Merge files were tested in babylonjs and gltf-report.
Node.js (v24+)
git clone https://github.com/WhileRomeBurns/GLTFMergeAnimationsnpm install
Call the script through node with a list of files to merge. The last file is the output of the merged animations. This script assumes that all animations reference the same joint names. Example:
node app.ts run01.glb walk01.glb idle01.glb merged_output.glb
Alternatively, pass in a directory of two or more glb files. The output file will take its name from the directory:
node app.ts /path/to/glbs/example/
and results in an output file next to the example directory:
/path/to/glbs/example.glb/path/to/glbs/example/
Use the included gltf-merge-animations.bat to call node and run app.ts by including an alias in your powershell user profile:
Set-Alias -Name gltf-merge-animations -Value "C:\path\to\GLTFMergeAnimations\gltf-merge-animations.bat"
and the directory example above becomes:
gltf-merge-animations /path/to/glbs/example/