Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wedge = Instance.new("WedgePart");
- wedge.Anchored = true;
- wedge.TopSurface = Enum.SurfaceType.Smooth;
- wedge.BottomSurface = Enum.SurfaceType.Smooth;
- 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
- while true do
- local a = workspace.A.Position
- local b = workspace.B.Position
- local c = workspace.C.Position
- local wedgeA, wedgeB = draw3dTriangle(a, b, c)
- wait()
- wedgeA:Destroy()
- wedgeB:Destroy()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement