#Country polygons clipping into globe & triangulation issues in R3F
9 messages · Page 1 of 1 (latest)
Thanks @copper saffron !
I will try now and let you know.
I've tried use PolygonOffSet, but it didn't fix the current issue.
I think the reason is my issue is not occurred between two nealry similar surfaces.
Current polygon is not curved, it has sharp angle in deep Polygon(Partially, not full).
Is there another way?
Yes. You can set the water sphere material.depthWrite = false
and .transparent = false
then the terrain with .transparent = true
but that may cause other artifacts with your labels.
Another option is perhaps to use a subdivision modifier on the terrain, and then re-spherize the vertices, to get a more spherical profile, at the expense of more triangles.
There are two geometries, neither of which are perfect spheres. The base globe will also be some form of triangle mesh. So to make any arbitrary shape "always above" that other mesh, you'll need to triangulate it in the same places, so it will need to have vertices in the same place as the vertices in the base mesh, raised up a little.
The easier route is probably to just disable depth test for everything and use renderOrder to get the objects drawn in the right order, and hopefully back face culling will mean you will only see the front of the globe. Otherwise you could always set the far clip plane so it chops off the back half
Three has DecalGeometry which does something similar to the first geometric approach I think - it "projects" textures onto a mesh but the implementation might be a useful reference if you go the geometric route
Some faces appear “chopped” or flat because triangulation happens in flat lon/lat space, not on the spherical surface.
Yes if you need to conform a triangulated shape to a curved surface you need to create a detailed enough "inner" triangulation of the shapes so you don't have such large flat polygons, which is fairly non trivial.
I've created a geojson project here that does this and generates smooth normals for the caps if you'd like to use it or reference the code. It's generating a set of sample points inside the shape and then using constrained delaunay triangulation to produce an even-enough triangulation to conform to a sphere.
Three.js shape loaders for GeoJSON and WKT formats - gkjohnson/three-geojson