I would like to Draw a triangle to three positions like this:
But I’m getting this:
I am not familiar with CFrame Matrix
Here is the code if you are wondering
local X, Z = 15, 15
local wedge = workspace.MeshPart;
wedge.Anchored = true;
local function draw3dTriangle(a, b, c)
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 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
draw3dTriangle(workspace.A.Position,workspace.B.Position,workspace.C.Position)
note(I am not using robloxs wedge model as that has too many triangles in it, so I am using a mesh with only one triangle)