Reference API Roblox

Engine API

Website

Related

Reference API Roblox

EditableMesh

Instance which allows for the runtime creation and manipulation of meshes.

Member index 57

HistoryMember
624SkinningEnabled: bool
640AddColor(color: Color3, alpha: float): int64
640AddNormal(normal: Vector3?): int64
604AddTriangle(vertexId0: int64, vertexId1: int64, vertexId2: int64): int64
640AddUV(uv: Vector2): int64
604AddVertex(p: Vector3): int64
619CreateMeshPartAsync(options: Dictionary = nil): MeshPart
602FindClosestPointOnSurface(point: Vector3): Tuple
604FindClosestVertex(toThisPoint: Vector3): int64
602FindVerticesWithinSphere(center: Vector3, radius: float): Array
640GetAdjacentFaces(faceId: int64): Array
640GetAdjacentTriangles(triangleId: int64): Array
604GetAdjacentVertices(vertexId: int64): Array
640GetColor(colorId: int64): Color3?
640GetColorAlpha(colorId: int64): float?
640GetColors(): Array
640GetFaceColors(faceId: int64): Array
640GetFaceNormals(faceId: int64): Array
640GetFaceUVs(faceId: int64): Array
640GetFaceVertices(faceId: int64): Array
640GetFaces(): Array
640GetFacesWithAttribute(id: int64): Array
640GetNormal(normalId: int64): Vector3?
640GetNormals(): Array
604GetPosition(vertexId: int64): Vector3
640GetTriangleVertices(triangleId: int64): Tuple
640GetTriangles(): Array
640GetUV(uvId: int64): Vector2?
640GetUVs(): Array
640GetVertexColor(vertexId: int64): Color3
640GetVertexColorAlpha(vertexId: int64): float
640GetVertexNormal(vertexId: int64): Vector3
602GetVertices(): Array
640GetVerticesWithAttribute(id: int64): Array
640IdDebugString(id: int64): string
640MergeVertices(mergeTolerance: float): Map
604RaycastLocal(origin: Vector3, direction: Vector3): Tuple
640RemoveFace(faceId: int64): null
640RemoveTriangle(triangleId: int64): null
640RemoveUnused(): Array
640RemoveVertex(vertexId: int64): null
640ResetNormal(normalId: int64): null
640SetColor(colorId: int64, color: Color3): null
640SetColorAlpha(colorId: int64, alpha: float): null
640SetFaceColors(faceId: int64, ids: Array): null
640SetFaceNormals(faceId: int64, ids: Array): null
640SetFaceUVs(faceId: int64, ids: Array): null
640SetFaceVertices(faceId: int64, ids: Array): null
640SetNormal(normalId: int64, normal: Vector3): null
604SetPosition(vertexId: int64, p: Vector3): null
640SetUV(uvId: int64, uv: Vector2): null
640SetVertexColor(vertexId: int64, color: Color3): null
640SetVertexColorAlpha(vertexId: int64, alpha: float): null
640SetVertexNormal(vertexId: int64, vnormal: Vector3): null
640Triangulate(): null
inherited from DataModelMesh
553Offset: Vector3
553Scale: Vector3
553VertexColor: Vector3
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553ClassName: string
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
553className: string
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
486GetChildren(): Objects
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
462GetPropertyChangedSignal(property: string): RBXScriptSignal
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsA(className: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
553children(): Objects
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
553getChildren(): Objects
462isA(className: string): bool
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462Changed(property: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)

Removed member index 2

HistoryMember
604Raycast(origin: Vector3, direction: Vector3): Tuple

Description

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

An EditableMesh can be created from an existing mesh ID using AssetService:CreateEditableMeshAsync(), or a blank EditableMesh can be created with Instance.new(). 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.

An EditableMesh is displayed when it's parented to a MeshPart, but only the part's appearance changes while the collision model remains the same.

Stable Vertex/Face IDs

Many EditableMesh methods take vertex 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 GetTriangles().

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

Limitations

EditableMesh currently has a limit of 60,000 vertices and 20,000 triangles. Attempting to add too many vertices or triangles will cause an error.

History 143

Members 57

AddColor

Parameters (2)
colorColor3
alphafloat
Returns (1)
int64

History 1

AddNormal

Parameters (1)
normalVector3?
Returns (1)
int64

History 1

AddTriangle

Parameters (3)
vertexId0int64
vertexId1int64
vertexId2int64
Returns (1)
int64

Adds a new triangle to the mesh and returns a stable triangle ID.

History 7

AddUV

Parameters (1)
uvVector2
Returns (1)
int64

History 1

AddVertex

Parameters (1)
pVector3
Returns (1)
int64

Adds a new vertex to the geometry and returns a stable vertex ID.

History 4

CreateMeshPartAsync

Parameters (1)Default
optionsDictionarynil
Returns (1)
MeshPart
This function yields. It will block the calling thread until completion.

History 2

Tags: [Yields]

FindClosestPointOnSurface

Parameters (1)
pointVector3
Returns (1)
Tuple

Finds the closest point on the mesh's surface. Returns the triangle ID, point on the mesh in local object space, and the barycentric coordinate of the position within the triangle. See RaycastLocal() for more information on barycentric coordinates.

History 1

FindClosestVertex

Parameters (1)
toThisPointVector3
Returns (1)
int64

Finds the closest vertex to a specific point in space and returns a stable vertex ID.

History 4

FindVerticesWithinSphere

Parameters (2)
centerVector3
radiusfloat
Returns (1)
Array

Finds all vertices within a specific sphere and returns a list of stable vertex IDs.

History 1

GetAdjacentFaces

Parameters (1)
faceIdint64
Returns (1)
Array

History 1

GetAdjacentTriangles

Parameters (1)
triangleIdint64
Returns (1)
Array

Given a stable triangle ID, returns a list of adjacent triangles.

Adjacent triangles indicated around requested triangle
This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

GetAdjacentVertices

Parameters (1)
vertexIdint64
Returns (1)
Array

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

Adjacent vertices indicated around requested vertex

History 4

GetColor

Parameters (1)
colorIdint64
Returns (1)
Color3?

History 1

GetColorAlpha

Parameters (1)
colorIdint64
Returns (1)
float?

History 1

GetColors

Parameters (0)
No parameters.
Returns (1)
Array

History 1

GetFaceColors

Parameters (1)
faceIdint64
Returns (1)
Array

History 1

GetFaceNormals

Parameters (1)
faceIdint64
Returns (1)
Array

History 1

GetFaceUVs

Parameters (1)
faceIdint64
Returns (1)
Array

History 1

GetFaceVertices

Parameters (1)
faceIdint64
Returns (1)
Array

History 1

GetFaces

Parameters (0)
No parameters.
Returns (1)
Array

History 1

GetFacesWithAttribute

Parameters (1)
idint64
Returns (1)
Array

History 1

GetNormal

Parameters (1)
normalIdint64
Returns (1)
Vector3?

History 1

GetNormals

Parameters (0)
No parameters.
Returns (1)
Array

History 1

GetPosition

Parameters (1)
vertexIdint64
Returns (1)
Vector3

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

History 4

GetTriangleVertices

Parameters (1)
triangleIdint64
Returns (1)
Tuple

Returns a triangle's three vertex IDs.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

GetTriangles

Parameters (0)
No parameters.
Returns (1)
Array

Returns all triangles of the mesh as a list of stable triangle IDs.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 2

Tags: [Deprecated]

GetUV

Parameters (1)
uvIdint64
Returns (1)
Vector2?

Returns UV coordinates at the given vertex.

History 6

GetUVs

Parameters (0)
No parameters.
Returns (1)
Array

History 1

GetVertexColor

Parameters (1)
vertexIdint64
Returns (1)
Color3

Returns the color at the given vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

GetVertexColorAlpha

Parameters (1)
vertexIdint64
Returns (1)
float

Returns the color alpha (transparency) at the given vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

GetVertexNormal

Parameters (1)
vertexIdint64
Returns (1)
Vector3

Returns the normal at the given vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

GetVertices

Parameters (0)
No parameters.
Returns (1)
Array

Returns all vertices as a list of stable vertex IDs.

History 1

GetVerticesWithAttribute

Parameters (1)
idint64
Returns (1)
Array

History 1

IdDebugString

Parameters (1)
idint64
Returns (1)
string

History 1

MergeVertices

Parameters (1)
mergeTolerancefloat
Returns (1)
Map

History 1

RaycastLocal

Parameters (2)
originVector3
directionVector3
Returns (1)
Tuple

Casts a ray and returns a point of intersection, triangle ID, and barycentric coordinates. The inputs and outputs of this method are in the mesh's local object space.

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

History 3

RemoveFace

Parameters (1)
faceIdint64
Returns (1)
null

History 1

RemoveTriangle

Parameters (1)
triangleIdint64
Returns (1)
null

Removes a triangle using its stable triangle ID.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

RemoveUnused

Parameters (0)
No parameters.
Returns (1)
Array

History 1

RemoveVertex

Parameters (1)
vertexIdint64
Returns (1)
null

Removes a vertex using its stable vertex ID.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

ResetNormal

Parameters (1)
normalIdint64
Returns (1)
null

History 1

SetColor

Parameters (2)
colorIdint64
colorColor3
Returns (1)
null

History 1

SetColorAlpha

Parameters (2)
colorIdint64
alphafloat
Returns (1)
null

History 1

SetFaceColors

Parameters (2)
faceIdint64
idsArray
Returns (1)
null

History 1

SetFaceNormals

Parameters (2)
faceIdint64
idsArray
Returns (1)
null

History 1

SetFaceUVs

Parameters (2)
faceIdint64
idsArray
Returns (1)
null

History 1

SetFaceVertices

Parameters (2)
faceIdint64
idsArray
Returns (1)
null

History 1

SetNormal

Parameters (2)
normalIdint64
normalVector3
Returns (1)
null

History 1

SetPosition

Parameters (2)
vertexIdint64
pVector3
Returns (1)
null

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

History 4

SetUV

Parameters (2)
uvIdint64
uvVector2
Returns (1)
null

Sets UV coordinates for a vertex.

History 5

SetVertexColor

Parameters (2)
vertexIdint64
colorColor3
Returns (1)
null

Sets the color for a vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

SetVertexColorAlpha

Parameters (2)
vertexIdint64
alphafloat
Returns (1)
null

Sets the color alpha (transparency) for a vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

SetVertexNormal

Parameters (2)
vertexIdint64
vnormalVector3
Returns (1)
null

Sets the normal for a vertex.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 5

Tags: [Deprecated]

SkinningEnabled

TypeDefault
boolfalse

History 1

Triangulate

Parameters (0)
No parameters.
Returns (1)
null

History 1

Removed members 2

Raycast

Parameters (2)
originVector3
directionVector3
Returns (1)
Tuple

History 4

Settings