Determine if picked point is on visible side of clip plane

Hi all,

I’m trying to determine if a picked point is on the rendered (visible) side of a clip plane or the hidden side.

I’ve been trying to work out the math for it, but I’m not having much luck. Can anyone help point me in the right direction?

The use case is to see if the picked point in the scene is on the hidden side of the clip plane or the visible side. If it’s visible, I want to do something with the mesh. If it’s on the hidden side, I don’t want anything to happen.

I’ve set up the playground with a plane - https://www.babylonjs-playground.com/#Y6W087#174

Any help is greatly appreciated :slight_smile: Thanks!

you could rely on the dot product with the picked normal for this to know if they are facing the picking direction or not:

https://www.babylonjs-playground.com/#Y6W087#175

1 Like

I think it’s possible for a point behind the plane to have its normal pointing toward the viewer, it’s all depend on the geometry.

You can simply plug the point coordinates into the plane equation and check the sign of the result to know if the point is on a side or the other of a plane.

To know what is the right sign to check, you can plug the camera coordinates into the plane equation: the sign of the result is the sign you want to check with.

See:
https://www.babylonjs-playground.com/#Y6W087#177

1 Like

Thanks so much, @Evgeni_Popov and @sebavan - that’s awesome. Works perfectly @Evgeni_Popov !