in threejs, i have a gltf house model. And I want to capture only the meshes that in the front view of the house. I want to return the properties and geometries of trhe meshes that are visible to the camera. and not the meshes BEHIND the meshes in view. So basically only the meshes that intersect with the view of the camera Does anyone know how to do this?
If i understood, you can try with Raycaster:
https://threejs.org/docs/#api/en/core/Raycaster
Raycaster will give you the objects between one point and another. If you use the camera as a reference, you can get the elements between the camera and another point where it is looking
Related:
I start with two assumptions:
- You mean “visible to the user”, not “visible to the camera”. The camera sees object behind other objects.
- You do not need this to work in real-time inside animation loop.
In this case here is one simple (and stupid) solution:
- render each mesh in individual flat color (without antialiasing)
- then read the canvas and see what colors are used in it
- these colors will give you the objects that are seen by the user