EditableMesh

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingMeshes and 3D

Up and coming

Build, reshape, split and recolour triangle meshes from code.

An EditableMesh keeps its triangles in flat buffers. Its vertex and face members carry Roblox's EditableMesh names, ReadTriangles and WriteTriangles move a big mesh in one call, and its geometry never yields: bounds, normalise, place like a MeshPart, merge, crop to a box, split and bake vertex colours into an atlas. Get one from MeshService:LoadAsync, or from AssetService.

Properties

NameTypeDefaultDescription
TriangleCountnumberread-only
VertexCountnumber
Bones{ [string]: MeshBone }The mesh's bones by name, each with its parent's name, a CFrame and its weights.
IsSkinnedboolean

Methods

NameArgumentsReturnsDescription
AddVertex(position: Vector3)number
AddTriangle(vertexId0: number, vertexId1: number, vertexId2: number)numberReturns a face id, as Roblox's EditableMesh:AddTriangle does.
GetPosition(vertexId: number)Vector3
SetPosition(vertexId: number, position: Vector3)()
GetVertices(){ number }
GetFaces(){ number }
GetFaceVertices(faceId: number){ number }
RemoveFace(faceId: number)()
AddUV(uv: Vector2)number
AddNormal(normal: Vector3)number
AddColor(color: Color3, alpha: number)number
SetFaceUVs(faceId: number, ids: { number })()
SetFaceNormals(faceId: number, ids: { number })()
SetFaceColors(faceId: number, ids: { number })()
ReadTriangles()bufferThe whole mesh in bulk: 36 bytes a corner, three corners a triangle; position, normal and UV as f32, colour as u8 RGBA.
WriteTriangles(data: buffer)()Replaces the whole mesh from a triangle buffer, the bulk way in for anything past a few thousand vertices.
GetBounds()(Vector3, Vector3)Returns the minimum and maximum corners; it never yields.
Normalize()()Centres the mesh and fits it to a 1x1x1 box, as a MeshPart's mesh is before its Size scales it.
PlaceAs(cframe: CFrame, size: Vector3)()Moves a normalised mesh into world space as a MeshPart with that CFrame and Size would place it.
Scale(scale: Vector3)()
SetColor(color: Color3, alpha: number?)()
Append(other: EditableMesh)()Merges another mesh into this one.
GetFacesInBox(cframe: CFrame, size: Vector3){ number }Returns the faces with all three corners inside the box.
SplitConnected(){ EditableMesh }Splits the mesh into pieces that share no position.
SplitByUVIsland(){ EditableMesh }
RecalculateNormals(smooth: boolean)()Recomputes the normals; false gives flat shading.
BakeColorsToAtlas(cellSize: number?)EditableImageMakes each vertex colour an atlas cell, points the UVs at it, turns the colours white and returns the atlas.
ToBlx()buffer
From ShotInstance 33