Rigged + animated objects disappear when rotating the camera

Hello there!

I built a simple drone in Blender (2.83) with a body and two wings. The rig is made out of two armatures, one for each wing, both are parented to the polgyon body. There are 3 animations in the file.The drone should go up and stay in the air, while the wings should loop rotate in different directions.

After importing the rig in Babylon JS the animations work fine: the body goes up and stays in the air, while the two wings are rotating/looping proberly.

The problem: When rotating the arc camera around the model, the skinned parts (wings) disappear or get culled by the engine in certain angles/distances. In Babylon sandbox all objects stay visible, when rotating the camera around. Here is a link to both videos: [https://we.tl/t-BwCs1LsT3G]

If the take off animation doesn´t get triggered and the body stays on the ground, all objects stay visible,when the camera rotates around it, even from below.

Does anyone recognize this problem?

I would be very happy, if anyone knows a possible solution:)

Kind regards
Chris

It’s probably a problem with the bounding box: the bounding box does not get recomputed at each frame, because the computation is done in the shader and the shader can’t pass data to the javascript side (it could but it would impair the performance): display the bounding boxes, you should see they don’t fit your animation and the meshes disappear when the boxes are culled.

The standard way to deal with that is to set a bounding box manually that encompasses all the frames of the animation. Or a simpler way is to simply instruct the engine to always render the object (mesh.alwaysSelectAsActiveMesh = true).

…and welcome aboard!

2 Likes

Thank you for the fast reply and the welcome:)

( mesh.alwaysSelectAsActiveMesh = true)

What parts of my rig do I have to give this command to? To all the single geometrie pieces, that disappear?
Or only the root geo?

If your object is not made of a single mesh, you need to set this on all meshes that make your object.

Thanks.
I will give it a try!

Especially with the arc rotate camera, one other thing that can be an issue is the camera.minZ clipping your mesh for being too close.

If this is an exported camera from Blender, .babylon exporter not GLTF, you can change the property in Blender, via clip Start property.

Camera

1 Like

@JCPalmer:
Thanks for the hint, but the clipping plane already was 0.01 to 20000.

@Evgeni_Popov:
It worked:) …but only with the simple block model at first .
So I got a bit confused, that your command worked on my simple low poly mesh but not on my textured and highpoly mesh. So I checked some material stuff, because you mentioned something about the shader. In Blender I deleted all object materials (plural!) and assigned a new material to the skinned geo. After importing it back in Babylon, it worked. The problem with the highpoly mesh was, that there were more than one materials assigned to the geo (multitextured). After splitting the mutlitextured object into many objects with only one material assigned, I could tell each individual object in the Babylon code to always render. Thanks for your quick help!

Kind regards
Chris

Glad it finally worked for you, but a single object with multi materials (so multiple sub-meshes) should still work in Babylon I think…

Glad it finally worked for you, but a single object with multi materials (so multiple sub-meshes) should still work in Babylon I think…

The multitextured object is rendered correctly in Babylon, yes, but when I set the “AsActiveMesh”-command to the multitextured/ submeshed “rotors_02”, the mesh disappears, when the bb gets out of sight and ignores the command. It doesn’t do so, if there is only one material attached in Blender.

Maybe there is a special command in Blender to merge objects with multiple materials together, so this error doesn’t occur. Not sure, I´m coming from Maya :wink:

As I can see it in the code, if a mesh has alwaysSelectAsActiveMesh set to true, then all its sub meshes are rendered unconditionally…

If you can share the exported babylon scene when meshes have multiple materials in Blender, we could have a look.

I have not been able to determine if this is a .babylon of .glb file. Only the .babylon file use sub-meshes as that is specific to BJS.

GLTF exports multiple meshes for meshes with multiple materials. They are almost the same thing from a draw call standpoint. Infrustrum would be done the same though.

GLTF is non-native, right handed, weird shit that I have made no attempt to assimilate in my thinking. Doing so would confuse the hell out of me writing a.babylon exporter.

@JCPalmer: I exported a .glb file with integrated textures in Blender. Is it also possble to export a .babylon?

@Evgeni: Here is a link to the multitextured and submeshed drone: [https://we.tl/t-eVWuKhxKtz]

My line of code in Babylon:

let mesh_bus = this.scene.getNodeByName(‘rotors_02’)
mesh_bus.alwaysSelectAsActiveMesh = true

The line doesn´t have any effect on the multitextured meshes, but only if the “rotors_02” mesh is singletextured.

I think there’s a problem with the glb file you linked to: nothing shows in the sandbox and there are a bunch of validation errors.
image

Yes, I´ve seen it too and didn´t know, what the problems were.

But when loaded in our babylon code (not the sandbox), there are no debugging errors in the browser and the object loads just fine. So, I ignored them.

Yes. As a .babylon is a JSON text file, they are encoded as base-64. This makes the file bigger than the sum of individuals, but since a text file is transmitted as gzip, and .jpg / .png cannot, the load time is not really effected.

The way exporter properties are handled is different than most Blender exporters. They are spread throughout the data properties on World, Mesh, Material, & Camera, and saved with the .blend. This allows different settings for each object, like mesh, as well.

You have to turn on inline textures with world exporter properties:

1 Like