Is there any way to detect if a GUI or Mesh behind camera

I have added multiple points in a mesh and i attached a spheres in those points, and in that sphere i have attached one gui element circle number to mark those points as 1 2 3 4 etc. And the sphere isVisible set to false, so the spheres will be hidden only gui numbers are shown. I was creating ray onAfterRenderObserbable from sphere to camera, if this ray intersects any main mesh it is not in front of camera other wise it is in front of camera. By creating ray on each render cause lag when multiple positions available. Can any one give me other example of checking mesh or gui element is front of camera kr behind camera?

Does this help?

Sometimes knowing the term is enough to get started. Looking for meshes in the frustum.


No it doesn’t work

what did you try?

sphere completely in frustum | Babylon.js Playground (

This is my playground link , you can add point just click add sphere then click anywhere in the mesh, then move around you can see that the gui elements opacity is 0.3 when it is behind any mesh, currenlty i’m doing this by sending a ray from point to camera on each render, which causes lag issue when i have multiple points.

See my answer in this post, but only the last part:

Quoting myself: