Detect if an object is completely invisible when clipping

How can I know if an object is invisible when clipped? I want to raycast on to a clipped object but the meshes which are no longer visible are still intersected. I understand this is expected behaviour. So instead, I would like to test if the object is visible (not completely clipped) first.

1 Like

You can perform the same test that is done to implement view frustum culling. Meaning you create an object of type Frustum and update it like so per frame:

matrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
frustum.setFromProjectionMatrix( matrix );

You can then check if a 3D object is within the view frustum like so:

frustum.intersectsObject( object )
1 Like

Thank you @Mugen87. I will give this a go and mark the question as complete :slight_smile: