I am having trouble trying get working correctly an export from blender which is a scene with animations.
-
The object within the scene becomes dislocated even though I did not apply transformations to the location in Blender, I’m not sure why it becomes placed at world.zero
-
the animation looks nothing like it does within Blender though I made sure to apply scale/rotation transformations.
-
this is how I’m starting it: scene.getSkeletonByName(‘Armature’).beginAnimation(‘ArmatureAction’, true)
This is the result:
This is where it’s supposed to be and how it’s supposed to animate:
queue the clown music
Are you able to test your file in another glTF viewer (like https://gltf-viewer.donmccurdy.com/), assuming you are exporting your models to a gltf file?
That will tell us if the problem is with Blender or Babylon.
Thanks for your reply!
Should I have been exporting the scene as .gltf instead of a .babylon file?
I went ahead and exported to glft instead of babylon and used that viewer as you suggested and the animation works fine in the viewer and is where it’s supposed to be.
Could it possibly be that I’m ticking/unticking an option within the babylonjs exporter that affects it? Or maybe even that because the animated mesh should be in it’s own individual file?
Does the glTF file work in the sandbox? That would mean there’s a bug somewhere when exporting the file to .babylon format…
I think we will need the blender file to go further, if you can share it.
Bumping this. Hoping someone can help me!
@tonyfirgun please, bear with us during the vacation period I am pretty sure the community will come back to you soon.
1 Like
I know nothing of Blender, so I have just installed it (latest version), exported the scene to a .glb file and opened it in the sandbox: the animation was ok.
So it seems it’s a problem with the Blender exporter.
cc @JCPalmer in case he can help (he is the father of the exporter).
1 Like
Well, I triaged the blend file by deleting everything but the Lamp mesh and the armature. Found there was also a shapekey on the mesh.
A big debugging problem with .babylon format is that armature, or skeleton animations do not start in the sandbox, where as .glb files with the same animation do. Technically it is not the format, but the fact the exporter works with Animations, not AnimationGroups. They did not exist in 2014.
I have just kind of abandoned the export of armature animation in my own work. Still do armatures, but then IK animation in sort of my own animation studio directly posing right in javascript. No transfer debugging EVER, since the animation was made in the final system. Also, no re-export just to change the animation.
First thing to try is parenting the mesh to the armature. It is not technically required for export as you found, but your mesh has location values which are not all zeros. This has been the cause of most situations like this. Once parented, do an Apply all Transforms
.
Your animation simple enough to possibly also work entirely as a shapekey animation. Those do play in the sandbox, since they are newer & exported as an AnimationGroup.
1 Like
Thank you guys for all your help. I apologize to not consider that everyone is celebrating the holidays.
So within Blender, I had to bring the mesh back to world origin and then apply transformations because in babylonjs the armature world be at world.zero even though it wasn’t in blender but after that it worked! The only problem now is that I’m not able to move the mesh/armature from world.zero in babylonjs to where it’s supposed to be in Blender, it would just stay there no matter where I moved it in Blender. Is this just the case for skeletons and that it should be it’s own separate model? or am I supposed to move the skeleton within code to the mesh?
Thanks again!
It should work. Try to move the root node, the one named __root__
.
The __root__
transform node is for GLB based exports. Try
mesh.skeleton.bones[0].setPosition(new BABYLON.Vector3(1, 2, 3));
Or at a still lower level, something like
mesh.skeleton.bones[0].getLocalMatrix().setTranslation(new BABYLON.Vector3(1, 2, 3));
Bones[0] is the root bone. The entire array of bones are ordered such that if processed in ascending order any later bone is a child of an earlier one. So ‘0’ is root bone.
Also, you hava a very large set of meshes. almost none of them move. You are going to occur a large overhead Every frame. You can avoid this by freezing the computation of the world matrixr on a mesh by mesh basis (including the Lamp mesh, since it is the skeleton that moves).
This could also be done in either load code (I consider this to almost be a bug to wait till then though), or in the sandbox and re-export from there. There are 2 major problems with exporting there though:
- If you change something in Blender, you have to redo the process.
- The exporter in the sand box does not do any precision reduction like the Blender exporter. Depending on the browser & if you have a 64 bit OS, you could get 16 characters of precision.
0
then becomes 0.00000000000000
. For meter scaled stuff, that is like an Atom level precision positioning. A total waste of bandwidth to transmit.