It’s funny. The last update you posted before this only really works well because you bumped the radius by 0.1. however, despite that being such a small distance, it’s visually noticeable! boo. (country doesn’t rest on surface of sphere). I raised depth by 0.1 instead and that returned to a better result. although Argentina still has a tiny slit. I am not a fan of “just make it taller and its fixed.”
the issue with a pure increaseVertices solution, is we are extruding to a spherical look, and that will end up with some countries taller than others, which wont be sexy.
Feature Request! One major issue really, is I have no concept right now if a hole exists or not programmatically. I’ve tried to use Mesh IntersectMeshes to help determine that, and unfortunately there’s no way to make it work with the bounding box / bounding sphere. It would be cool if Babylon created a bounding arc, so intersections could be analyzed more accurately than a bounding box on an item. I feel the logic would mimic the sphere, but I could be wrong haha.
Yesterday i ventured into the world of PDFs of algorithms, looking at CSG subtract type stuff. I was thinking I could draw a sphere at the depth height (radius+depth), with 128 segments (produces good sized triangles), and then subtract the border ribbon out of the sphere. this would return me the vertices from the sphere inside the borders, and then I’d just render those.This would solve holes and give me sweet curvature.
that … did not work in Babylon haha (cpu whimpered and died). (course, the outer shell sphere is like, 32k vertices or 64k, something crazy big). I am thinking of trying this with a csg.js library i found, but I feel it might die too. I tried to use the CreateSphere routine with an arc, to reduce vertices, but I couldn’t find a way to box in the border.
Found a paper on doing it for meshes, but sadly could not find any code, and the paper was juust vague enough i couldn’t pull it out.
As it stands right now, I have 3 functional approaches that I’ve used with varying success.
- Return Center and Incenter of triangle. just add those 2 as holes. works great for Canada and Brazil.
- Return midpoints of triangle legs, basically I’m attempting to create 4 triangles. got the idea from a Delauney triangulation article, section 1 Although on re-reading it, apparently I read it wrong. so may have to revisit (I was trying to do 4T-LE). My current code works great when i have a narrow triangle such as Argentina. in fact, i think this is the only one that solves it well and simply.
- JohnK’s addedPoint logic based on area. this works really well for super large triangles like Russia. but less well for Canada and Australia, and that’s not a tiny triangle! kinda interesting.
Interesting notes: i tried to make (1) and (2) subdivide, thinking if the area is big enough, multiples will be needed. did not work! although that may be programmer error. especially (2)
so I am considering looking at the area of a triangle (i have a function that gets me the true triangle area, using the vertices not a bounding box), and some logic to figure out if the triangle approaches equilateral (canada), narrow (argentina), or superlarge (Russia), and uses one of the above algorithms for it.
I am considering also looking at the longest leg length of the triangle in relation to the sphere. the issue is the curve of the sphere surface. so if my leg is 0.5 length on a radius 2 sphere, that needs to be reduced. I feel like I should be able to mathematically calculate the distance at which the curve intersects a fixed line, and use that as a guide.
This is fairly interesting project haha.