Importing Animation corrupt animation data. 3dsmax creating animationgroups

When I import my model with animation into my project I am getting bad animation data.

The same model works properly in the BabylonJS Sandbox viewer.

I am using BABYLON.SceneLoader.ImportMesh(,data.modelURL, data.file, scene, (newMeshes, particleSystems, skeletons) to import a GLB and BABYlON model both display bad animation data.

I am not sure why but when I replace the first parameter of the function with an empty string it works. I was using the targeted model name which made sense to me. It sounds like a bug to me.

BABYLON.SceneLoader.ImportMesh("",data.modelURL, data.file, scene, (newMeshes, particleSystems, skeletons)

1 Like

It should work by passing the name as the first parameter. Are you able to setup a repro in the Playground?

I can do that. For an accurate test should I use the .glb model that I created? If so is there a way to upload the model or should I host the model somewhere I have access to? I would think it would be easy to reproduce seeing I am using a model directly exported from the Babylonjs 3ds max exporter. I was trying to import it by model name. I don’t see many babylonjs examples doing this method. I was giving the option and it just seemed natural to me.

Oh the other thing with this bug was that it was breaking game loading in the IOS browser because it was trying to parse such a large number. Android let it happen but wouldnt play the animation

It does not matter, as long as you can reproduce the problem in the Playground.

Reproduced it. Circled all the elements in red.

Here is the playground

Learned something new in BabylonJS. You guys are doing a great job with this framework. Its got a learning curve but overall awesome work!

I think you forgot to save your latest PG or did not provide the right link as we can see dummy3.babylon in the PG, not woody :slight_smile:

You are correct. I still have a few things to learn :slight_smile:

Pinging @bghgary, it seems when loading a specific mesh from the gltf file not all animations data are loaded. I don’t know if it’s expected or not.

Sorry for the slow response. It’s been a busy few days.

I’m not sure I understand what is wrong. I don’t see bad animation data with this PG. I just see a whole bunch of empty animation groups. This is because the animation channels are ignored if they target a node that doesn’t exist. Since you only allowed the “Woody” name, all of the bone nodes are not loaded and thus none of the animations can target the bone nodes which results in all the animations getting ignored.

Thank you for your response. I understand. Why does it have the empty animation data from the imported file if it is not usable?

My suggestion for a better UX and to save some future dev time.

  • That the animation data doesn’t get imported OR it is complete animation data.
  • It throws an exception if someone does try to use this empty animation data with the same name of animation I created.
  • At the least, put 0 and not the large number that breaks the app on parse. Inevitably, you will be answering this question in the future on why is my animation data equal to 0?

All these would be easier than hours of debugging, digging through this forum, and docs for the answer.

I am new to Babylon. I love what you guys are doing, and I am committed to making this work.

That’s a fair point. The animation group should probably be removed if none of the channels got created. I will submit a fix for this.

Your original post is indicating there is some kind of invalid data. None of the values I’m seeing are invalid. The defaults of an animation group for from and to are -Number.MAX_VALUE and Number.MAX_VALUE respectively which makes sense in my opinion. Where does it “breaks the app on parse”?

Changed glTF loader to remove empty animation groups by bghgary · Pull Request #9537 · BabylonJS/Babylon.js (


I pasted an image above with the number. Testing on multiple platforms, Safari on IOS threw the parse error on -Number.MAX_VALUE when importing the GLB file. This is how I discovered the problem. You might find this in other places of Bablyonjs.
Chrome Android can handle the import but just wouldn’t play the animation.

Safari is weird. Are you saying the model didn’t load or it just logged something in the console?

You can say that again. It didn’t load breaking the script. JSON parse error. Trying to parse a large number.

Hmm, I seem to remember that JSON doesn’t support the full double number range, but I’m a bit confused why the code is using JSON to parse this number.

Yes, I agree.

I haven’t dived to much into the GLTF spec. Off the top of my head, what I remember it is using JSON for the raw model data. GLB I’m guessing is a zip package with the GLTF and textures all in one package. It sounds like the 3d model builder at one point of the system needs a JSON parser to build the model.

I understand the reason for the use of MAX and MIN Number, it might be safer to not use them in the model converter. It looks like you solved the issue by not including the animation data at all. When I see those MIN MAX numbers I do assume something went wrong. Showing a little empathy to your user could you have used zero? Avoiding those large numbers? It wasn’t obvious to me the BabylonJS untrained eye that it was an empty animation data. That would have read as an empty animation data. Start 0, End 0

Disclaimer: I am member of the Khronos 3D formats working group and have been involved in the glTF spec for a number of years.

Yes, glTF is based on JSON, but Number.MaxValue and Number.MinValue is not part of the parsing of the glTF file. I’m not sure where this is coming from. Will have to investigate to find out.

These values are the defaults of an AnimationGroup object. Showing Start 0 / End 0 maybe okay for the UI, I would not do it in the code as that will require extra logic. Also, Start 0 / End 0 is technically a valid range for an animation (i.e. one frame), so maybe the UI should just show something that indicates the group is empty.

1 Like