Is there a way to determine if an object (dbid) is visible by the camera at any point in time?
1 Answer
That depends on the precision you need, for example:
Is it enough to find out if the element is outside the camera view?
- This would be relatively straightforward and performant, as you could use
FrustumIntersectorto detect whether the bounding box of the element is outside of the frustum.
- This would be relatively straightforward and performant, as you could use
What if the element is inside the camera view but it's occluded by other objects? Do you need to detect that situation as well?
For this you'd need something like occlusion queries, however this is not supported by the Viewer SDK, so you'd need to build it yourself.
You could, for example, project and render bounding boxes of individual elements into a buffer (with colors encoding the IDs of the corresponding elements), and then check whether there are any pixels in the frame belonging to the element you're interested in. Unfortunately, since you don't have access to the underlying rendering pipeline, this would be very inefficient.