I am trying to create a script where it generates 256x256 stud chunks which all possess the same editablemesh. I plan to adjust the position of each vertice but as of right now I’m facing an issue when I apply the editablemesh. The plane mesh gets created and placed correctly, but as soon as I apply the mesh using MeshPart:ApplyMesh(), the entire thing gets stretched beyond the horizon.
I have another script which does practically the same thing with a different instance of the same plane mesh and I basically directly ported over the code from the working script. I’m not sure why that script works and this one doesn’t.
I’ve tried running the faulty script in a standalone environment and the issue still persists.
Here is the function where the issue occurs:
function Terrain.LoadChunksAsync()
while task.wait() do
if Terrain._RenderQueue:IsEmpty() then
continue
end
-- // get the next chunk in queue to be rendered
local chunkPos: Vector3 = Terrain._RenderQueue:Dequeue()
local terrainModel: Model = game.ReplicatedStorage.Assets.TerrainMesh:Clone()
terrainModel.Name = "chunk" .. chunkIndex
chunkIndex += 1
local plane: MeshPart = terrainModel:WaitForChild("Plane", 2)
if not plane then continue end
terrainModel:PivotTo(CFrame.new(chunkPos))
terrainModel.Parent = loadedChunkFolder
-- if an editable mesh already exists, simply apply the mesh
if Terrain.HostChunk then
plane:ApplyMesh(Terrain.HostChunk)
table.insert(Terrain.LoadedChunks, terrainModel)
continue
end
-- if no host chunk, create a new editable mesh to be applied
local editableMesh = Common.CreateEditableMesh(plane.MeshId)
-- configureEditableMeshVertices(editableMesh)
local mesh = assetService:CreateMeshPartAsync(Content.fromObject(editableMesh))
task.wait(2)
plane:ApplyMesh(mesh) -- stretch occurs at this point
Terrain.HostChunk = mesh
table.insert(Terrain.LoadedChunks, terrainModel)
end
end
Here are the videos related to the issue:
Bugged result: Watch Desktop 2025.01.31 - 17.23.07.24 | Streamable
Expected result: Watch Desktop 2025.01.31 - 17.43.02.25 | Streamable