How to consider if coordinates are in current view

I tried to use Camera.computeViewRectangle to get a rectangle and then use Rectangle.contains to compute if the location is in current view.

But the computeViewRectangle always returns {west: -3.141592653589793, south: -1.5707963267948966, east: 3.141592653589793, north: 1.5707963267948966} when the camera look at the whole planet.In this case any coordinate is inside the view rectangle which is not right.

I can see why it might return that result (a coordinate on the other side of the globe is technically in this view rectangle, but it’s not visible because it’s occluded due to the surface of the globe itself). I know we handle this as a special case for billboards by checking if they’re on the other side of the globe and hiding them in that case.

If your goal is just to see if a given point is in the viewport, you could use this function to get the 2D window position of a 3D coordinate:

And then figure out, based on the known window width and height, whether that’s in view or not.

Let me know if that helps!

Thanks for your reply!
Transform#.wgs84ToDrawingBufferCoordinates is not what I am looking for.I want to find a way to check if coordinates are on the other side of the globe,so I can hide/show my HTML Overlay.

1 Like

I know billboards automatically do this, but I believe this check happens on the GPU in a shader (see

You could use a billboard for this overlay (but then it would have be an image or something like that). Another option is to use Scene.pick which tells you what object is under this mouse position. If it’s the globe, then that HTML overlay should be hidden. If it’s an entity (so you’d place a placeholder entity in the world at that same position as the HTML overlay) then the overlay should be visible.

Let me know if these approaches work or if you find something that works better.

hi,do you have any solution to solve this problem? I’m looking for solution too. thanks!!:smiley: :smiley: :smiley: