Issue with loading mesh and colliders and adding physics

Hey @Cedric, thanks again for your time.

I’ve looked into the work you did and your solution is not what I was hoping for. You use bucketMesh.parent = null; which ignores the scaling introduced by the __root__ mesh from the gltf import. This effectively flips the mesh and not desired, which is not apparent in this simple bucket example.

I’ve also tried checking out master and testing your PR for fixing the debug display, but unfortunately it doesn’t look like it’s working yet:

image

I have experimented a bit more with my playground and I found a working solution which I’m happy with: #CUDJRH#6. It seems to work with AmmoJS and CannonJS. I’ve added a lot of comments explaining why I think all the steps are necessary.

With this I think there are still 3 issues which is making this all difficult:

  1. There is still a bug in the physics debug viewer
  2. The babylonjs PhysicsImposter doesn’t work with a mesh with mesh.scaling.y = -1 (see #10283)
  3. The compound PhysisImposter system doesn’t work with root.scaling.y = -1 (which you’ll run into when importing gtlf)

For the latter, I’m not sure if this is something babylonjs should support. If not, I think the only real solution is to create a new root mesh when building the compound physics object, which is actually also explained in the documentation (Authoring and loading a mesh with a collider mesh), although a bit outdated.

I would like to hear your thoughts! Thanks!

Related:
https://doc.babylonjs.com/extensions/Exporters/Blender_to_glTF
https://forum.babylonjs.com/t/how-to-correctly-import-gltf-and-add-physics/20234/2