I am trying to just generate a flat plane however it refuses to render if its completely flat but will render if I offset a vertex by 0.001 then it will render but with gaps. I have tried adding a normal and setting the faces normal to (0, 1, 0) but it changes nothing.
Here is the function to create a plane:
function makePlane(Size, Resolution)
local editableMesh: EditableMesh = AssetService:CreateEditableMesh()
local Space = Size / Resolution
for X = 0, Resolution - 1 do
for Z = 0, Resolution - 1 do
local Position = Vector3.new(X * Space, 0, Z * Space)
local nid = editableMesh:AddNormal()
local vId0 = editableMesh:AddVertex(Position + Vector3.new(0, 0, 0))
local vId1 = editableMesh:AddVertex(Position + Vector3.new(-Space, 0, 0))
local vId2 = editableMesh:AddVertex(Position + Vector3.new(0, 0, Space))
local vId3 = editableMesh:AddVertex(Position + Vector3.new(-Space, 0, Space))
local fid0 = editableMesh:AddTriangle(vId0, vId1, vId2)
local fid1 = editableMesh:AddTriangle(vId2, vId1, vId3)
editableMesh:SetFaceNormals(fid0, {nid, nid, nid})
editableMesh:SetFaceNormals(fid1, {nid, nid, nid})
end
end
return editableMesh
end
We have a fix for this issue coming up in v654 – expected be released next week.
The problem is indeed with flat planes. In the meantime you can work around it by moving at least one of your vertices a bit off the plane.
Separately, make sure to avoid duplicating vertices unless it’s intentional. In your sample code, each quad or pair of triangles generates distinct vertices. The mesh will be more efficient if you share vertices and normals across faces.