Group Animation and Morph Managers together

Hello everyone! I was around here last year and now I am back - I have been promoting the benefits of babylon js to my work colleagues and now they starting to listen to me, so hopefully I can be making some very cool bits and pieces (and maybe get back to a lab that I was working on in babylon :slightly_smiling_face: ).

I have been trying to solve a problem for the last three days. I have learnt some things and got confused on some others.

https://www.babylonjs-playground.com/#82ZN2R

The above playground shows a gltf of which I have brought in from the 3DSMAX Exporter. It is a conveyor belt with two cells (for now) moving along it. I have used the group animations to control the cell animations.

During the exporting I had done plenty of barbaric (on my part) testing of the animations. From what I have seen I cannot export out a position animation and a morph animation together - so I settled for a position animation with a view to alter the morph animation in registerBeforeRender.

So the problem comes down to something I hope is stupidly simple that it makes you guys chuckle a little and shake your heads.

Is it possible to get the current frame of the animation on the cells? They are called Object 419 and Object 420.

My view is - if I get the current frame of these animations I can incrementally update the morphs also.

I would also instead to clone these afterwards but I’ll cross that bridge when I come to it.

Hopefully this makes sense and if it doesn’t - or it looks like I am doing a stupid and you guys can suggest a better way could you set me off in the right direction?

Thank you all!

Adding @Drigax for the exporter and he loves animations too :slight_smile:

2 Likes

thank you kind sir!

I do love animation :slight_smile:

You should be able to do that, and have them all in a single animation group when exported. What happened when you tried that? I’m interested in fixing any bugs that may be present in the exporters.

I agree, again, it may make more sense to sequence your animation and morph targets in 3dsMax, rather than in Babylon.JS, but for a given animation group, the current frame isn’t really exposed directly on the animationGroup object, but one can get it via:

<animationGroup>.animatables[0].masterFrame

2 Likes

Hey Drigax - and good to hear from you.

Thanks for that little line of code.

Yeah I wondered why it wasn’t working that way - I’ll go through it with you for sure.


So in this first image I took the back cell that was moving along the conveyor belt. At the start of the animation - it’s morpher is at 0 and at the end of the animation the animation is at 100.


I then set up the animation groups. I think this is done right.


After this I export out the animation as a gltf and here’s the exports I used.

https://www.babylonjs-playground.com/#82ZN2R#2

Maybe I am doing something daft. But I have noticed in the past when I do not animate the position - the morph works in animation. weird.

I have noticed though sometimes I have three errors on the exporters from MAX. One means the morphs don’t seem to export. Referring to an invalid ID. Next time it happens I will stick it up for sure.

And here’s the error I was talking about - happens when I click on Group Animations and after it happens once I cannot use any elements in the scene again.

In fairness I can merge the old max scene into a new scene and it’s ok in there - but its an unexpected behaviour. This is for anyone with a similar problem.