Given a Mesh
and a PerspectiveCamera
I would like to find the faces of the Mesh
that are currently visible in camera frame.
I'm not looking for occluded / non occluded faces. Just those faces that are inside or outside the camera frame.
For example, I have a sphere and a camera looking at it. Initially the entire sphere is visible. As I zoom in, some faces would be rendered outside the camera frame and some other will still be within the camera frame. How can I find them?
Asked
Active
Viewed 101 times
1

lviggiani
- 5,824
- 12
- 56
- 89
-
1Is it like [this question](https://stackoverflow.com/questions/47585717/three-js-find-the-subset-of-faces-visible-to-camera-at-a-given-time)? – kelsny Nov 11 '22 at 15:10
-
Is this intended for performance or for some specific application? Explaining your application might help give the proper recommendations. You can always iterate through your triangles and compare them with the camera frustum on the CPU, each frame. but I suspect you are after something else. – Berthur Nov 11 '22 at 15:23
-
@Berthur it's for a specific application and performance also. As I zoomin I have to load higher resoltion textures and get specific area information. This is time and traffic consuming if I do it for all faces. So I want to limit the operation to visible faces only. A kind of Google Earth for example – lviggiani Nov 11 '22 at 15:53
-
1@lviggiani What you're after is termed frustum culling. If it's for performance, it's not often a good idea to do frustum culling on triangle level, beacuse you will spend more time doing this calculation than rendering it in the first place. Rather, if you have objects, check if the entire object (its bounding box) is outside the frustum, and then skip rendering it. If you don't have objects, or you have too many, merge them into batches. – Berthur Nov 11 '22 at 17:54
-
Thanks @Berthur! It's not for rendering performance purpose but for limiting traffing from / to my server. – lviggiani Nov 15 '22 at 09:01
1 Answers
1
As discussed in the comments, this seems like a bit of an usual thing to do. Describing the application of this test might attract better answers.
But based only on your question, one way to achieve this is using Frustom.containsPoint(). You create a frustum from the camera, and then test it against the vertices of individual triangles.
If it contains all 3 points of a triangle, then the entire triangle should be on the screen. If at least one is included, then it is partially on the screen. If none, then it is occluded.

Berthur
- 4,300
- 2
- 14
- 28