I have big problems with EditableMesh after the update, this piece of code worked before the update, and turned my meshpart into a plane, after the update it just stopped working, can someone explain what the problem is, preferably in more detail, because I don’t understand this topic at all.
local AssetService = game:GetService("AssetService")
local Water = script.Parent
local EditableMesh = AssetService:CreateEditableMesh()
local width = 100
local height = 100
local vertices = {}
for y = 1, height do
local raw = {}
for x = 1, width do
local vertexPosition = Vector3.new(x - 1, 0, y - 1)
local vertexId = EditableMesh:AddVertex(vertexPosition)
raw[x] = vertexId
end
vertices[y] = raw
end
print("1 fors")
for y = 1, height - 1 do
for x = 1, width - 1 do
local vertex1 = vertices[y][x]
local vertex2 = vertices[y + 1][x]
local vertex3 = vertices[y][x + 1]
local vertex4 = vertices[y + 1][x + 1]
local triagle1 = EditableMesh:AddTriangle(vertex1, vertex2, vertex3)
local triagle2 = EditableMesh:AddTriangle(vertex3, vertex4, vertex2)
end
end
print("2 fors")
2nd attempt:
local AssetService = game:GetService("AssetService")
local myMeshPart = workspace:FindFirstChildWhichIsA("MeshPart")
local myEditableMesh
if myMeshPart then
myEditableMesh = AssetService:CreateEditableMeshAsync(myMeshPart.MeshContent)
if myEditableMesh then
print("EditableMesh created.")
else
warn("Error.")
end
else
warn("MeshPart doesnt found.")
end
local function computeExtents(em: EditableMesh)
local verts = em:GetVertices()
if #verts == 0 then
return Vector3.zero
end
local inf = math.huge
local min = Vector3.new(inf, inf, inf)
local max = Vector3.new(-inf, -inf, -inf)
for _, id in verts do
local v = em:GetPosition(id)
min = min:Min(v)
max = max:Max(v)
end
return max - min
end
local width = 100
local height = 100
local vertices = {}
for y = 1, height do
local row = {}
for x = 1, width do
local vertexPosition = Vector3.new(x - 1, 0, y - 1)
-- Используем myEditableMesh для добавления вершины
local vertexId = myEditableMesh:AddVertex(vertexPosition)
row[x] = vertexId
end
vertices[y] = row
end
print("1 fors")
for y = 1, height - 1 do
for x = 1, width - 1 do
local vertex1 = vertices[y][x]
local vertex2 = vertices[y + 1][x]
local vertex3 = vertices[y][x + 1]
local vertex4 = vertices[y + 1][x + 1]
myEditableMesh:AddTriangle(vertex1, vertex2, vertex3)
myEditableMesh:AddTriangle(vertex3, vertex4, vertex2)
end
end
print("2 fors")