55 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

EditableMesh

Inherits from: Object

EditableMesh changes the applied visual mesh when linked to a MeshPart, allowing for querying and modification of the mesh both in Studio and in-game.

Enabling for published games

For security purposes, using EditableMesh fails by default for published games. To enable usage of EditableMesh, you must be 13+ age verified and ID verified. After you are verified, open the Creator Dashboard and toggle on Enable Mesh / Image APIs. Remember to review the Terms of Use before enabling the toggle.

Permissions

To prevent misuse, AssetService:CreateEditableMeshAsync() only allows you to load and edit mesh assets if any of the following is true:

See Grant permissions to learn how to share assets with users or groups.

The APIs throw an error if they are used to load an asset that does not meet the criteria above.

Memory limits

Editable assets are currently expensive for memory usage. To minimize its impact on client performance, EditableMesh has strict client-side memory budgets, although the server, Studio, and plugins operate with unlimited memory. Using FixedSize may help you stay within the memory budget and, in some scenarios, linking one EditableMesh to multiple MeshParts (multi-referencing) can help with memory optimization.

Creation and display

An EditableMesh can be created from an existing Content of a MeshPart or a mesh ID using AssetService:CreateEditableMeshAsync(), or a blank EditableMesh can be created with AssetService:CreateEditableMesh(). It can then be displayed, modified, and its collision model updated. Not all of the steps are necessary; for example, you might want to create an EditableMesh just to raycast without ever displaying it.

local AssetService = game:GetService("AssetService")

-- Create empty EditableMesh
local editableMesh = AssetService:CreateEditableMesh()

-- Create EditableMesh from asset ID
local editableMeshFromAsset = nil
local success, errorMessage = pcall(function()
	editableMeshFromAsset = AssetService:CreateEditableMeshAsync(Content.fromAssetId(ASSET_ID))
end)

-- Create EditableMesh from another EditableMesh
local editableMeshFromAnother = nil
local success, errorMessage = pcall(function()
	editableMeshFromAnother = AssetService:CreateEditableMeshAsync(Content.fromObject(OTHER_EDITABLE_MESH))
end)

-- Create EditableMesh from MeshPart
local editableMeshFromMeshPart = nil
local success, errorMessage = pcall(function()
	editableMeshFromMeshPart = AssetService:CreateEditableMeshAsync(MESH_PART.MeshContent)
end)

An EditableMesh is displayed when it's linked to a new MeshPart, through AssetService:CreateMeshPartAsync(). You can create more MeshPart instances that reference the same EditableMesh Content, or link to an existing MeshPart through MeshPart:ApplyMesh().

local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")

-- Create EditableMesh from asset ID
local editableMeshFromAsset = nil
local success, errorMessage = pcall(function()
	editableMeshFromAsset = AssetService:CreateEditableMeshAsync(Content.fromAssetId(ASSET_ID))
end)

-- Create new MeshPart linked to the EditableMesh
local newMeshPart = nil
local success, errorMessage = pcall(function()
	newMeshPart = AssetService:CreateMeshPartAsync(Content.fromObject(editableMeshFromAsset))
end)

-- Alternatively, link the new MeshPart created above to an existing MeshPart
local existingMeshPart = Workspace:FindFirstChild("EXISTING_MESH_PART")
existingMeshPart:ApplyMesh(newMeshPart)

To recalculate collision and fluid geometry after editing, you can again call AssetService:CreateMeshPartAsync() and MeshPart:ApplyMesh() to update an existing MeshPart. It's generally recommended to do this at the end of a conceptual edit, not after individual calls to methods that manipulate geometry. Visual changes to the mesh will always be immediately reflected by the engine, without the need to call AssetService:CreateMeshPartAsync().

Fixed-size meshes

When creating an EditableMesh from an existing mesh asset (via AssetService:CreateEditableMeshAsync()), the resulting editable mesh is fixed-size by default. Fixed-size meshes are more efficient in terms of memory but you cannot change the number of vertices, faces, or attributes. Only the values of vertex attributes and positions can be edited.

local AssetService = game:GetService("AssetService")

-- Create EditableMesh without fixed-size default
local editableMeshFromAsset = nil
local success, errorMessage = pcall(function()
	editableMeshFromAsset = AssetService:CreateEditableMeshAsync(Content.fromAssetId(ASSET_ID), {FixedSize = false})
end)

Stable IDs

Many EditableMesh methods take vertex, normal, UV, color and face IDs. These are represented as integers in Luau but they require some special handling. The main difference is that IDs are stable and they remain the same even if other parts of the mesh change. For example, if an EditableMesh has five vertices {1, 2, 3, 4, 5} and you remove vertex 4, the new vertices will be {1, 2, 3, 5}.

Note that the IDs are not guaranteed to be in order and there may be holes in the numbering, so when iterating through vertices or faces, you should iterate through the table returned by GetVertices() or GetFaces().

For debugging purposes, it can be very helpful to get a more readable string for a stable ID with IdDebugString().

Split vertex attributes

A vertex is a corner of a face, and topologically connects faces together. Each vertex has a single position, while its normal, UV coordinate, and color (with transparency) are stored per face corner. A vertex shared by multiple faces can use the same values on every face, or different values on each.

Sometimes it's useful for all faces that touch a vertex to use the same attribute values, but sometimes you'll want different faces to use different attribute values on the same vertex. For example, on a smooth sphere, each vertex will only have a single normal. In contrast, at the corner of a cube, the vertex will have 3 different normals (one for each adjacent face). You can also have seams in the UV coordinates or sharp changes in the vertex colors.

When creating faces with AddFace() or AddTriangle(), each corner of the new face is automatically assigned a normal, UV, and color attribute. If a vertex already belongs to an existing face, the new face reuses that vertex's existing attributes (producing smooth shading and continuous UVs). If the vertex is new, fresh attribute IDs are created with default values (auto-computed normal, UV of (0, 0), white color). To create a seam, you should create new attributes and set them on the face. For example, this code will create a sharp cube:

local AssetService = game:GetService("AssetService")

-- Given 4 vertex IDs, adds a new normal and a quad face, making a sharp quad
local function addSharpQuad(editableMesh, vid0, vid1, vid2, vid3)
	local nid = editableMesh:AddNormal() -- This creates a normal ID which is automatically computed

	local fid = editableMesh:AddFace({vid0, vid1, vid2, vid3})
	editableMesh:SetFaceNormals(fid, {nid, nid, nid, nid})
end

-- Makes a cube with creased edges between the 6 sides
local function makeSharpCube()
	local editableMesh = AssetService:CreateEditableMesh()

	local v1 = editableMesh:AddVertex(Vector3.new(0, 0, 0))
	local v2 = editableMesh:AddVertex(Vector3.new(1, 0, 0))
	local v3 = editableMesh:AddVertex(Vector3.new(0, 1, 0))
	local v4 = editableMesh:AddVertex(Vector3.new(1, 1, 0))
	local v5 = editableMesh:AddVertex(Vector3.new(0, 0, 1))
	local v6 = editableMesh:AddVertex(Vector3.new(1, 0, 1))
	local v7 = editableMesh:AddVertex(Vector3.new(0, 1, 1))
	local v8 = editableMesh:AddVertex(Vector3.new(1, 1, 1))

	addSharpQuad(editableMesh, v5, v6, v8, v7) -- Front
	addSharpQuad(editableMesh, v1, v3, v4, v2) -- Back
	addSharpQuad(editableMesh, v1, v5, v7, v3) -- Left
	addSharpQuad(editableMesh, v2, v4, v8, v6) -- Right
	addSharpQuad(editableMesh, v1, v2, v6, v5) -- Bottom
	addSharpQuad(editableMesh, v3, v7, v8, v4) -- Top

	editableMesh:RemoveUnused()
	return editableMesh
end

Winding

Mesh faces have a front side and a back side. When drawing meshes, only the front of the faces are drawn by default, although you can change this by setting the mesh' DoubleSided property to true.

The order of the vertices around the face determines whether you are looking at the front or the back. The front of the face is visible when the vertices go counterclockwise around it.

Order of the vertices around the face

FACS poses

Animatable heads use the Facial Action Coding System (FACS). See the FACS poses reference for helpful information when using GetFacsPoses() and similar methods.

Each FACS pose is specified by an FacsActionUnit value. For the FACS pose, virtual bones can each have a CFrame that transforms the bones' initial CFrame in the bind pose of the mesh into the CFrame for that FACS action unit's pose. All bone CFrames are in the mesh's local space.

These FACS poses are blended together during animation. Sometimes, the blending of the base poses produces poor results. In those cases, you can override the blending of specific combinations of base poses with a corrective pose that is more pleasing. A corrective pose is specified by 2 or 3 FacsActionUnit values. Like a base FACS pose, for a corrective pose, virtual bones can each have a CFrame that transforms the bones' initial CFrame in the bind pose of the mesh into the CFrame for that FACS corrective.

Please note that corrective poses that operate on both left and right action units are not currently expressible. For example, using LeftCheekPuff and RightEyeClosed together in a corrective pose is not currently possible.

Batching

The batch methods let you create, read, update, and remove many mesh elements in a single call instead of invoking the singular methods (AddVertex(), SetPosition(), GetColor(), and so on) once per element. Batching your mesh operations is typically much more performant than handling them one by one.

Rather than one method per attribute, each batch method shares a small set of general entry points and uses an MeshAttribute value (or the type already encoded in each mesh ID) to determine which attribute you mean. For example, BatchSetValues() sets positions when called with vertex IDs, but sets normals when called with normal IDs. You cannot mix-and-match ID types within a single call.

Batch setters take parallel arrays: element i of every argument array describes the same logical operation. In BatchSetValues(ids, values), values[i] is written to ids[i]. All argument arrays must be the same length or the call errors. Batch getters take an array of IDs and return results in the same order.

If a mesh ID is invalid, batching still applies updates to all elements before the invalid ID, then stops.

Limitations

EditableMesh currently has a limit of 60,000 vertices and 20,000 triangles. Faces can be triangles or quads, and each quad counts as 2 triangles toward the triangle limit. Attempting to add too many vertices or triangles will cause an error.

Inherits from: Object

Memory category: Instances

Tags: NotCreatable

Properties

NameType / ReturnsDescription
EditableMesh.FixedSizebooleanReturns true if a mesh is fixed-size.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring

EditableMesh.FixedSize

Fixed-sized meshes allow changing the values of vertex attributes but do not allow vertices and faces to be added or deleted.

FieldValue
typeboolean
tags["ReadOnly","NotReplicated"]
security{"read":"None","write":"RobloxEngineSecurity"}
thread safetyReadSafe
categoryData
serialization{"can_load":false,"can_save":true}
capabilities["DynamicGeneration"]

Methods

NameType / ReturnsDescription
EditableMesh:AddBoneint64Adds a new bone and returns a bone ID.
EditableMesh:AddColorint64Adds a new color to the geometry and returns a color ID.
EditableMesh:AddFaceint64Adds a new triangle or quad face to the mesh and returns a face ID.
EditableMesh:AddNormalint64Adds a new normal to the geometry and returns a normal ID.
EditableMesh:AddTriangleint64Adds a new triangle to the mesh and returns a face ID.
EditableMesh:AddUVint64Adds a new UV to the geometry and returns a UV ID.
EditableMesh:AddVertexint64Adds a new vertex to the geometry and returns a vertex ID.
EditableMesh:BatchAddArrayCreates new mesh elements of the given attribute type and returns their IDs.
EditableMesh:BatchGetFaceAttributesArrayReturns the per-corner attribute IDs for each face in a batch.
EditableMesh:BatchGetValuesTupleReturns attribute values for each ID in a batch.
EditableMesh:BatchGetVertexAttributesArrayReturns the attribute IDs associated with each vertex in a batch.
EditableMesh:BatchGetVertexFaceAttributesArrayReturns the attribute ID at each specified corner for a batch of vertex–face pairs.
EditableMesh:BatchRemove()Removes a batch of faces.
EditableMesh:BatchSetFaceAttributes()Sets the per-corner attribute IDs for each face in a batch.
EditableMesh:BatchSetValues()Writes attribute values to a batch of mesh element IDs.
EditableMesh:BatchSetVertexFaceAttributes()Sets the attribute at a specific corner for each vertex–face pair in a batch.
EditableMesh:Clear()Clears all of an EditableMesh's geometry.
EditableMesh:Destroy()Destroys the mesh.
EditableMesh:FindClosestPointOnSurfaceTupleFinds the closest point on the mesh's surface.
EditableMesh:FindClosestVertexint64Finds the closest vertex to a specific point in space.
EditableMesh:FindVerticesWithinSphereArrayFinds all vertices within a specific sphere.
EditableMesh:GetAdjacentFacesArrayReturns a list of faces adjacent to a given face.
EditableMesh:GetAdjacentVerticesArrayReturns a list of vertices adjacent to a given vertex.
EditableMesh:GetBoneByNameint64Finds the bone ID of the bone with the given name.
EditableMesh:GetBoneCFrameCFrameReturns the initial CFrame of the bone in the bind pose of the mesh.
EditableMesh:GetBoneIsVirtualbooleanReturns true if the bone is virtual.
EditableMesh:GetBoneNamestringReturns the bone name.
EditableMesh:GetBoneParentint64Returns the parent bone ID, if any.
EditableMesh:GetBonesArrayReturns all bones of the mesh.
EditableMesh:GetCenterVector3Returns the center of the mesh's axis-aligned bounding box.
EditableMesh:GetColorColor3?Returns the color for the given color ID.
EditableMesh:GetColorAlphafloat?Returns the color alpha (transparency) at the given color ID.
EditableMesh:GetColorsArrayReturns all colors of the mesh.
EditableMesh:GetFaceColorsArrayReturns the face's color IDs for the vertices on the face.
EditableMesh:GetFaceNormalsArrayReturns the face's normal IDs for the vertices on the face.
EditableMesh:GetFacesArrayReturns all faces of the mesh.
EditableMesh:GetFacesWithAttributeArrayReturns a list of faces that use a given attribute ID.
EditableMesh:GetFacesWithColorArrayReturns an array of face IDs that use the given color ID.
EditableMesh:GetFacesWithNormalArrayReturns an array of face IDs that use the given normal ID.
EditableMesh:GetFacesWithUVArrayReturns an array of face IDs that use the given UV ID.
EditableMesh:GetFaceUVsArrayReturns the face's UV IDs for the vertices on the face.
EditableMesh:GetFaceVerticesArrayReturns the face's vertex IDs.
EditableMesh:GetFacsCorrectivePoseTupleReturns bone IDs and bone CFrames for all bones in a specific FACS corrective pose.
EditableMesh:GetFacsCorrectivePosesArrayReturns all FACS corrective poses that are in use.
EditableMesh:GetFacsPoseTupleReturns bone IDs and bone CFrames for all bones in a specific FACS action unit.
EditableMesh:GetFacsPosesArrayReturns all FACS action units that have poses defined.
EditableMesh:GetNormalVector3?Returns the normal vector for the given normal ID.
EditableMesh:GetNormalsArrayReturns all normals of the mesh.
EditableMesh:GetPositionVector3Gets the position of a vertex.
EditableMesh:GetSizeVector3Returns the size of the mesh's axis-aligned bounding box.
EditableMesh:GetUVVector2?Returns UV coordinates at the given UV ID.
EditableMesh:GetUVsArrayReturns all UVs of the mesh.
EditableMesh:GetVertexBonesArrayReturns all bone IDs that are associated with the vertex for skinning.
EditableMesh:GetVertexBoneWeightsArrayReturns skinning blend weights for each bone that is associated with the vertex.
EditableMesh:GetVertexColorsArrayReturns the color IDs of the faces attached to the given vertex.
EditableMesh:GetVertexFaceColorint64Returns the color ID of a vertex/face pair.
EditableMesh:GetVertexFaceNormalint64Returns the normal ID of a vertex/face pair.
EditableMesh:GetVertexFacesArrayReturns the face IDs of the faces attached to the given vertex.
EditableMesh:GetVertexFaceUVint64Returns the UV ID of a vertex/face pair.
EditableMesh:GetVertexNormalsArrayReturns the normal IDs of the faces attached to the given vertex.
EditableMesh:GetVertexUVsArrayReturns the UV IDs of the faces attached to the given vertex.
EditableMesh:GetVerticesArrayReturns all vertices as a list of vertex IDs.
EditableMesh:GetVerticesWithAttributeArrayReturns a list of vertices that use a given attribute ID.
EditableMesh:GetVerticesWithColorArrayReturns an array of vertex IDs that use the given color ID.
EditableMesh:GetVerticesWithNormalArrayReturns an array of vertex IDs that use the given normal ID.
EditableMesh:GetVerticesWithUVArrayReturns an array of vertex IDs that use the given UV ID.
EditableMesh:IdDebugStringstringReturns a string describing an ID, useful for debugging purposes.
EditableMesh:MergeVerticesMapMerges vertices that touch together.
EditableMesh:RaycastLocalTupleCasts a ray and returns the intersection point, face ID, and barycentric coordinates.
EditableMesh:RemoveBone()Removes a bone using its bone ID.
EditableMesh:RemoveFace()Removes a face using its face ID.
EditableMesh:RemoveUnusedArrayRemoves all unused vertices, normals, UVs, and colors, and returns the removed IDs.
EditableMesh:ResetNormal()Reset this normal ID to be automatically calculated.
EditableMesh:SetBoneCFrame()Set the initial CFrame for a bone in the mesh's bind pose.
EditableMesh:SetBoneIsVirtual()Set whether a bone is virtual.
EditableMesh:SetBoneName()Sets the name for a bone.
EditableMesh:SetBoneParent()Set a parent for a bone.
EditableMesh:SetColor()Sets the color for a color ID.
EditableMesh:SetColorAlpha()Sets the color alpha (transparency) for a color ID.
EditableMesh:SetFaceColors()Sets the face's vertex colors to new color IDs.
EditableMesh:SetFaceNormals()Sets the face's vertex normals to new normal IDs.
EditableMesh:SetFaceUVs()Sets the face's vertex UVs to new UV IDs.
EditableMesh:SetFaceVertices()Sets the face's vertices to new vertex IDs.
EditableMesh:SetFacsBonePose()Set CFrame for an individual bone in a specific FACS action unit.
EditableMesh:SetFacsCorrectivePose()Set pose for all bones in a specific FACS corrective pose.
EditableMesh:SetFacsPose()Set pose for all bones in a specific FACS action unit.
EditableMesh:SetNormal()Set the normal for a normal ID.
EditableMesh:SetPosition()Sets a vertex position in the mesh's local object space.
EditableMesh:SetUV()Sets UV coordinates for a UV ID.
EditableMesh:SetVertexBones()Assign a list of bones with the vertex for skinning.
EditableMesh:SetVertexBoneWeights()Sets skinning blend weights for each bone associated with the vertex.
EditableMesh:SetVertexFaceColor()Sets the color ID of a vertex/face pair.
EditableMesh:SetVertexFaceNormal()Sets the normal ID of a vertex/face pair.
EditableMesh:SetVertexFaceUV()Sets the UV ID of a vertex/face pair.
EditableMesh:Triangulate()Splits all faces on the mesh to be triangles.

Inherited from Object

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

EditableMesh:AddBone

Adds a new bone to the mesh and returns a bone ID that persists across topology changes. An error is thrown if the bone name is already in use, the parent ID is invalid, or the mesh already contains the maximum number of bones.

Parameters

NameTypeDefaultDescription
bonePropertiesDictionaryOptions table containing bone parameters: - Name — A string that specifies the bone name. Note that all bone names in a mesh must be unique, and the maximum length is 100 characters. - ParentId — Optional bone ID of the new bone's parent. - CFrame — Initial CFrame of the bone in the bind pose of the mesh, in the mesh's local space. - Virtual — Boolean that specifies whether this bone is virtual. Virtual bones can only be bound to a FaceControls instance.

Returns

TypeDescription
int64Bone ID of the new bone.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddColor

Adds a new vertex color attribute to the mesh and returns a color ID.

Parameters

NameTypeDefaultDescription
colorColor3The new color.
alphafloatThe color alpha (transparency). 0 is fully transparent, and 1 is fully opaque.

Returns

TypeDescription
int64Color ID of the new color.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddFace

Adds a new face from an array of vertex IDs and returns a stable face ID. A face is either a triangle (3 vertex IDs) or a quad (4 vertex IDs); any other count throws an error. For adding triangles specifically, it is preferable to use AddTriangle(), which is equivalent but slightly more performant as it avoids constructing an array for the vertices.

For rendering and collision, each quad is internally split into 2 triangles, so a quad counts as 2 triangles toward the mesh's triangle limit.

Automatic attribute assignment

AddFace() only takes vertex IDs as arguments. For each vertex of the new face, it automatically assigns normal, UV, and color attributes using the following logic:

Two adjacent faces sharing vertex attribute IDs at their common vertices

Overriding attributes after adding a face

The auto-assigned attributes can be customized after adding a face. The approach depends on whether you want to change attribute values while keeping the topology intact, or create entirely new attribute IDs to add or remove seams between faces.

To change values in-place, retrieve the auto-created IDs with methods like GetVertexFaceUV() and set their values directly. This is more performant and avoids leaving unused IDs in the mesh:

-- Create a triangle
local faceId = editableMesh:AddFace({v0, v1, v2})

-- Get the UV IDs that were automatically created
local uvId0 = editableMesh:GetVertexFaceUV(v0, faceId)
local uvId1 = editableMesh:GetVertexFaceUV(v1, faceId)
local uvId2 = editableMesh:GetVertexFaceUV(v2, faceId)

-- Set UV values on those existing UV IDs
editableMesh:SetUV(uvId0, Vector2.new(0, 0))
editableMesh:SetUV(uvId1, Vector2.new(1, 0))
editableMesh:SetUV(uvId2, Vector2.new(0, 1))

To create a seam — where the same vertex needs different attribute values on different faces (for example, a UV seam or a sharp edge) — create new attribute IDs with AddUV(), AddNormal(), or AddColor(), then assign them to the face with SetFaceUVs(), SetFaceNormals(), or SetFaceColors():

-- Create a triangle
local faceId = editableMesh:AddFace({v0, v1, v2})

-- Create new UV IDs with custom coordinates
local uv0 = editableMesh:AddUV(Vector2.new(0, 0))
local uv1 = editableMesh:AddUV(Vector2.new(1, 0))
local uv2 = editableMesh:AddUV(Vector2.new(0, 1))

-- Replace the face's UV IDs (creates a seam if the vertex had different UVs on another face)
editableMesh:SetFaceUVs(faceId, {uv0, uv1, uv2})

Normal sharing and smooth vs. sharp edges

Because new faces reuse normal IDs from adjacent faces by default, meshes appear smooth. To create a sharp edge (crease) between faces, create a separate normal ID for each face and assign it with SetFaceNormals():

Two adjacent faces with separate normal IDs producing flat shading
-- Two triangles sharing vertices v0 and v1, but with a sharp edge between them
local fid1 = editableMesh:AddFace({v0, v1, v2})
local fid2 = editableMesh:AddFace({v0, v3, v1})

-- Create separate normals for each face to produce a hard edge
local n1 = editableMesh:AddNormal() -- Auto-computed for fid1
local n2 = editableMesh:AddNormal() -- Auto-computed for fid2
editableMesh:SetFaceNormals(fid1, {n1, n1, n1})
editableMesh:SetFaceNormals(fid2, {n2, n2, n2})

See also SetNormal() to manually specify a normal vector, and ResetNormal() to revert a normal back to automatic computation.

Parameters

NameTypeDefaultDescription
vertexIdsArrayArray of the new face's vertex IDs, in order around the face. Provide 3 IDs to create a triangle or 4 IDs to create a quad.

Returns

TypeDescription
int64Face ID of the new face.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddNormal

Adds a new normal to the geometry and returns a normal ID. If the normal value isn't specified, the normal will be automatically calculated.

Parameters

NameTypeDefaultDescription
normalVector3?The normal vector. If the normal value isn't specified, the normal will be automatically calculated.

Returns

TypeDescription
int64Normal ID of the new normal.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddTriangle

Adds a new triangle to the mesh and returns a stable face ID. This is equivalent to passing an array of 3 vertex IDs to AddFace(), but is slightly more performant as it avoids constructing an array for each call.

See AddFace() for information on how all faces are added, including those added by AddTriangle(). This includes details related to automatic attribute assignment, overriding attributes, and more.

Parameters

NameTypeDefaultDescription
vertexId0int64ID of the first vertex of the triangle.
vertexId1int64ID of the second vertex of the triangle.
vertexId2int64ID of the third vertex of the triangle.

Returns

TypeDescription
int64Stable face ID of the new face.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddUV

Adds a new UV coordinate attribute to the mesh and returns a UV ID.

Parameters

NameTypeDefaultDescription
uvVector2The new UV coordinate.

Returns

TypeDescription
int64UV ID of the new UV.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:AddVertex

Adds a new vertex to the mesh and returns a vertex ID. The position is specified in the mesh's local object space. An error is thrown if the mesh already contains 60,000 vertices.

Parameters

NameTypeDefaultDescription
pVector3Position in the mesh's local object space.

Returns

TypeDescription
int64Vertex ID of the new vertex.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:BatchAdd

Creates new mesh elements of the given attribute type and returns their IDs in the same order as the input data. This method always requires an explicit MeshAttribute because its input is raw values with no existing IDs to inspect. Throws an error if the attribute type is invalid, the data format does not match, or adding the elements would exceed mesh limits.

local vIds = mesh:BatchAdd(Enum.MeshAttribute.Vertex, positions)     -- Positions: {Vector3}
local nIds = mesh:BatchAdd(Enum.MeshAttribute.Normal, normals)       -- Normals: {Vector3}
local uIds = mesh:BatchAdd(Enum.MeshAttribute.UV, uvs)               -- UVs: {Vector2}
local cIds = mesh:BatchAdd(Enum.MeshAttribute.Color, colors, alphas) -- Colors: {Color3}, Alphas: {number}
local fIds = mesh:BatchAdd(Enum.MeshAttribute.Face, {
    {vIds[1], vIds[2], vIds[3]},
    {vIds[1], vIds[3], vIds[4]},
})

Parameters

NameTypeDefaultDescription
attrMeshAttributeThe MeshAttribute type of element to create.
dataArrayValues to initialize the new elements. An array of Vector3 for Vertex or Normal; an array of Vector2 for UV; an array of Color3 followed by a matching array of alpha numbers (same length) for Color; a 2D array of vertex-ID arrays for Face.

Returns

TypeDescription
ArrayOrdered array of new element IDs matching the input order.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:BatchGetFaceAttributes

Returns, for each face, the array of per-corner attribute IDs, one per corner in the same order as GetFaceVertices().

local faceNormals = mesh:BatchGetFaceAttributes(Enum.MeshAttribute.Normal, faceIds) -- {{normalId}}
local faceVerts = mesh:BatchGetFaceAttributes(Enum.MeshAttribute.Vertex, faceIds)   -- {{vertexId}}

Parameters

NameTypeDefaultDescription
attrMeshAttributeThe attribute to retrieve for each face's corners. Must be MeshAttribute.Vertex, MeshAttribute.Normal, MeshAttribute.Color, or MeshAttribute.UV; MeshAttribute.Face is not supported and throws an error.
faceIdsArrayFaces to query.

Returns

TypeDescription
Array2D array where result[i] is the array of attribute IDs at the corners of faceIds[i].
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:BatchGetValues

Returns attribute values for the given IDs in the same order as the input. Passing an empty array returns an empty result.

local positions = mesh:BatchGetValues(vertexIds)     -- {Vector3}
local normals = mesh:BatchGetValues(normalIds)       -- {Vector3}
local uvs = mesh:BatchGetValues(uvIds)               -- {Vector2}
local colors, alphas = mesh:BatchGetValues(colorIds) -- {Color3}, {number}

Parameters

NameTypeDefaultDescription
idsArrayIDs of the elements to read. All must be the same attribute type — vertex, normal, color, or UV. The attribute is determined by the ID type, so no MeshAttribute argument is needed. Mixing types, or passing face or bone IDs, throws an error.

Returns

TypeDescription
TupleA tuple of two values. The first is an array of attribute values: Vector3 for vertex or normal IDs, Vector2 for UV IDs, Color3 for color IDs. The second is nil for all attribute types except color, where it is an array of alpha numbers.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:BatchGetVertexAttributes

Returns, for each vertex, the array of associated attribute IDs, gathered across all faces adjacent to that vertex. For example, using MeshAttribute.Face returns every face that references each vertex.

local adjFaces = mesh:BatchGetVertexAttributes(Enum.MeshAttribute.Face, vertexIds) -- {{faceId}}

Parameters

NameTypeDefaultDescription
attrMeshAttributeThe attribute type to look up. Must be MeshAttribute.Face (faces that reference each vertex), MeshAttribute.Normal, MeshAttribute.Color, or MeshAttribute.UV; MeshAttribute.Vertex is not supported and throws an error (to read vertex positions, use BatchGetValues()).
vertexIdsArrayVertices to query.

Returns

TypeDescription
Array2D array where result[i] is the array of attribute IDs associated with vertexIds[i].
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:BatchGetVertexFaceAttributes

Returns the attribute ID at each corner specified by a vertex–face pair.

local cornerColors = mesh:BatchGetVertexFaceAttributes(Enum.MeshAttribute.Color, vertexIds, faceIds)

Parameters

NameTypeDefaultDescription
attrMeshAttributeThe attribute to retrieve. Must be MeshAttribute.Normal, MeshAttribute.Color, or MeshAttribute.UV; MeshAttribute.Vertex and MeshAttribute.Face are not supported and throw an error.
vertexIdsArrayVertices that identify each corner.
faceIdsArrayFaces that identify each corner. Must be the same length as vertexIds.

Returns

TypeDescription
ArrayArray of attribute IDs at each corner, in the same order as the inputs.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:BatchRemove

Removes a batch of faces. As with RemoveFace(), the vertices and attributes used by the removed faces are not automatically deleted; call RemoveUnused() afterward to clean up unused elements.

mesh:BatchRemove(faceIds)

Parameters

NameTypeDefaultDescription
faceIdsArrayFace IDs to remove. An invalid or already-removed ID throws an error and removes nothing; duplicate IDs are collapsed to a single removal.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:BatchSetFaceAttributes

Sets the per-corner attribute IDs for each face.

-- Assign normal IDs to every corner of two faces
mesh:BatchSetFaceAttributes(faceIds, {
	{n1, n2, n3},
	{n4, n5, n6},
})

Parameters

NameTypeDefaultDescription
faceIdsArrayFace IDs to update. Must be the same length as attrIdArrays.
attrIdArraysArray2D array. attrIdArrays[i] is the list of attribute IDs for the corners of faceIds[i], in order. Each inner array must have one entry per corner of the face. All IDs must be of the same attribute type — vertex, normal, color, or UV; mixing types (or passing another ID type) throws an error.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:BatchSetValues

Writes attribute values to the given IDs. values[i] is written to ids[i]; the ids and values arrays must be the same length, unless values is nil to reset normals.

For color IDs, pass an array of Color3 to set the colors, or an array of numbers to set the alphas. Mixing types in one call is an error.

mesh:BatchSetValues(vertexIds, positions) -- Positions: {Vector3}
mesh:BatchSetValues(normalIds, normals)   -- Normals: {Vector3}
mesh:BatchSetValues(uvIds, uvs)           -- UVs: {Vector2}
mesh:BatchSetValues(colorIds, colors)     -- Colors: {Color3}
mesh:BatchSetValues(colorIds, alphas)     -- Alphas: {number}
mesh:BatchSetValues(normalIds, nil)       -- Resets each normal to auto-computed

Parameters

NameTypeDefaultDescription
idsArrayIDs of the elements to write. All must be the same attribute type — vertex, normal, color, or UV. The attribute is determined by the ID type, so no MeshAttribute argument is needed. Mixing types, or passing face or bone IDs, throws an error.
valuesArrayValues to assign. Type depends on the ID type: Vector3 for vertex or normal IDs, Vector2 for UV IDs, Color3 or a number for color IDs. Pass nil for normal IDs to reset each normal to auto-computed values, equivalent to calling ResetNormal() on each.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:BatchSetVertexFaceAttributes

Sets the attribute at a specific corner — identified by a vertex–face pair — for each element in the batch. For each index i, the attribute at corner (vertexIds[i], faceIds[i]) is set to attrIds[i].

mesh:BatchSetVertexFaceAttributes(vertexIds, faceIds, colorIds)

Parameters

NameTypeDefaultDescription
vertexIdsArrayVertex IDs that identify each corner.
faceIdsArrayFace IDs that identify each corner. Must be the same length as vertexIds.
attrIdsArrayAttribute IDs to assign, one per pair; must be the same length as vertexIds. All must be the same attribute type — normal, color, or UV; passing a vertex or face ID throws an error.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:Clear

Removes all vertex data (including positions, normals, UV coordinates, and colors), faces, bones, and FACS data without destroying the EditableMesh or its allocated space.

This method cannot be called on a fixed-size mesh (where FixedSize is true). Attempting to do so throws an error because fixed-size meshes do not allow adding or removing elements.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:Destroy

Destroys the contents of the mesh, immediately reclaiming used memory.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:FindClosestPointOnSurface

Finds the closest point on the mesh's surface. Returns the face ID, point on the mesh in local object space, the barycentric coordinates of the position within the face, and the 3 vertex IDs that the barycentric coordinates correspond to. See RaycastLocal() for more information on barycentric coordinates, including how they apply to quad faces. When the mesh is skinned, this query operates against the bind-pose geometry, not the deformed mesh as it appears at runtime.

Parameters

NameTypeDefaultDescription
pointVector3Point position in the mesh's local object space.

Returns

TypeDescription
TupleTuple of the face ID, point on the mesh in local object space, the barycentric coordinate of the position within the face, and the 3 vertex IDs that the barycentric coordinate weights.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:FindClosestVertex

Finds the closest vertex to a specific point in space and returns a vertex ID. When the mesh is skinned, this query operates against the bind-pose geometry, not the deformed mesh as it appears at runtime.

Parameters

NameTypeDefaultDescription
toThisPointVector3Point position in the mesh's local object space.

Returns

TypeDescription
int64Closest vertex ID to the specified point in space.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:FindVerticesWithinSphere

Finds all vertices within a specific sphere and returns a list of vertex IDs. When the mesh is skinned, this query operates against the bind-pose geometry, not the deformed mesh as it appears at runtime.

Parameters

NameTypeDefaultDescription
centerVector3Center of the sphere in the mesh's local object space.
radiusfloatRadius of the sphere.

Returns

TypeDescription
ArrayList of vertex IDs within the requested sphere.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetAdjacentFaces

Given a face ID, returns a list of adjacent faces.

Adjacent faces indicated around requested face

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to get adjacent faces.

Returns

TypeDescription
ArrayList of face IDs adjacent to the given face.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetAdjacentVertices

Given a vertex ID, returns a list of adjacent vertices.

Adjacent vertices indicated around requested vertex

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID around which to get adjacent vertices.

Returns

TypeDescription
ArrayList of IDs of adjacent vertices around the given vertex ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBoneByName

Finds the bone ID of the bone with the given name. Errors if no bone with that name exists.

Parameters

NameTypeDefaultDescription
boneNamestringBone name to search for.

Returns

TypeDescription
int64Bone ID of the bone with the given name.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBoneCFrame

Returns the initial CFrame of the bone in the bind pose of the mesh, in the mesh's local space.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to get the CFrame.

Returns

TypeDescription
CFrameInitial CFrame of the bone in the bind pose of the mesh, in the mesh's local space.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBoneIsVirtual

Returns true if the bone is virtual. Virtual bones can only be bound to a FaceControls instance.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to get whether the bone is virtual.

Returns

TypeDescription
booleanWhether the bone with the given bone ID is virtual. Virtual bones can only be bound to a FaceControls instance.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBoneName

Returns the name string of the bone identified by the given bone ID. Bone names are unique within the mesh and can be up to 100 characters long.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to get the name.

Returns

TypeDescription
stringName of the bone with the given bone ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBoneParent

Returns the bone ID of the parent bone in the bone hierarchy. If the bone has no parent, returns 0.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to get the parent.

Returns

TypeDescription
int64Bone ID for the parent of the bone with the given bone ID. If there is no parent, returns 0.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetBones

Returns all bones of the mesh as a list of bone IDs.

Returns

TypeDescription
ArrayList of bone IDs.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetCenter

Returns the center of the mesh's axis-aligned bounding box, in the mesh's local object space.

Returns

TypeDescription
Vector3Center of the bounding box of the EditableMesh.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetColor

Returns the Color3 value stored at the given color ID. Use GetColorAlpha() to retrieve the alpha component separately.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID for which to get the color.

Returns

TypeDescription
Color3?Color for the requested color ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetColorAlpha

Returns the alpha component of the vertex color at the given color ID as a number between 0 (fully transparent) and 1 (fully opaque). Use GetColor() to retrieve the RGB component.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID for which to get the alpha.

Returns

TypeDescription
float?Color alpha at the request color ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetColors

Returns all colors of the mesh as a list of color IDs.

Returns

TypeDescription
ArrayList of color IDs.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFaceColors

Returns an array of color IDs, one per vertex corner of the specified face, in the same order as GetFaceVertices(). Use these IDs with GetColor() and GetColorAlpha() to read the actual color values.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to get the color IDs.

Returns

TypeDescription
ArrayList of color IDs used for the vertices on the given face.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFaceNormals

Returns an array of normal IDs, one per vertex corner of the specified face, in the same order as GetFaceVertices(). Use these IDs with GetNormal() to read the actual normal vectors.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to get the normal IDs.

Returns

TypeDescription
ArrayList of normal IDs used for the vertices on the given face.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFaces

Returns all faces of the mesh as a list of face IDs.

Returns

TypeDescription
ArrayList of face IDs.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacesWithAttribute

Deprecated. This method is deprecated. Do not use it for new work.

Returns a list of faces that use a given vertex ID, normal ID, UV ID, or color ID.

Parameters

NameTypeDefaultDescription
idint64Attribute ID for which to find faces that use it.

Returns

TypeDescription
ArrayList of face IDs which use the given attribute ID.
FieldValue
tags["Deprecated"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacesWithColor

Returns an array of face IDs that use the given color ID. Use together with GetVerticesWithColor() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID to find faces for.

Returns

TypeDescription
ArrayList of face IDs that use the provided color ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacesWithNormal

Returns an array of face IDs that use the given normal ID. Use together with GetVerticesWithNormal() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
normalIdint64Normal ID to find faces for.

Returns

TypeDescription
ArrayList of face IDs that use the provided normal ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacesWithUV

Returns an array of face IDs that use the given UV ID. Use together with GetVerticesWithUV() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
uvIdint64UV ID to find faces for.

Returns

TypeDescription
ArrayList of face IDs that use the provided UV ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFaceUVs

Returns an array of UV IDs, one per vertex corner of the specified face, in the same order as GetFaceVertices(). Use these IDs with GetUV() to read the actual UV coordinates.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to get the UV IDs.

Returns

TypeDescription
ArrayList of UV IDs used for the vertices on the given face.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFaceVertices

Returns an array of vertex IDs that define the corners of the given face, in the same order used when the face was created.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to get the vertex IDs.

Returns

TypeDescription
ArrayList of vertex IDs around the given face.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacsCorrectivePose

Returns bone IDs and bone CFrames for all bones in a specific FACS corrective pose. Each bone CFrame transforms the bone from the initial bone CFrame in the bind pose of the mesh to the combined bone CFrame for this pose. All CFrames are in the mesh's local space.

Parameters

NameTypeDefaultDescription
actionsArrayArray or 2 or 3 FacsActionUnit values that specify a corrective pose.

Returns

TypeDescription
TupleArray of bone IDs and corresponding array of bone CFrames.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacsCorrectivePoses

Returns all FACS corrective poses that are in use. Each corrective pose is specified by 2 or 3 FacsActionUnit values.

Returns

TypeDescription
ArrayArray of corrective poses. Each corrective pose is specified by a small array of 2 or 3 FacsActionUnit values.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacsPose

Returns bone IDs and bone CFrames for all bones in a specific FACS action unit. Each bone CFrame transforms the bone from the initial bone CFrame in the bind pose of the mesh to the combined bone CFrame for this pose. All CFrames are in the mesh's local space.

Parameters

NameTypeDefaultDescription
actionFacsActionUnitFACS action unit for which to get the pose.

Returns

TypeDescription
TupleArray of bone IDs and corresponding array of bone CFrame.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetFacsPoses

Returns an array of FacsActionUnit values representing all base FACS poses currently defined on this mesh. Use each returned value with GetFacsPose() to retrieve the bone transforms for that pose. See also GetFacsCorrectivePoses() for corrective poses.

Returns

TypeDescription
ArrayArray of FacsActionUnit, one for each FACS action unit that has a pose defined.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetNormal

Returns the Vector3 normal vector at the given normal ID. If the normal vector was manually specified it will return that vector. If the normal vector was not specified or was reset, this will return an automatically calculated normal vector based on the shape of the mesh.

Parameters

NameTypeDefaultDescription
normalIdint64Normal ID for which to get the normal vector.

Returns

TypeDescription
Vector3?Normal vector at the requested normal ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetNormals

Returns all normals of the mesh as a list of normal IDs.

Returns

TypeDescription
ArrayList of normal IDs.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetPosition

Gets the position of a vertex in the mesh's local object space.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID for which to get the position.

Returns

TypeDescription
Vector3Position of a vertex in the mesh's local object space.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetSize

Returns the size of the mesh's axis-aligned bounding box, in the mesh's local object space.

Returns

TypeDescription
Vector3Size of the EditableMesh.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetUV

Returns the Vector2 texture coordinate stored at the given UV ID. UV coordinates map the mesh surface to a 2D texture.

Parameters

NameTypeDefaultDescription
uvIdint64UV ID for which to get the UV coordinate.

Returns

TypeDescription
Vector2?UV coordinates at the requested UV ID.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetUVs

Returns all UVs of the mesh as a list of UV IDs.

Returns

TypeDescription
ArrayList of UV IDs.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexBones

Returns an array of bone IDs that influence the given vertex during skinning deformation. A vertex can be influenced by up to 4 bones. The returned array corresponds index-by-index with the weights returned by GetVertexBoneWeights() for the same vertex.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID for which to get the associated bones.

Returns

TypeDescription
ArrayBone IDs associated with the vertex for skinning.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexBoneWeights

Returns an array of blend weights (each between 0 and 1) for the bones influencing this vertex during skeletal deformation. The returned array corresponds index-by-index with the bone IDs returned by GetVertexBones() for the same vertex.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID for which to get the associated bone weights.

Returns

TypeDescription
ArraySkinning blend weights for each bone that is associated with the vertex.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexColors

Returns an array of color IDs used on all face corners that reference the given vertex. A vertex shared by multiple faces can have different color IDs on each face (a color seam); this method returns all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID to find color IDs.

Returns

TypeDescription
ArrayArray of color IDs of faces attached to the given vertex.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexFaceColor

Returns the color ID assigned to a specific corner of a face, identified by the vertex/face pair. This is useful when a vertex is shared by multiple faces and you need the color for one particular face corner rather than all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.

Returns

TypeDescription
int64Color ID of the vertex/face pair.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexFaceNormal

Returns the normal ID assigned to a specific corner of a face, identified by the vertex/face pair. This is useful when a vertex has split normals (a sharp edge) and you need the normal for one particular face corner rather than all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.

Returns

TypeDescription
int64Normal ID of the vertex/face pair.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexFaces

Returns an array of face IDs for all faces that have the given vertex as one of their corners. Use this to traverse the mesh topology around a vertex, for example to find all faces affected by moving a vertex.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID to find faces for.

Returns

TypeDescription
ArrayArray of face IDs attached to the given vertex.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexFaceUV

Returns the UV ID assigned to a specific corner of a face, identified by the vertex/face pair. This is useful when a vertex has a UV seam and you need the UV for one particular face corner rather than all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.

Returns

TypeDescription
int64UV ID of the vertex/face pair.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexNormals

Returns an array of normal IDs used on all face corners that reference the given vertex. A vertex shared by multiple faces can have different normal IDs on each face (a hard/sharp edge); this method returns all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID to find normal IDs.

Returns

TypeDescription
ArrayArray of normal IDs of faces attached to the given vertex.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertexUVs

Returns an array of UV IDs used on all face corners that reference the given vertex. A vertex shared by multiple faces can have different UV IDs on each face (a UV seam); this method returns all of them.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID to find UV IDs.

Returns

TypeDescription
ArrayArray of UV IDs of faces attached to the given vertex.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVertices

Returns all vertex IDs in the mesh as a list of IDs. The IDs may not be contiguous. Use this list to iterate over vertices safely, rather than assuming consecutive numbering.

Returns

TypeDescription
ArrayList of vertex IDs.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVerticesWithAttribute

Deprecated. This method is deprecated. Do not use it for new work.

Returns a list of vertices that use a given face ID, normal ID, UV ID, or color ID.

Parameters

NameTypeDefaultDescription
idint64Attribute ID for which to find vertices that use it.

Returns

TypeDescription
ArrayList of vertex IDs which use the given attribute ID.
FieldValue
tags["Deprecated"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVerticesWithColor

Returns an array of vertex IDs that use the given color ID. Use together with GetFacesWithColor() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID to find faces for.

Returns

TypeDescription
ArrayList of face IDs that use the provided color ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVerticesWithNormal

Returns an array of vertex IDs that use the given normal ID. Use together with GetFacesWithNormal() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
normalIdint64Normal ID to find vertices for.

Returns

TypeDescription
ArrayList of vertex IDs that use the provided normal ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:GetVerticesWithUV

Returns an array of vertex IDs that use the given UV ID. Use together with GetFacesWithUV() to obtain all face/vertex pairs.

Parameters

NameTypeDefaultDescription
uvIdint64UV ID to find vertices for.

Returns

TypeDescription
ArrayList of vertex IDs that use the provided UV ID.
FieldValue
tags["CustomLuaState"]
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

EditableMesh:IdDebugString

Returns a string describing an ID, useful for debugging purposes, like f17 or v12, containing the type, ID number, and version.

Parameters

NameTypeDefaultDescription
idint64ID for which to return a debugging information string.

Returns

TypeDescription
stringString that describes the ID in human-readable format.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:MergeVertices

Merges vertices that touch together, to use a single vertex ID but keep the other original attribute IDs.

Parameters

NameTypeDefaultDescription
mergeTolerancefloatThe distance at which the vertices are considered to touch each other.

Returns

TypeDescription
MapA mapping of old vertex ID to new vertex ID for vertices that have been merged.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:RaycastLocal

Casts a ray and returns the face ID, point of intersection, barycentric coordinates, and the 3 vertex IDs that the barycentric coordinates correspond to. The inputs and outputs of this method are in the mesh's local object space. When the mesh is skinned, this raycast operates against the bind-pose geometry, not the deformed mesh as it appears at runtime.

A barycentric coordinate is a way of specifying a point within a triangle as a weighted combination of the triangle's 3 vertices. This is useful as a general way of blending vertex attributes. See this method's code sample as an illustration.

Because a barycentric coordinate is defined over exactly 3 vertices, when the hit face is a quad, the coordinate and the returned vertex IDs refer to 3 of the quad's 4 vertices forming the corners of the sub-triangle that was hit. Use the returned vertex IDs, rather than the face's full vertex list, to identify which vertices the weights apply to.

Parameters

NameTypeDefaultDescription
originVector3Origin of the ray in the mesh's local object space.
directionVector3Direction of the ray.

Returns

TypeDescription
TupleTuple of the face ID, point of intersection, barycentric coordinates, and the 3 vertex IDs that the barycentric coordinates weight.
FieldValue
securityNone
thread safetySafe
capabilities["DynamicGeneration"]

Code samples: View on Creator Hub (EditableMesh-RaycastLocal).

EditableMesh:RemoveBone

Removes a bone from the mesh using its bone ID. Any vertex skinning weights that referenced the removed bone are also cleared.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID of the bone to remove.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:RemoveFace

Removes a face from the mesh using its face ID. The vertices and attributes that were used by the face are not automatically deleted; call RemoveUnused() afterward if you want to clean up unused vertices and attributes.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID of the face to remove.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:RemoveUnused

Removes all vertices, normals, UVs, and colors which are not used in any face, and returns the removed IDs.

Returns

TypeDescription
ArrayAll of the removed IDs.
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:ResetNormal

Reset this normal ID to be automatically calculated based on the shape of the mesh, instead of manually set.

Parameters

NameTypeDefaultDescription
normalIdint64Normal ID to reset.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetBoneCFrame

Set the initial CFrame for a bone in the mesh's bind pose, in the mesh's local space.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to set the initial CFrame.
cframeCFrameInitial CFrame for the bone in the mesh's bind pose, in the mesh's local space.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetBoneIsVirtual

Set whether a bone is virtual. Virtual bones can only be bound to a FaceControls instance.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to set whether the bone is virtual.
virtualbooleanWhether the bone should be virtual.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetBoneName

Sets the name for a bone. Bone names can be 100 characters long and must be unique in the mesh.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to set the name.
namestringBone name to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetBoneParent

Sets the parent of a bone in the bone hierarchy. Pass a valid bone ID to parent the bone, or 0 to make it a root bone. The engine validates that the new parent does not create a cycle in the bone hierarchy and throws an error if the parent ID is invalid or would produce a circular dependency.

Parameters

NameTypeDefaultDescription
boneIdint64Bone ID for which to set the parent.
parentBoneIdint64Parent bone ID.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetColor

Sets the Color3 value for a color ID. This changes the vertex color for every face corner that references this color ID. Use SetColorAlpha() to change the alpha component separately.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID for which to set the color.
colorColor3Color to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetColorAlpha

Sets the alpha (transparency) component of the vertex color at the given color ID. The value is a number between 0 (fully transparent) and 1 (fully opaque). This changes the alpha for every face corner that references this color ID.

Parameters

NameTypeDefaultDescription
colorIdint64Color ID for which to set the color alpha.
alphafloatAlpha to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFaceColors

Assigns new color IDs to the corners of a face, replacing whatever color IDs were previously set. The array must contain one color ID per vertex of the face, in the same winding order as GetFaceVertices(). Use this to create a color seam at a vertex shared by multiple faces.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to update the vertex colors.
idsArrayList of new color IDs to use for the given face's vertices.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFaceNormals

Assigns new normal IDs to the corners of a face, replacing whatever normal IDs were previously set. The array must contain one normal ID per vertex of the face, in the same winding order as GetFaceVertices(). Use this to create a hard/sharp edge by giving adjacent faces different normals at the same vertex.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to update the vertex normals.
idsArrayList of new normal IDs to use for the given face's vertices.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFaceUVs

Assigns new UV IDs to the corners of a face, replacing whatever UV IDs were previously set. The array must contain one UV ID per vertex of the face, in the same winding order as GetFaceVertices(). Use this to create a UV seam at a vertex shared by multiple faces.

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to update the vertex UVs.
idsArrayList of new UV IDs to use for the given face's vertices.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFaceVertices

Replaces the vertex IDs at each corner of the given face, in winding order. Passing 3 vertex IDs makes the face a triangle and 4 makes it a quad, so this can convert a face between a triangle and a quad while keeping the same face ID.

The normal, UV, and color attributes on each of the existing corners are preserved. If a new corner is added, it follows the same automatic attribute assignment described in AddFace().

Parameters

NameTypeDefaultDescription
faceIdint64Face ID for which to update the vertices.
idsArrayList of new vertex IDs to use for the given face.

Returns

TypeDescription
()
FieldValue
tags["CustomLuaState"]
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFacsBonePose

Sets the CFrame for a single bone within a specific FACS action unit pose, without modifying the other bones in that pose. The bone must be virtual. The CFrame transforms the bone from its initial bind-pose position to the target pose position, in the mesh's local space. Use this for incremental edits to a FACS pose; use SetFacsPose() to set all bones in a pose at once.

Parameters

NameTypeDefaultDescription
actionFacsActionUnitFACS action unit for which to set the pose.
boneIdint64Bone to set a CFrame for this pose.
cframeCFrameCFrame which transforms the bone from the initial bone CFrame in the bind pose of the mesh to the combined bone CFrame for this pose. All CFrames are in the mesh's local space.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFacsCorrectivePose

Sets all bone transforms for a FACS corrective pose, which overrides the blended result of 2 or 3 base poses when they are active simultaneously. The actions array must contain exactly 2 or 3 FacsActionUnit values that identify the combination. All referenced bones must be virtual. The boneIds and cframes arrays must be the same length; each CFrame transforms the bone from the bind pose to the corrective target, in the mesh's local space. Throws if the action combination is not a valid corrective.

Parameters

NameTypeDefaultDescription
actionsArrayArray or 2 or 3 FacsActionUnit values to apply as a corrective pose.
boneIdsArrayBones to set a CFrame for this pose.
cframesArrayCFrame transforms for the bones in this corrective pose. Each bone CFrame transforms the bone from the initial bone CFrame in the bind pose of the mesh to the combined bone CFrame for this pose. All CFrames are in the mesh's local space.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetFacsPose

Sets all bone transforms for a FACS base pose (a single action unit). The boneIds and cframes arrays must be the same length; each CFrame transforms the bone from the bind pose to the target pose, in the mesh's local space. All referenced bones must be virtual (non-virtual bones throw an error). This replaces any previously defined pose for the given action unit.

Parameters

NameTypeDefaultDescription
actionFacsActionUnitFACS action unit to set the pose for.
boneIdsArrayBones for which to set a CFrame for this pose.
cframesArrayCFrame transforms for the bones in this pose. Each bone CFrame transforms the bone from the initial bone CFrame in the bind pose of the mesh to the combined bone CFrame for this pose. All CFrames are in the mesh's local space.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetNormal

Set the normal for a normal ID. This will change the normal value for every face vertex which is using the normal ID.

Parameters

NameTypeDefaultDescription
normalIdint64Normal ID for which to set the normal vector.
normalVector3Normal vector to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetPosition

Sets a vertex position in the mesh's local object space. Please note that collision and other physics data on linked MeshParts is not updated until you call AssetService:CreateMeshPartAsync() and MeshPart:ApplyMesh().

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID of the vertex to position.
pVector3Position in the mesh's local object space.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetUV

Sets the Vector2 texture coordinate for a UV ID. This changes the UV mapping for every face corner that references this UV ID.

Parameters

NameTypeDefaultDescription
uvIdint64UV ID for which to set the UV coordinates.
uvVector2UV coordinates.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetVertexBones

Assign a list of bones with the vertex for skinning.

Corresponds with the skinning blend weights used in SetVertexBoneWeights(). In other words, GetVertexBoneWeights(vertexId)[i] is the weight on this vertex for GetVertexBones(vertexId)[i].

This method should be called before calling SetVertexBoneWeights().

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID to set vertex skinning bones.
boneIDsArrayBone IDs to use with this vertex for skinning.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetVertexBoneWeights

Sets skinning blend weights for each bone associated with the vertex.

Corresponds with the bone IDs used in SetVertexBones(). In other words, GetVertexBoneWeights(vertexId)[i] is the weight on this vertex for GetVertexBones(vertexId)[i].

This method should be called after calling SetVertexBones().

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID on which to set skinning blend weights.
boneWeightsArraySkinning blend weights to set on the vertex.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetVertexFaceColor

Sets the color ID for a specific corner of a face, identified by the vertex/face pair. This is equivalent to changing just one element of the array set by SetFaceColors(), and is useful for creating or removing a color seam at a single vertex without affecting the other corners of the face.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.
colorIdint64Color ID to set for the vertex/face pair.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetVertexFaceNormal

Sets the normal ID for a specific corner of a face, identified by the vertex/face pair. This is equivalent to changing just one element of the array set by SetFaceNormals(), and is useful for creating or removing a hard edge at a single vertex without affecting the other corners of the face.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.
normalIdint64Normal ID to set for the vertex/face pair.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:SetVertexFaceUV

Sets the UV ID for a specific corner of a face, identified by the vertex/face pair. This is equivalent to changing just one element of the array set by SetFaceUVs(), and is useful for creating or removing a UV seam at a single vertex without affecting the other corners of the face.

Parameters

NameTypeDefaultDescription
vertexIdint64Vertex ID.
faceIdint64Face ID.
uvIdint64UV ID to set for the vertex/face pair.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

EditableMesh:Triangulate

Splits every quad face on the mesh into two triangle faces each. A heuristic is used to determine which diagonal each quad should be split along to produce better-shaped triangles. If your code relies on faces being triangles, call this method after AssetService:CreateEditableMeshAsync(), which may produce quad faces.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["DynamicGeneration"]

Events

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.