2
$\begingroup$

I have a scene where I have three cubes, rotating at the exact same speed. I want to export this to .glb so that only one animation is packed into the .glb, to optimize the file size. enter image description here

I have tried creating linked duplicates of the cubes so that they all share the same action. As you can see in this screenshot, there is only one action. enter image description here

But when I export to .glb, and check the file contents using https://gltf.report/, it shows that there are three animations in the .glb file (while only having one mesh): enter image description here

Is there any work around for this, or does my work just prove that .glb cannot support linked animations?

$\endgroup$

1 Answer 1

2
$\begingroup$

In glTF terminology, an "animation" is a unit of playback, a "channel" is a keyframe sequence within an animation targeting a single property of a single object, and a "sampler" containing "accessors" is the storage containing the channel's keyframe data.

In order to spin three boxes, you will always need to have at least three channels. Those three channels could be grouped into one animation for playback together, or separated so each can be played individually. In the screenshot above they are separate, but you can merge them by assigning each object an NLA Track of the same name in Blender — with default export settings, NLA Tracks with the same name are merged into a single animation at export.

However, whether there is one or three animations, there must still be three channels. This does not mean data is duplicated — all three channels can share the same sampler or accessors if exported efficiently. The https://gltf.report/ table shows the size of each animation, but doesn't show whether the animations share data or not.

If the animations did not share data (some exporters might not be fully optimized) you could detect and merge duplicate accessors by running this script in the https://gltf.report/ script tab —

import { dedup } from '@gltf-transform/functions';
await document.transform(dedup());
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .