Imported mesh collision with Camera ellipsoid - Requirements?

I have problems with few different imported objects. My camera (ellipsoid) sometimes just goes through the object very slowly and my camera gets stuck in it. I tried both checkCollision and physic impostors, but nothing seems to work.

-Are there any specific requirements how object should be made, that collision works without any problem?
-Is there any way to set (calculate) collision box of objects?

***Playground - Lines 39-50: https://www.babylonjs-playground.com/#PVAC9F#17

   BABYLON.SceneLoader.ImportMeshAsync("", "https://firebasestorage.googleapis.com/v0/b/universal-ar.appspot.com/o/stones_wall.glb?alt=media&token=13d89eb7-e4bf-4ab0-b408-ecdc4d2ad602", "", scene).then((result) => {
        var birds = result.meshes[0];
        birds.scaling = new BABYLON.Vector3(5, 5, 5);
        birds.position = new BABYLON.Vector3(-4, -10, 0);
     
        for (let i = 0; i < result.meshes.length; i++) {
            var meshAll = result.meshes[i]
            meshAll.checkCollisions = true;
            meshAll.physicsImpostor = new BABYLON.PhysicsImpostor(meshAll, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 0, friction: 1 }, scene);
        }

});

cc @Cedric

It is probably something about object specifications, because collisions work fine on some objects and on some not:

This one is pumpkin object: https://raw.githubusercontent.com/TrevorDev/gltfModels/master/customPumpkin.glb

Playground: https://www.babylonjs-playground.com/#PVAC9F#18

It will look much better if you would add camera.minZ = 0.1

Example - https://www.babylonjs-playground.com/#PVAC9F#19

As for other problems - check mesh normals, when they are inverted you will pass through them.

1 Like

Here is one of simple examples with collision setup - https://playground.babylonjs.com/#0VHCTL#32

1 Like

Check also negative mesh scales and double sided meshes.
Avoid negative scales as much as possible!

2 Likes

Amazing project. I just had some problems with walking stairs on my project. Thanks to you I also solved this problem by decreasing gravity. Do you know the exact requirements to walk stars = Correlation between camera ellipsoid, scene gravity and camera speed and size of the stairs? Just curious. If you change one of those things it doesn’t work.

Thanks