Wrong animation order in exported GLB with NLA tracks

Hello all,

I’m having difficulties understanding how to control the order of my stacked animations in the NLA editor. I was certain that the exported GLB would follow the order of the NLA tracks in the NLA editor, but in my case my animations seems to be exported in random order.

I’m thinking that perhaps there could be some residue data that ruins the export order of the animations, but I’m not sure where to look for the culprit.

Does anyone know how to control the order of the animations reliably?

Anyone know what I’m doing wrong?

Just to check – you have multiple NLA tracks, and not multiple strips in a single NLA track, correct? a screenshot before/after export, or a .blend, or something might help us to guess what’s going on.

NLA Tracks are kind of a Blender-specific concept, and animations in a glTF file have a somewhat different meaning — for one thing, their order doesn’t really matter in glTF. So it’s possible the Blender glTF importer or exporter just hasn’t preserved the original sort order, which could be reported as a bug at https://github.com/KhronosGroup/glTF-Blender-IO. Each NLA Track can be given a unique name, if that helps, and the names should be preserved.

1 Like

Thanks for checking in. I’ve attached some screenshots here, but can not share the .blend unfortunately due to confidentiality reasons…

This first is the NLA editor where I have my stack of tracks/animations. I have named them with what I want them to be called in the 3D-viewer (Babylon Sandbox for example). The naming works as intended. I have also tried to remove the number and period from the name to see if that is the culprit, but the export results are the same.

This second is the order that the animations are exported. I was wrong about it being totally random though. But as you can see from the lines of codes, my animationGroups become the wrong order. animationGroup0, animationGroup1 and animationGroup2 shouldn’t be 5, 6 and 4 in the export. They should be 0, 1 and 2 (and so on). But somehow the order of the animations have been thrown off.

I can’t tell from these screenshots whether Blender exports the NLA Tracks out of order, or Babylon.js imports them out of order. To get anything to change you’d probably need to determine that and file a bug on one project or the other. Personally I would sort the array, it’s going to be a more reliable process that way:

animationGroups.sort((a, b) => a.name > b.name ? 1 : -1);

const [group0, group1, group2, ...] = animationGroups;

Thanks for cleaning things up :slight_smile: Appreciate the help.

I’m pretty sure Blender exports them in the “wrong” order in this case. They have the same order in the Microsoft 3D viewer as well…

I thought I’d update this thread with my findings, in case anyone else stumbles across the same issue I was having.

It seems that the animation order in the exported GLB follows the order in the Actions menu found in the Display mode - Blender File.

Blender file

This is how it looked at first when my animations were exported in the wrong order. This is the order that the animations were exported. It seems that this hierarchy controls the animation order of the exported .glb, regardless of the order in the NLA Editor. So from the top to bottom:

Right clicking the Actions/names and renaming them makes the animations export in the order I intended:

I have created the actions, but later on decided to change the naming of the Action. And the name is not updated automatically. So it seems that it wasn’t a bug after all. Or perhaps it is since the naming/order is not updated automatically in the “Blender File” when changing the names in the NLA editor.

2 Likes