Skip to content Skip to sidebar Skip to footer

Three.js - How To Check If An Object Is Visible To The Camera

I'm having hard times figuring out what's the best way to check if a Object3d is visible for the eyes of the camera. I'm having a sphere in the middle of the screen. Some cubes are

Solution 1:

You want to look at Occlusion Culling techniques. Frustum culling works fine and is not what you are describing. Frustum culling just checks if an object (or its bounding box) is inside the camera pyramid. You perform Occlusion culling in addition to Frustum Culling specially when you want to eliminate objects which are occluded by other objects inside the view frustum. But it is not an easy task.

Solution 2:

I just worked though a similar problem where I was trying to detect when a point in world space passed out of view of the camera and behind specific objects in the scene. I created a jsfiddle, (see below) for it. When the red "target" passes behind any of the three "walls" a blue line is drawn from the "target" to the camera. I hope this helps.

Post a Comment for "Three.js - How To Check If An Object Is Visible To The Camera"