When importing file from blender (using BabylonJS addon), armatures are lost?

Hi,
I am trying to export a simple cube with an armature inside from blender. When I export the cube and load it into the sandbox, I can see the armature and bones in the inspector. However, when I load the file into the playground using, like in the following code, the armature dissapears from the inspector (the entire skeletons tab is gone). Do I have to import some other way or what is the problem exactly? Thank you very much in advance!

BABYLON.SceneLoader.ImportMesh("", "", 'data:' + JSON.stringify(modelData), scene, function (meshes, particleSystems, skeletons) {
});

var modelData = {"producer":{"name":"Blender","version":"2.76 (sub 0)","exporter_version":"4.6.0","file":"test3.babylon"},

"autoClear":true,"clearColor":[0.0509,0.0509,0.0509],"ambientColor":[0,0,0],"gravity":[0,-9.81,0],

"materials":[{"name":"test3.Material","id":"test3.Material","ambient":[0.8,0.8,0.8],"diffuse":[0.64,0.64,0.64],"specular":[0.5,0.5,0.5],"emissive":[0,0,0],"specularPower":50,"alpha":1,"backFaceCulling":true,"checkReadyOnlyOnce":false}],

"multiMaterials":[],

"skeletons":[{"name":"Armature","id":0,"dimensionsAtRest":[0,3.0652,0],"bones":[

{"name":"Bone","index":0,"matrix":[1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1],"rest":[1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1],"parentBoneIndex":-1,"length":1},

{"name":"Bone.001","index":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],"rest":[1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],"parentBoneIndex":0,"length":0.9815},

{"name":"Bone.002","index":2,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0.9815,0,1],"rest":[1,0,0,0,0,1,0,0,0,0,1,0,0,0.9815,0,1],"parentBoneIndex":1,"length":1.0838}]}],

"meshes":[{"name":"Cube","id":"Cube","materialId":"test3.Material","billboardMode":0,"position":[0,0,0],"rotation":[0,0,0],"scaling":[1,1,1],"isVisible":true,"freezeWorldMatrix":false,"isEnabled":true,"checkCollisions":false,"receiveShadows":false,"skeletonId":0,"numBoneInfluencers":2

,"positions":[-0.2743,0.897,0.2743,-0.2743,-0.0422,0.2743,-0.2743,-0.0422,-0.2743,0.2743,0.897,0.2743,0.2743,-0.0422,0.2743,0.2743,0.897,-0.2743,0.2743,-0.0422,-0.2743,-0.2743,0.897,-0.2743,-0.2743,1.1148,-0.2743,-0.2743,1.1148,0.2743,0.2743,1.1148,0.2743,0.2743,1.8536,0.2743,0.2743,1.8536,-0.2743,0.2743,1.1148,-0.2743,0.2743,2.1056,-0.2743,-0.2743,2.1056,-0.2743,-0.2743,1.8536,-0.2743,-0.2743,1.8536,0.2743,0.2743,2.1056,0.2743,0.2743,3.0981,0.2743,0.2743,3.0981,-0.2743,-0.2743,2.1056,0.2743,-0.2743,3.0981,0.2743,-0.2743,3.0981,-0.2743]

,"normals":[-0.7071,0,0.7071,-0.5773,-0.5773,0.5773,-0.5773,-0.5773,-0.5773,0.7071,0,0.7071,0.5773,-0.5773,0.5773,0.7071,0,-0.7071,0.5773,-0.5773,-0.5773,-0.7071,0,-0.7071,-0.7071,0,-0.7071,-0.7071,0,0.7071,0.7071,0,0.7071,0.7071,0,0.7071,0.7071,0,-0.7071,0.7071,0,-0.7071,0.7071,0,-0.7071,-0.7071,0,-0.7071,-0.7071,0,-0.7071,-0.7071,0,0.7071,0.7071,0,0.7071,0.5773,0.5773,0.5773,0.5773,0.5773,-0.5773,-0.7071,0,0.7071,-0.5773,0.5773,0.5773,-0.5773,0.5773,-0.5773]

,"matricesWeights":[0.8258,0.1712,0,0,0.9877,0,0,0,0.9868,0,0,0,0.8257,0.1712,0,0,0.9868,0,0,0,0.8258,0.1712,0,0,0.9877,0,0,0,0.8257,0.1712,0,0,0.2042,0.7818,0,0,0.2042,0.7818,0,0,0.2042,0.7818,0,0,0.8013,0.1831,0,0,0.8013,0.1831,0,0,0.2042,0.7818,0,0,0.1482,0.849,0,0,0.1482,0.8489,0,0,0.8013,0.1831,0,0,0.8013,0.1831,0,0,0.1482,0.8489,0,0,0.9894,0,0,0,0.9903,0,0,0,0.1482,0.849,0,0,0.9903,0,0,0,0.9894,0,0,0]

,"matricesIndices":[256,0,0,256,0,256,0,256,256,256,256,513,513,256,513,513,513,513,513,2,2,513,2,2]

,"indices":[0,1,2,3,4,1,5,6,4,7,2,6,1,4,6,7,8,9,10,11,12,5,13,8,0,9,10,3,10,13,12,14,15,8,16,17,13,12,16,9,17,11,18,19,20,17,21,18,11,18,14,16,15,21,20,19,22,15,23,22,14,20,23,21,22,19,7,0,2,0,3,1,3,5,4,5,7,6,2,1,6,0,7,9,13,10,12,7,5,8,3,0,10,5,3,13,16,12,15,9,8,17,8,13,16,10,9,11,14,18,20,11,17,18,12,11,14,17,16,21,23,20,22,21,15,22,15,14,23,18,21,19]

,"subMeshes":[{"materialIndex":0,"verticesStart":0,"verticesCount":24,"indexStart":0,"indexCount":132}]

,"instances":[]}

],

"cameras":[{"name":"Camera","id":"Camera","position":[7.4811,5.3437,-6.5076],"rotation":[0.4615,-0.8149,0.0108],"fov":0.8576,"minZ":0.1,"maxZ":100,"speed":1,"inertia":0.9,"checkCollisions":false,"applyGravity":false,"ellipsoid":[0.2,0.9,0.2],"cameraRigMode":0,"interaxial_distance":0.0637,"type":"FreeCamera"}],"activeCamera":"Camera",

"lights":[{"name":"Lamp","id":"Lamp","type":0,"position":[4.0762,5.9039,1.0055],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]}],

"shadowGenerators":[]

}; ```

Adding @JCPalmer our blender exporter GURU

In the mean time could you share your export logs and model as I am sure this could help troubleshooting.

Here’s the files from the blender export, including model and log:
basic_armature.zip (3.2 KB)

It seems to work when I use the SceneLoader.Append instead of ImportMesh. Is it intended to work that way?

Can you repro in the playground to help troubleshooting faster ? This indeed sound strange.

https://www.babylonjs-playground.com/#D4ZZ8#73

Two models are imported, one of them default to the example and the other exported by me from blender. Both models should have skeletons according to the data string, but it is only shown in the inspector for the default model.

you newer export data does not contain “skeletonId”:0,“numBoneInfluencers”:2 meaning that there is no skeleton associated with the mesh.

Ping @JCPalmer to see if there is smthg obvious missing when you export to ensure the mesh is properly associated with the skeleton on export.

Aha okay… I must have done something wrong in blender then. Thank you for your assistance, I will go look closer at the blender documentation (I’m new to both blender and babylon, makes it difficult to troubleshoot hehe).

1 Like

Yeah, I had put the cube as a parent to armature, not the other way around. Problem fixed now, the skeleton shows up in the playground!

1 Like

Yep, I already answered this once already today. For future reference, adding an armature as the parent with automatic weights is the easiest way, but the export does not require this.

There may be times when you wish the mesh to be parented to something else, yet still have the armature. To do that right click, then Parent->Clear Parent and Keep transform. You can parent to something else.

1 Like