# plane.intersectMesh(mesh)

Hello !

Is it possible to have a method to know if a plane intersect a mesh without having to create a plane mesh ?

Something like:

``````plane.intersectMesh(mesh)
``````

``````const planeMesh = MeshBuilder.CreatePlane(
'intersectPlane',
{ height: 10000, sourcePlane: plane, width: 10000 },
scene
)
const result = myMesh.intersectsMesh(planeMesh, true)
planeMesh.dispose()
resolve(result)
})
``````

Thank you Maybe instead of a plane mesh you can create a mathematical plane and use signedDistanceTo(), to design your own intersectsMesh:

Here to follow intersectsMesh of BabylonJS:

Edit: Another idea could be:

``````const min = Vector3(1,1,2); // minimum boundingbox of your plane
const max = ...
mesh.getBoundingInfo().boundingBox.intersectsMinMax(min, max);
``````
1 Like

I finally found how to make it, for those who need it too:

``````import { Plane, Mesh, BoundingBox } from '@babylonjs/core'

// From: https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html
export const doesPlanIntersectBbox = (plane: Plane, bbox: BoundingBox): boolean => {
const e = bbox.maximum.subtract(bbox.center)
const r = e.x * Math.abs(plane.normal.x) + e.y * Math.abs(plane.normal.y) + e.z * Math.abs(plane.normal.z)
const s = plane.signedDistanceTo(bbox.center)
return Math.abs(s) <= r
}

export const doesPlanIntersectMesh = (plane: Plane, mesh: Mesh): boolean =>
doesPlanIntersectBbox(plane, mesh.getBoundingInfo().boundingBox)

export default { doesPlanIntersectBbox, doesPlanIntersectMesh }
``````
2 Likes