Using moveWithCollisions with imported GLTF boxes

For some reason, when importing meshes, the collision when using moveWithCollisions() seems to be off.

Here is an example with created boxes, which works correctly:

Here is an example with an imported glb file, where the moving box goes through other colliders:

Am I missing some kind of import settings?

cc @Cedric

1 Like

Let me take a look …

1 Like

@Sem

I think it’s relative to the mesh being double sided. Not the material but I think all the triangles are doubled?
I checked that with the inspector. Setting the material front sided faces didn’t change anything.

Try again with single sided faces and let me know if it works.

1 Like

@Cedric Hey thanks for the response! Sadly, this is not the case. I enabled backface culling in the material and used a “merge by distance” in Blender, it did remove multiple vertices but the problem still persists.

You can see the exported GLTF cubes at https://test.zuncreative.com/col.glb

I need to dig deeper. I’ll do it in the coming days.

1 Like

Thank you so much! :smile:

I did some more fiddling around and found that scene.useRightHandedSystem = true; solves the random collision issue, so the collision might be a problem because the Z scale of the root is -1 because of the GLTF import.
movewithcollisions | Babylon.js Playground (babylonjs.com)

It still feels like the collider boxes are smaller than the meshes even though they are scale 1.

1 Like

Ho! good catch! it will definitely help me track the issue

3 Likes

The issue is actually the collider(player cube mesh) is still attached to the root (with negative scale)
if you set its root to null, then everything is fine.

2 Likes

Hello @Sem just checking in, are you still having issues? :slight_smile:

1 Like

Hey, sorry for the late response. I was on holiday :slight_smile:

When setting meshes parents to null definitely solves the issue.
I do think importing GLTF meshes in a negative scale is a fundamental problem, had multiple issues with it over the years. But I do not know the philosophy behind it.

Unfortunately we have to do it to convert between GLTF’s right handed system to our left :confused:
image

Thanks for the explanation @carolhmj and even though it might take more time to load, I’d rather have something like vertices recalculated instead of applying this negative scale.

You can use Mesh | Babylon.js Documentation (babylonjs.com) bakeCurrentTransformIntoVertices to do that :smiley:

3 Likes

Hey @carolhmj , thanks so much for sharing. I’ll try this one for sure.

1 Like