Advice on camera/mesh to mesh collision detection (poor performance when checkCollisions=true on large meshes)


I’m currently facing some confusion regarding the implementation of native collision detection and the usage of a physics engine for camera movement in my project. Specifically, I’m trying to achieve camera movement using the WSAD keys while allowing the camera to interact with imported meshes by “picking” items upon collisions. These items can vary in type and quantity and are randomly distributed within the scene.

To enable collision detection between the camera and meshes, I have set the checkCollisions property to true. However, I’m encountering significant performance issues when the picked mesh is relatively large. This issue disappears when I have checkCollisions enabled for the imported meshes.

I have employed the camera.onCollide event to handle the collisions. Nonetheless, I’m seeking guidance on the optimal approach for this specific use case of camera movement and collision detection with objects.

My questions are as follows:

a. What would be the preferred strategy or best practice for implementing camera movement while colliding with objects, taking into consideration the requirement to “pick” items upon collision?

b. Is there a way to define a physics body when utilizing checkCollisions=true?

Any insights, suggestions, or solutions regarding these matters would be highly appreciated.

Thank you all in advance for your time and expertise.

one possible approach - creating a child collider mesh which is more simple, however in this approach I end creating a physics body and a collider so it fells a bit off

For large complex models simple colliders are quite good.
Also, try to disable picking on all meshes except needed ones.

1 Like

You could also forgo the use of checkCollisions, create a collider body for the camera and do everything with physics

1 Like

sounds like a right approach, any chance you have a playground with that?

I set up a very simple example here: Babylon.js Playground (

There’s more than one way this can be done, of course, but in this case I elected to parent the camera to the collider body and do all the movement in that collider body. I’m also updating the collider’s position directly instead of using forces/impulses as that’s simpler, but using forces/impulses would result in better collision response.