Open Asterune
Mesh

Mesh

Creates and edits polygon geometry, skin weights, and morph targets.

Behavior

Mesh creates and edits polygon geometry, skin weights, and morph targets.

Summary

Constructors9
Functions9
  • Mesh.ball(radius: number?, segments: number?): Mesh

    Creates a sphere mesh with the supplied radius and segment count.

  • Mesh.box(size: Vector3?): Mesh

    Creates a box mesh with the supplied dimensions.

  • Mesh.cornerWedge(size: Vector3?): Mesh

    Creates a corner-wedge mesh with the supplied dimensions.

  • Mesh.cylinder(radius: number?, height: number?, segments: number?): Mesh

    Creates a cylinder mesh with the supplied radius, height, and segment count.

  • Mesh.fromPart(part: BasePart): Mesh

    Creates a mesh from the supplied BasePart's geometry.

  • Mesh.new(): Mesh

    Creates an empty editable Mesh.

  • Mesh.prism(sides: number?, radius: number?, height: number?): Mesh

    Creates a prism with the supplied side count, radius, and height.

  • Mesh.pyramid(sides: number?, radius: number?, height: number?): Mesh

    Creates a pyramid with the supplied side count, radius, and height.

  • Mesh.wedge(size: Vector3?): Mesh

    Creates a wedge mesh with the supplied dimensions.

Members75
Properties5
Methods70

Constructors

ball

Mesh.ball(radius: number?, segments: number?): Mesh

Creates a sphere mesh with the supplied radius and segment count.

box

Mesh.box(size: Vector3?): Mesh

Creates a box mesh with the supplied dimensions.

cornerWedge

Mesh.cornerWedge(size: Vector3?): Mesh

Creates a corner-wedge mesh with the supplied dimensions.

cylinder

Mesh.cylinder(radius: number?, height: number?, segments: number?): Mesh

Creates a cylinder mesh with the supplied radius, height, and segment count.

fromPart

Mesh.fromPart(part: BasePart): Mesh

Creates a mesh from the supplied BasePart's geometry.

new

Mesh.new(): Mesh

Creates an empty editable Mesh.

prism

Mesh.prism(sides: number?, radius: number?, height: number?): Mesh

Creates a prism with the supplied side count, radius, and height.

pyramid

Mesh.pyramid(sides: number?, radius: number?, height: number?): Mesh

Creates a pyramid with the supplied side count, radius, and height.

wedge

Mesh.wedge(size: Vector3?): Mesh

Creates a wedge mesh with the supplied dimensions.

Properties

CollisionUpdates

Mesh.CollisionUpdates: boolean

Whether mesh edits automatically update collision geometry. Disable during a batch of edits and call UpdateCollision afterward when needed.

FaceCount

Mesh.FaceCount: number

The number of polygon faces in the mesh.

SmoothingAngle

Mesh.SmoothingAngle: number

The angular threshold used when smoothing adjacent faces.

TriangleCount

Mesh.TriangleCount: number

The number of triangles after polygon triangulation.

VertexCount

Mesh.VertexCount: number

The number of vertices in the mesh.

Methods

AddFace

Mesh:AddFace(vertices: {number}): number

Adds a polygon using the supplied vertex identifiers and returns its face identifier.

AddMorphTarget

Mesh:AddMorphTarget(name: string, deltas: { Vector3 } | buffer): ()

Registers named per-vertex position offsets for a morph target.

AddTriangle

Mesh:AddTriangle(first: number, second: number, third: number): number

Adds a triangular face using three vertex identifiers and returns its face identifier.

AddVertex

Mesh:AddVertex(position: Vector3): number

Adds a vertex at a mesh-local position and returns its identifier.

AutoSkin

Mesh:AutoSkin(): ()

Computes skin weights for the mesh's bound bones.

BevelEdges

Mesh:BevelEdges(edges: { { number } }, width: number, segments: number?): ()

Bevels the supplied edges by the given width and segment count.

BindSkin

Mesh:BindSkin(bones: { Attachment | BasePart }): ()

Binds the supplied Attachments or Parts as bones for mesh deformation.

ClearSkin

Mesh:ClearSkin(): ()

Removes skin bindings and weights from the mesh.

Clone

Mesh:Clone(): Mesh

Returns an independent copy of the mesh.

Compact

Mesh:Compact(): ()

Compacts mesh storage after topology edits.

CutFace

Mesh:CutFace(face: number, from: number, to: number): number

Splits the specified face between the supplied vertex identifiers and returns the resulting face identifier.

Edit

Mesh:Edit(edit: (mesh: Mesh) -> ()): ()

Runs the callback with this mesh as a grouped edit operation.

ExtrudeFaces

Mesh:ExtrudeFaces(faces: {number}, distance: number): table

Extrudes selected faces by the supplied distance and returns information about the resulting geometry.

FillHoles

Mesh:FillHoles(): number

Fills open boundaries and returns the number of holes filled.

Flip

Mesh:Flip(): ()

Reverses face winding and surface orientation.

GetEdges

Mesh:GetEdges(): table

Returns the edges of the mesh as vertex-identifier pairs.

GetExtent

Mesh:GetExtent(): Vector3

Returns the dimensions of the mesh's bounds.

GetFaceArea

Mesh:GetFaceArea(face: number): number

Returns the area of the specified face.

GetFaceCenter

Mesh:GetFaceCenter(face: number): Vector3

Returns the center of the specified face in mesh-local coordinates.

GetFaceEdges

Mesh:GetFaceEdges(face: number): table

Returns the edges forming the specified face.

GetFaceNormal

Mesh:GetFaceNormal(face: number): Vector3

Returns the geometric normal of the specified face.

GetFaceNormals

Mesh:GetFaceNormals(face: number): { Vector3 }

Returns the per-corner normals of the specified face.

GetFaceUVs

Mesh:GetFaceUVs(face: number): table

Returns the texture coordinates assigned to the specified face.

GetFaceVertices

Mesh:GetFaceVertices(face: number): table

Returns the vertex identifiers forming the specified face.

GetFaces

Mesh:GetFaces(): table

Returns the face identifiers in the mesh.

GetFacesAlongEdge

Mesh:GetFacesAlongEdge(edge: {number}): table

Returns the faces adjacent to the supplied edge.

GetFacesFacing

Mesh:GetFacesFacing(direction: Vector3, tolerance: number?): table

Returns faces whose normals face the supplied direction within the tolerance.

GetFacesTouching

Mesh:GetFacesTouching(vertex: number): table

Returns the faces containing the specified vertex.

GetMorphTargets

Mesh:GetMorphTargets(): { string }

Returns the names of the registered morph targets.

GetMorphWeight

Mesh:GetMorphWeight(name: string): number

Returns the current weight of the named morph target.

GetPosedVertexPosition

Mesh:GetPosedVertexPosition(vertex: number): Vector3

Returns a vertex position after skin and morph deformation.

GetSharpEdges

Mesh:GetSharpEdges(angle: number?): table

Returns edges whose adjacent faces differ by more than the angle threshold.

GetSkinBones

Mesh:GetSkinBones(): { string }

Returns the names of the bones bound to this mesh.

GetSurfaceArea

Mesh:GetSurfaceArea(): number

Returns the total area of the mesh surface.

GetVertexBuffer

Mesh:GetVertexBuffer(first: number?, count: number?): buffer

Returns a packed position buffer for the requested vertex range.

GetVertexPosition

Mesh:GetVertexPosition(vertex: number): Vector3

Returns the mesh-local position of the specified vertex.

GetVertexPositions

Mesh:GetVertexPositions(first: number?, count: number?): { Vector3 }

Returns mesh-local positions for the requested vertex range.

GetVertexWeights

Mesh:GetVertexWeights(vertex: number): { [string]: number }

Returns bone-name-to-weight entries for the specified vertex.

GetVertices

Mesh:GetVertices(): table

Returns the vertex identifiers in the mesh.

GetVolume

Mesh:GetVolume(): number

Returns the volume computed from the mesh's oriented faces. Open or inconsistently oriented geometry may not describe a closed solid.

InsetFaces

Mesh:InsetFaces(faces: {number}, amount: number): table

Insets the selected faces by the supplied amount and returns the resulting geometry information.

Intersect

Mesh:Intersect(other: Mesh): ()

Replaces this mesh with its solid intersection with another mesh.

IsClosed

Mesh:IsClosed(): boolean

Returns whether the mesh forms a closed surface.

IsFaceSmooth

Mesh:IsFaceSmooth(face: number): boolean

Returns whether the specified face uses smooth shading.

MergeByDistance

Mesh:MergeByDistance(distance: number?): ()

Merges vertices whose positions fall within the supplied distance.

MergeVertices

Mesh:MergeVertices(vertices: {number}): number

Merges the supplied vertex identifiers and returns the retained vertex identifier.

ProjectUVs

Mesh:ProjectUVs(scale: number?): ()

Generates projected texture coordinates using the supplied scale.

RemoveFace

Mesh:RemoveFace(face: number): boolean

Removes a face and returns whether it existed.

RemoveFaces

Mesh:RemoveFaces(faces: {number}): number

Removes the supplied faces and returns the number removed.

RemoveMorphTarget

Mesh:RemoveMorphTarget(name: string): ()

Removes the named morph target.

RemoveVertex

Mesh:RemoveVertex(vertex: number): number

Removes the specified vertex and updates affected topology.

Scale

Mesh:Scale(factor: Vector3): ()

Multiplies mesh-local vertex positions by the supplied per-axis scale.

SetFaceNormals

Mesh:SetFaceNormals(face: number, normals: { Vector3 }?): ()

Sets the per-corner normals for a face. Passing nil clears the override.

SetFaceSmooth

Mesh:SetFaceSmooth(face: number, smooth: boolean): ()

Enables or disables smooth shading for the specified face.

SetFaceUVs

Mesh:SetFaceUVs(face: number, uvs: { Vector2 }): ()

Sets the per-corner texture coordinates for the specified face.

SetFaceVertices

Mesh:SetFaceVertices(face: number, vertices: { number }): ()

Replaces the vertex sequence of the specified face.

SetMorphWeight

Mesh:SetMorphWeight(name: string, weight: number): ()

Sets the blend weight of a named morph target.

SetSkinWeights

Mesh:SetSkinWeights(first: number, weights: { { [string]: number } }): ()

Sets skin weights for a consecutive range of vertices.

SetSmooth

Mesh:SetSmooth(smooth: boolean): ()

Enables or disables smooth shading across all faces.

SetVertexPosition

Mesh:SetVertexPosition(vertex: number, position: Vector3): ()

Sets the mesh-local position of the specified vertex.

SetVertexPositions

Mesh:SetVertexPositions(first: number, positions: { Vector3 } | buffer): ()

Writes consecutive vertex positions from a Vector3 array or packed buffer.

SetVertexWeights

Mesh:SetVertexWeights(vertex: number, weights: { [string]: number }): ()

Sets the bone weights of the specified vertex.

Slice

Mesh:Slice(point: Vector3, normal: Vector3): Mesh

Splits geometry with a plane defined by a point and normal and returns a Mesh.

SplitEdge

Mesh:SplitEdge(edge: {number}, along: number?): number

Splits an edge at the supplied fractional position and returns the new vertex identifier.

Subtract

Mesh:Subtract(other: Mesh): ()

Replaces this mesh with its solid difference from another mesh.

Transform

Mesh:Transform(cframe: CFrame): ()

Applies a CFrame to the mesh-local vertex positions.

Translate

Mesh:Translate(offset: Vector3): ()

Adds an offset to all mesh-local vertex positions.

Triangulate

Mesh:Triangulate(): ()

Converts polygon faces into triangles.

Union

Mesh:Union(other: Mesh): ()

Replaces this mesh with its solid union with another mesh.

UpdateCollision

Mesh:UpdateCollision(): ()

Rebuilds collision geometry after mesh edits.

Operators

__tostring · __type

Used by

BasePart · GeometryPart · IntersectOperation · NegateOperation · Part · Seat · SpawnLocation · UnionOperation · VehicleSeat