drawFace
Function to create a triangle or quadrangle from vertices.
Features:
- Reduces parts when they are right triangles or rectangles.
- You can update the vertices of the generated part.
Examples
three vertices
local drawFace = require(script.drawFace)
local v1 = Vector3.new(3, 3, 0)
local v2 = Vector3.new(6, 3, 3)
local v3 = Vector3.new(0, 3, 3)
local p1 = Instance.new("Part", workspace)
p1.Name = "p1"
p1.Anchored = true
p1.Position = v1
p1.Size = Vector3.new(0.1, 0.1, 0.1)
local p2 = Instance.new("Part", workspace)
p2.Name = "p2"
p2.Anchored = true
p2.Position = v2
p2.Size = Vector3.new(0.1, 0.1, 0.1)
local p3 = Instance.new("Part", workspace)
p3.Name = "p3"
p3.Anchored = true
p3.Position = v3
p3.Size = Vector3.new(0.1, 0.1, 0.1)
local FaceParts = drawFace({v1, v2, v3}, workspace)
p1.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position}, workspace, FaceParts)
end)
p2.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position}, workspace, FaceParts)
end)
p3.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position}, workspace, FaceParts)
end)
four vertices
local drawFace = require(script.drawFace)
local v1 = Vector3.new(3, 3, 0)
local v2 = Vector3.new(6, 3, 3)
local v3 = Vector3.new(0, 3, 3)
local v4 = Vector3.new(3, 3, 6)
local p1 = Instance.new("Part", workspace)
p1.Name = "p1"
p1.Anchored = true
p1.Position = v1
p1.Size = Vector3.new(0.1, 0.1, 0.1)
local p2 = Instance.new("Part", workspace)
p2.Name = "p2"
p2.Anchored = true
p2.Position = v2
p2.Size = Vector3.new(0.1, 0.1, 0.1)
local p3 = Instance.new("Part", workspace)
p3.Name = "p3"
p3.Anchored = true
p3.Position = v3
p3.Size = Vector3.new(0.1, 0.1, 0.1)
local p4 = Instance.new("Part", workspace)
p4.Name = "p4"
p4.Anchored = true
p4.Position = v4
p4.Size = Vector3.new(0.1, 0.1, 0.1)
local FaceParts = drawFace({v1, v2, v3, v4}, workspace)
p1.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position, p4.Position}, workspace, FaceParts)
end)
p2.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position, p4.Position}, workspace, FaceParts)
end)
p3.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position, p4.Position}, workspace, FaceParts)
end)
p4.Changed:Connect(function()
FaceParts = drawFace({p1.Position, p2.Position, p3.Position, p4.Position}, workspace, FaceParts)
end)