---
title: MDLMesh
framework: modelio
role: symbol
role_heading: Class
path: modelio/mdlmesh
---

# MDLMesh

A container for vertex buffer data to be used in rendering a 3D object.

## Declaration

```swift
class MDLMesh
```

## Overview

Overview A mesh contains one or more MDLSubmesh objects. Each submesh contains index buffer data that describes how the mesh’s vertices should be combined for drawing and references material information describing an intended surface appearance for the submesh. Typically, you obtain meshes by traversing the object hierarchy of a MDLAsset object, but you can also create meshes from your own vertex data or create parametric meshes. The MDLMesh class also supports processing meshes to generate vertex attributes or to bake lighting information.

## Topics

### Creating a Custom Mesh

- [init(vertexBuffer:vertexCount:descriptor:submeshes:)](modelio/mdlmesh/init(vertexbuffer:vertexcount:descriptor:submeshes:).md)
- [init(vertexBuffers:vertexCount:descriptor:submeshes:)](modelio/mdlmesh/init(vertexbuffers:vertexcount:descriptor:submeshes:).md)
- [init(bufferAllocator:)](modelio/mdlmesh/init(bufferallocator:).md)
- [newSubdividedMesh(_:submeshIndex:subdivisionLevels:)](modelio/mdlmesh/newsubdividedmesh(_:submeshindex:subdivisionlevels:).md)
- [init(meshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator:)](modelio/mdlmesh/init(meshbysubdividingmesh:submeshindex:subdivisionlevels:allocator:).md)

### Working with Vertex Data

- [boundingBox](modelio/mdlmesh/boundingbox.md)
- [submeshes](modelio/mdlmesh/submeshes.md)
- [vertexBuffers](modelio/mdlmesh/vertexbuffers.md)
- [vertexCount](modelio/mdlmesh/vertexcount.md)
- [vertexDescriptor](modelio/mdlmesh/vertexdescriptor.md)
- [allocator](modelio/mdlmesh/allocator.md)
- [addAttribute(withName:format:)](modelio/mdlmesh/addattribute(withname:format:).md)
- [addAttribute(withName:format:type:data:stride:)](modelio/mdlmesh/addattribute(withname:format:type:data:stride:).md)
- [addAttribute(withName:format:type:data:stride:time:)](modelio/mdlmesh/addattribute(withname:format:type:data:stride:time:).md)
- [removeAttributeNamed(_:)](modelio/mdlmesh/removeattributenamed(_:).md)
- [replaceAttributeNamed(_:with:)](modelio/mdlmesh/replaceattributenamed(_:with:).md)
- [updateAttributeNamed(_:with:)](modelio/mdlmesh/updateattributenamed(_:with:).md)
- [addUnwrappedTextureCoordinates(forAttributeNamed:)](modelio/mdlmesh/addunwrappedtexturecoordinates(forattributenamed:).md)
- [vertexAttributeData(forAttributeNamed:)](modelio/mdlmesh/vertexattributedata(forattributenamed:).md)
- [vertexAttributeData(forAttributeNamed:as:)](modelio/mdlmesh/vertexattributedata(forattributenamed:as:).md)

### Generating Geometry Data

- [addNormals(withAttributeNamed:creaseThreshold:)](modelio/mdlmesh/addnormals(withattributenamed:creasethreshold:).md)
- [addTangentBasis(forTextureCoordinateAttributeNamed:tangentAttributeNamed:bitangentAttributeNamed:)](modelio/mdlmesh/addtangentbasis(fortexturecoordinateattributenamed:tangentattributenamed:bitangentattributenamed:).md)
- [addTangentBasis(forTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:)](modelio/mdlmesh/addtangentbasis(fortexturecoordinateattributenamed:normalattributenamed:tangentattributenamed:).md)
- [makeVerticesUnique()](modelio/mdlmesh/makeverticesunique().md)

### Generating Ambient Occlusion Data

- [generateAmbientOcclusionTexture(withQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:)](modelio/mdlmesh/generateambientocclusiontexture(withquality:attenuationfactor:objectstoconsider:vertexattributenamed:materialpropertynamed:).md)
- [generateAmbientOcclusionTexture(withSize:raysPerSample:attenuationFactor:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:)](modelio/mdlmesh/generateambientocclusiontexture(withsize:rayspersample:attenuationfactor:objectstoconsider:vertexattributenamed:materialpropertynamed:).md)
- [generateAmbientOcclusionVertexColors(withQuality:attenuationFactor:objectsToConsider:vertexAttributeNamed:)](modelio/mdlmesh/generateambientocclusionvertexcolors(withquality:attenuationfactor:objectstoconsider:vertexattributenamed:).md)
- [generateAmbientOcclusionVertexColors(withRaysPerSample:attenuationFactor:objectsToConsider:vertexAttributeNamed:)](modelio/mdlmesh/generateambientocclusionvertexcolors(withrayspersample:attenuationfactor:objectstoconsider:vertexattributenamed:).md)

### Generating Light Map Data

- [generateLightMapTexture(withQuality:lightsToConsider:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:)](modelio/mdlmesh/generatelightmaptexture(withquality:lightstoconsider:objectstoconsider:vertexattributenamed:materialpropertynamed:).md)
- [generateLightMapTexture(withTextureSize:lightsToConsider:objectsToConsider:vertexAttributeNamed:materialPropertyNamed:)](modelio/mdlmesh/generatelightmaptexture(withtexturesize:lightstoconsider:objectstoconsider:vertexattributenamed:materialpropertynamed:).md)
- [generateLightMapVertexColorsWithLights(toConsider:objectsToConsider:vertexAttributeNamed:)](modelio/mdlmesh/generatelightmapvertexcolorswithlights(toconsider:objectstoconsider:vertexattributenamed:).md)

### Creating Parametric Meshes

- [newBox(withDimensions:segments:geometryType:inwardNormals:allocator:)](modelio/mdlmesh/newbox(withdimensions:segments:geometrytype:inwardnormals:allocator:).md)
- [newEllipsoid(withRadii:radialSegments:verticalSegments:geometryType:inwardNormals:hemisphere:allocator:)](modelio/mdlmesh/newellipsoid(withradii:radialsegments:verticalsegments:geometrytype:inwardnormals:hemisphere:allocator:).md)
- [newCylinder(withHeight:radii:radialSegments:verticalSegments:geometryType:inwardNormals:allocator:)](modelio/mdlmesh/newcylinder(withheight:radii:radialsegments:verticalsegments:geometrytype:inwardnormals:allocator:).md)
- [newEllipticalCone(withHeight:radii:radialSegments:verticalSegments:geometryType:inwardNormals:allocator:)](modelio/mdlmesh/newellipticalcone(withheight:radii:radialsegments:verticalsegments:geometrytype:inwardnormals:allocator:).md)
- [newPlane(withDimensions:segments:geometryType:allocator:)](modelio/mdlmesh/newplane(withdimensions:segments:geometrytype:allocator:).md)
- [newCapsule(withHeight:radii:radialSegments:verticalSegments:hemisphereSegments:geometryType:inwardNormals:allocator:)](modelio/mdlmesh/newcapsule(withheight:radii:radialsegments:verticalsegments:hemispheresegments:geometrytype:inwardnormals:allocator:).md)
- [newIcosahedron(withRadius:inwardNormals:allocator:)](modelio/mdlmesh/newicosahedron(withradius:inwardnormals:allocator:).md)
- [newIcosahedron(withRadius:inwardNormals:geometryType:allocator:)](modelio/mdlmesh/newicosahedron(withradius:inwardnormals:geometrytype:allocator:).md)
- [init(boxWithExtent:segments:inwardNormals:geometryType:allocator:)](modelio/mdlmesh/init(boxwithextent:segments:inwardnormals:geometrytype:allocator:).md)
- [init(sphereWithExtent:segments:inwardNormals:geometryType:allocator:)](modelio/mdlmesh/init(spherewithextent:segments:inwardnormals:geometrytype:allocator:).md)
- [init(cylinderWithExtent:segments:inwardNormals:topCap:bottomCap:geometryType:allocator:)](modelio/mdlmesh/init(cylinderwithextent:segments:inwardnormals:topcap:bottomcap:geometrytype:allocator:).md)
- [init(coneWithExtent:segments:inwardNormals:cap:geometryType:allocator:)](modelio/mdlmesh/init(conewithextent:segments:inwardnormals:cap:geometrytype:allocator:).md)
- [init(planeWithExtent:segments:geometryType:allocator:)](modelio/mdlmesh/init(planewithextent:segments:geometrytype:allocator:).md)
- [init(icosahedronWithExtent:inwardNormals:geometryType:allocator:)](modelio/mdlmesh/init(icosahedronwithextent:inwardnormals:geometrytype:allocator:).md)
- [init(capsuleWithExtent:cylinderSegments:hemisphereSegments:inwardNormals:geometryType:allocator:)](modelio/mdlmesh/init(capsulewithextent:cylindersegments:hemispheresegments:inwardnormals:geometrytype:allocator:).md)
- [init(hemisphereWithExtent:segments:inwardNormals:cap:geometryType:allocator:)](modelio/mdlmesh/init(hemispherewithextent:segments:inwardnormals:cap:geometrytype:allocator:).md)

### Instance Methods

- [addOrthTanBasis(forTextureCoordinateAttributeNamed:normalAttributeNamed:tangentAttributeNamed:)](modelio/mdlmesh/addorthtanbasis(fortexturecoordinateattributenamed:normalattributenamed:tangentattributenamed:).md)
- [flipTextureCoordinates(inAttributeNamed:)](modelio/mdlmesh/fliptexturecoordinates(inattributenamed:).md)
- [makeVerticesUniqueAndReturnError()](modelio/mdlmesh/makeverticesuniqueandreturnerror().md)

## Relationships

### Inherits From

- [MDLObject](modelio/mdlobject.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [MDLNamed](modelio/mdlnamed.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### 3D Asset Basics

- [MDLAsset](modelio/mdlasset.md)
- [MDLObject](modelio/mdlobject.md)
- [MDLTransform](modelio/mdltransform.md)
- [MDLSubmesh](modelio/mdlsubmesh.md)
- [MDLSubmeshTopology](modelio/mdlsubmeshtopology.md)
- [MDLNamed](modelio/mdlnamed.md)
