I’m trying to build a planet, now by using fibonacci spheres. Vertices are placed, and got the triangle drawn out. However connecting the triangles to all of those points are something tricky I can’t get done with.

Here’s my attempt so far. Instead of a sphere, it makes this pattern.

I checked sources like Delaunay triangulation but I do not fully understand the source provided, I could try if there was additional information provided.

Source code:

```
local radius = 500
-- reference
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(5, 5, 5)
local wedge = Instance.new("WedgePart");
wedge.Anchored = true;
wedge.TopSurface = Enum.SurfaceType.Smooth;
wedge.BottomSurface = Enum.SurfaceType.Smooth;
-- reference
local triangles = {}
local function draw3dTriangle(selected)
local a = selected[1][2].Position
local b = selected[2][2].Position
local c = selected[3][2].Position
local ab, ac, bc = b - a, c - a, c - b;
local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);
if (abd > acd and abd > bcd) then
c, a = a, c;
elseif (acd > bcd and acd > abd) then
a, b = b, a;
end
ab, ac, bc = b - a, c - a, c - b;
local edge = bc
local right = ac:Cross(ab).unit;
local up = bc:Cross(right).unit;
local back = bc.unit;
local height = math.abs(ab:Dot(up));
local w1 = wedge:Clone();
w1.Size = Vector3.new(0, height, math.abs(ab:Dot(back)));
w1.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back);
w1.Parent = workspace;
local w2 = wedge:Clone();
w2.Size = Vector3.new(0, height, math.abs(ac:Dot(back)));
w2.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back);
w2.Parent = workspace;
return w1, w2;
end
local function fibonacci_spiral_sphere(num_points)
local vectors = {}
local gr = (math.sqrt(5) + 1) / 2
local ga = (2 - gr) * (2 * math.pi)
for i = 1, num_points do
local lat = math.asin(-1 + 2 * i / (num_points + 1))
local lon = ga * i
local x = math.cos(lon) * math.cos(lat)
local y = math.sin(lon) * math.cos(lat)
local z = math.sin(lat)
table.insert(vectors, Vector3.new(x, y, z))
end
return vectors
end
local vec = fibonacci_spiral_sphere(1024)
for _, v in ipairs(vec) do
local part = part:Clone()
--table.insert(triangles,part)
part.CFrame = CFrame.new(v.Unit * radius)
part.Parent = workspace.Parts
--[[
if #triangles == 3 then
draw3dTriangle()
triangles = {}
end]]
end
wait(5)
-- this attempts to find the cloeset parts of all descendants
local PartsToFind = 2
for i,obj in pairs(workspace.Parts:GetChildren()) do
local dictionary = {}
for i, v in pairs(workspace.Parts:GetChildren()) do
if v:IsA("Part") and obj ~= v then
table.insert(dictionary,{(obj.Position - v.Position).Magnitude,v})
end
end
local array = {}
for _, value in pairs(dictionary) do
--print(value[1])
table.insert(array, tonumber(value[1]))
end
table.sort(array)
local selected = {{0,obj}}
for i = 1, PartsToFind do
local key = array[i]
for i, v in pairs(dictionary) do
if v[1] == key then
table.insert(selected,v)
end
end
end
draw3dTriangle(selected)
task.wait()
end
```