Currently, I am working on rendering a complex 3D mesh using Three.js (an iliac bone) and including some simple spheres to mark specific points on the surface where muscles would attach.
However, I have encountered an issue where the markers protrude out the back in areas where the mesh is thin.
In this scenario, I can assume that the marker coordinates are always closer to the front face of the mesh than the back face. Additionally, the spheres will display more surface area/volume on the front of the mesh compared to the back.
Is there a way to automatically hide the parts of the markers that extrude from the back without manually adjusting them for each marker?
Edit: One potential solution I thought of involves several steps. I would appreciate feedback on the viability of this approach as well as guidance or code examples to implement it:
- For each marker sphere:
- Determine all faces of the mesh that intersect with the sphere
- Calculate outward-facing normal vectors of those faces (vertex-normals? face-normals?)
- Compute distances from the center of the face to the center of the sphere
- Combine all normal vectors, weighted by their respective distances
- Based on the normalized result vector, conceal the hemisphere pointing in that direction
I am unsure about how to proceed with coding these steps and whether this proposed method is practical. Any advice or suggestions would be greatly appreciated.