Can someone please explain to me how editable meshes work

I have no idea what's going on

I obviously know the gist of it, but there has been so many changes and I have only been able to make ONE editable mesh, and that was months ago. Currently I feel like there is no documentation on how to just even put an editable mesh into the workspace. I feel like I can’t even learn how these work because the only people I’ve seen do anything with editable meshes already somehow know exactly how to use them.

  1. How do I create editable mesh and literally just see in in workspace? (???)

Okay well I do know about the triangles and the vertices but even if I have those, I still have no idea how to generate the mesh, and even worse, SEE it.

That’s it. One question. I feel like the documentation is useless as it doesn’t give any basic code on how to just generate an editable mesh and just see it. Now, I don’t have 32 PHD’s in coding and math but I feel like this is unnecessarily complicated.

It’s a bit complicated but I was able to learn it and I’ll teach you.

First off, you need to create an editable mesh, you can do that using this method in AssetService:

It mainly requires a Content parameter which can be made using the Content data type:

You can just do:
Content.fromtUri(--Asset Id Goes Here!)
Or
MeshPart.MeshContent
For the latter statement, you don’t need to use the Content data type as it itself returns a content.

Just pass this into the CreateEditableMeshAsync method and you’ll be returned an editable mesh.
Now, to apply it onto a mesh, you can simply do:
MeshPart:ApplyMesh()

1 Like

Thank you for the meshpart:ApplyMesh(mesh) hint, but every time I use it, I get this error:

Unable to cast value to Object  -  Server - Script:2

Can it not be empty?

local mesh = game:GetService("AssetService"):CreateEditableMesh()
script.Parent:ApplyMesh(mesh)

It seems like a roblox bug because I tried a lot as well and it simply doesn’t work.

1 Like

Also, this seems to work:

local mesh = game:GetService("AssetService"):CreateEditableMeshAsync(workspace.Main.MeshContent)

mesh:SetPosition(mesh:GetVertices()[1],Vector3.new(0,5,0))

local newMesh = game:GetService("AssetService"):CreateMeshPartAsync(Content.fromObject(mesh))
newMesh.Parent = workspace
newMesh.Name = "Second"

I still don’t know why ApplyMesh errors out so much without any context.

1 Like

Going to post the method I found to be working since I was also curious about how to create empty meshes:

  1. Create an EditableMesh using AssetService:CreateEditableMesh().

  2. Populate the EditableMesh with vertices and triangles (you must do this as you cannot create MeshParts with empty EditableMeshes)

  3. Create the MeshPart using the AssetService:CreateMeshPartAsync(Content.fromObject(EditableMesh)).

By default you don’t need to do anything else as the MeshPart will already have the editable mesh applied. You can then use the EditableMesh to influence the MeshPart’s appearance.

Hopefully this works!