Is there any other method to check collision between meshes except intersectsMesh?

When I use intersectsMesh to check mesh collision with a lot of other meshes, the frame rate is very slow. Is there any other method to check collision between meshes except intersectsMesh?

I believe you may use onCollideObservable - Babylon.js docs

onCollideObservable can be used to check collision enter. How to check collision exist?

mesh1.actionManager = new BABYLON.ActionManager(scene);

mesh1.actionManager.registerAction(
    new BABYLON.ExecuteCodeAction(
        {
            trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,
            parameter: mesh2
        },
        function() {
            console.log("Mesh1 collided with Mesh2!");
        }
    )
);

The same with BABYLON.ActionManager.OnIntersectionExitTrigger

1 Like