EditableMesh won't render flat plane

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
2 Likes

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.

1 Like

I made this to experiment with waves, not just to have a flat plane, if that’s what you mean.

Also, will there be an option to set the vertices with a buffer or something so you can batch them

Have you published the patch? It is january and i just got the exact same bug

The fix was deployed yesterday. Please let me know if you are still encountering the issue.
Thanks!

1 Like

Hello! It works fine for me, thank you for this patch