Importing animations from GLB [SOLVED]

I am moving from importing .blend to .glb but am having trouble importing GLB files with animations and I’m hoping someone can give me a hint of where to look.

I’m exporting models from Blender 2.8 using a script. The relevant line (with GLTF export options):

bpy.ops.export_scene.gltf(filepath=filename, export_materials=False, check_existing=False)

I then read the file with a standard assetsManager.loadModel(modelKey)

When the models do not have animations this works fine. Whenever I add an animation, no matter how simple, I get an AssetLoadException with the error message “Inconsistent animation sampling”

Checking the code throwing the exception, it reads:

public void checkTimesConsistantcy() {
    if ((translations != null && times.length != translations.length)
            || (rotations != null && times.length != rotations.length)
            || (scales != null && times.length != scales.length)) {
        throw new AssetLoadException("Inconsistent animation sampling ");

Which implies that the imported data has a mismatch in the animation keyframes. I suspect there is some set of options required in the Blender export operation to make the animations importable. I’ve tried various combinations of the timing and baking arguments but can’t seem to get it to work.

Reading back through the various topics about GLTF import I see a lot of discussion on importing animations and why it is hard. Has anyone had success export GLTF from Blender 2.8 then importing into JME? If so, do you have hints on what you know?

1 Like

yes, im using .gtlf to load models with animations.
you can see: Com.jme3.anim Skinning Help - #7 by IkeOTL

well, about “Inconsistent animation sampling”

you just need sample animations to Linear in Blender:

in Animation → dope sheet → select animation → all(a) and T → Linear (there were something else to set Linear, but as i good remember the needed one was T → Linear)

anyway i use .gtlf not .glb so not sure if it have some differences in animation load.


Thanks - that worked.

I feel it’d be worth having a section on the wiki about exporting GLTF scenes from Blender to JME to capture this information. There are equivalents for various other formats. I’d be happy to write it to make it easier for others - will start collecting findings as I go.


nice, wiki need updates :slight_smile:

here some i know in general:

Thanks that a great start - you ok reviewing it if put something together?

sure, i can look from my side if it will be fine :slight_smile:

I have created a pull request for the wiki with the added page. I kept it pretty basic at this stage but if you could take a look and let me know if you agree with the content that’d be useful.

Pull request is Document Blender to JME via glTF by sprinter-17 · Pull Request #98 · jMonkeyEngine/wiki · GitHub


Well, look fine for me if its about informations. Good work! :slight_smile: Just some mentions:

“Ultimately all jME projects should use the .j3o format for storing assets. However during development a format is required to export scenes from Blender in a format suitable for conversion (either through the SDK or directly through code).”

  • well, i dont think this sentence is necessary. maybe others will say if it should be here.

  • cant confirm all about .glb because myself i always export to .gltf

At export time, force the export to create interpolated keyframes using sampling. This can be done in Python using export_force_sampling=True or selecting Always Sample Animations in the Animation tab of the export function. By default a sample is created from each frame of the animation. This can be changed in Python using export_frame_step=n where n is number of frames between samples or changing the sampling rate in the Animation tab of the export function.

  • well, if i remember correctly i dont needed use it for “non IK animations” and anyway it didnt work for me well so needed bake animations anyway as i remember. but maybe they fixed it in new versions. Because as i understand this should do something like “Bake on export thing” if im not wrong. On their github there just is “Apply sampling to all animations.” but not sure about what sampling it is.

  • because currently i needed create dupplicated skeleton, bake animations on it, and export it, instead of oryginal skeleton. But if this is doing something else than i think then dont listen me.

Why don’t you think it is necessary?

i agree with word “should”, however each developer can use format he want to, so in some cases it might be wrong. Nothing more. i would rather say “.j3o is fast to load” if need.

Well, we could include like the 7 or 8 reasons you should use .j3o or just say it’s “the way”.

Anyone smart enough to know when it’s appropriate to “break the rule” will also be smart enough to know that they CAN break the rule.

If you give a noob a crack in the door, he will take it. Then we have 40 support questions about all of the problems that come later.

Just use .j3o. There is almost no reason not to. The only valid one so far is “I let users import their own models at runtime”. Every other one is really an anti-reason in disguise.

right, this way you are correct. dont need to be se precise, since it will create “crack in the door” like you say :slight_smile: