ArrayMesh
Mesh
type that provides utility for constructing a surface from arrays.
class ArrayMesh
The ArrayMesh
is used to construct a Mesh
by specifying the attributes as arrays.
The most basic example is the creation of a single triangle:
The MeshInstance3D
is ready to be added to the SceneTree
to be shown.
See also ImmediateMesh
, MeshDataTool
and SurfaceTool
for procedural geometry generation.
Superclasses
class Mesh
A
Resource
that contains vertex array-based geometry.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var blendShapeMode: Mesh.BlendShapeMode
Sets the blend shape mode to one of
Mesh.BlendShapeMode
.var customAabb: AABB
Overrides the
AABB
with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.var shadowMesh: ArrayMesh?
An optional mesh which is used for rendering shadows and can be used for the depth prepass. Can be used to increase performance of shadow rendering by using a mesh that only contains vertex position data (without normals, UVs, colors, etc.).
func addBlendShape(name: StringName
) Adds name for a blend shape that will be added with
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
. Must be called before surface is added.func addSurfaceFromArrays(primitive: Mesh.PrimitiveType, arrays: GArray, blendShapes: VariantCollection<GArray>, lods: GDictionary, flags: Mesh.ArrayFormat
) Creates a new surface.
getSurfaceCount
will become thesurf_idx
for this new surface.func clearBlendShapes(
) Removes all blend shapes from this
ArrayMesh
.func clearSurfaces(
) Removes all surfaces from this
ArrayMesh
.func getBlendShapeCount(
) -> Int32 Returns the number of blend shapes that the
ArrayMesh
holds.func getBlendShapeName(index: Int32
) -> StringName Returns the name of the blend shape at this index.
func lightmapUnwrap(transform: Transform3D, texelSize: Double
) -> GodotError Performs a UV unwrap on the
ArrayMesh
to prepare the mesh for lightmapping.func regenNormalMaps(
) Regenerates tangents for each of the
ArrayMesh
’s surfaces.func setBlendShapeName(index: Int32, name: StringName
) Sets the name of the blend shape at this index.
func surfaceFindByName(String
) -> Int32 Returns the index of the first surface with this name held within this
ArrayMesh
. If none are found, -1 is returned.func surfaceGetArrayIndexLen(surfIdx: Int32
) -> Int32 Returns the length in indices of the index array in the requested surface (see
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
).func surfaceGetArrayLen(surfIdx: Int32
) -> Int32 Returns the length in vertices of the vertex array in the requested surface (see
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
).func surfaceGetFormat(surfIdx: Int32
) -> Mesh.ArrayFormat Returns the format mask of the requested surface (see
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
).func surfaceGetName(surfIdx: Int32
) -> String Gets the name assigned to this surface.
func surfaceGetPrimitiveType(surfIdx: Int32
) -> Mesh.PrimitiveType Returns the primitive type of the requested surface (see
addSurfaceFromArrays(primitive:arrays:blendShapes:lods:flags:)
).func surfaceSetName(surfIdx: Int32, name: String
) Sets a name for a given surface.
func surfaceUpdateAttributeRegion(surfIdx: Int32, offset: Int32, data: PackedByteArray
) func surfaceUpdateSkinRegion(surfIdx: Int32, offset: Int32, data: PackedByteArray
) func surfaceUpdateVertexRegion(surfIdx: Int32, offset: Int32, data: PackedByteArray
)