<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ClothMeshResource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:22RealityFoundationCloth0C12MeshResourceC"
  },
  "title" : "ClothMeshResource"
}
-->

# ClothMeshResource

A mesh resource that defines the topology and shape of a cloth body or a mesh-shaped cloth collider.

```
final class ClothMeshResource
```

## Overview

Use this resource as the mesh for a [`mesh`](/documentation/RealityKit/ClothBodyComponent/mesh) or a [`mesh`](/documentation/RealityKit/ClothMeshShape/mesh).

## Topics

### Creating a cloth mesh

[`convenience init(positions: [SIMD3<Float>], triangleIndices: [UInt32]) throws`](/documentation/RealityKit/ClothMeshResource/init(positions:triangleIndices:))

Creates a cloth mesh resource from the given vertex positions and triangle indices.

[`static func patch(size: SIMD2<Float>, targetEdgeLength: Float) throws -> Self`](/documentation/RealityKit/ClothMeshResource/patch(size:targetEdgeLength:))

Creates a rectangular patch mesh with a topology suitable for cloth simulation.

[`static func box(size: SIMD3<Float>, targetEdgeLength: Float) throws -> Self`](/documentation/RealityKit/ClothMeshResource/box(size:targetEdgeLength:))

Creates a box mesh with a topology suitable for cloth simulation.

[`static func sphere(radius: Float, targetEdgeLength: Float) throws -> Self`](/documentation/RealityKit/ClothMeshResource/sphere(radius:targetEdgeLength:))

Creates a sphere mesh with a topology suitable for cloth simulation.

[`static func capsule(height: Float, radius: Float, targetEdgeLength: Float) throws -> Self`](/documentation/RealityKit/ClothMeshResource/capsule(height:radius:targetEdgeLength:))

Creates a capsule mesh with a topology suitable for cloth simulation.

[`static func cylinder(height: Float, radius: Float, withCaps: Bool, targetEdgeLength: Float) throws -> Self`](/documentation/RealityKit/ClothMeshResource/cylinder(height:radius:withCaps:targetEdgeLength:))

Creates a cylinder mesh with a topology suitable for cloth simulation.

[`static let defaultTargetEdgeLength: Float`](/documentation/RealityKit/ClothMeshResource/defaultTargetEdgeLength)

Default target edge length for mesh generation.

### Accessing vertex data

[`var vertexCount: Int`](/documentation/RealityKit/ClothMeshResource/vertexCount)

The number of vertices in the mesh.

[`func position(at: UInt32) -> SIMD3<Float>`](/documentation/RealityKit/ClothMeshResource/position(at:))

Returns the position of the vertex at the given index.

[`func withPositions<Result>((Span<SIMD3<Float>>) -> Result) -> Result`](/documentation/RealityKit/ClothMeshResource/withPositions(_:))

Provides access to the positions of all the vertices within a callback.

[`func vertexIndex(at: UInt32) -> UInt32`](/documentation/RealityKit/ClothMeshResource/vertexIndex(at:))

Returns the vertex index at the given position in the mesh’s flattened primitive index array.

[`func vertexIndex(primitive: UInt32, vertex: UInt32) -> UInt32`](/documentation/RealityKit/ClothMeshResource/vertexIndex(primitive:vertex:))

Returns the vertex index of the specified vertex within the specified primitive.

[`func vertices(in: ClothVolumeShape, center: SIMD3<Float>, orientation: simd_quatf) -> [UInt32]`](/documentation/RealityKit/ClothMeshResource/vertices(in:center:orientation:))

Returns the indices of the vertices that lie inside the given volume shape.

### Inspecting mesh geometry

[`var isWatertight: Bool`](/documentation/RealityKit/ClothMeshResource/isWatertight)

Indicates whether the mesh is “watertight”.

[`var volume: Float?`](/documentation/RealityKit/ClothMeshResource/volume)

The volume of the mesh, or `nil` if the mesh is not watertight.

### Initializers

[`convenience init(from: MeshResource) throws`](/documentation/RealityKit/ClothMeshResource/init(from:))

Creates a cloth mesh resource from a rendering mesh resource.

### Instance Properties

[`var indexCount: Int`](/documentation/RealityKit/ClothMeshResource/indexCount)

The number of indices in the mesh.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`Resource`](/documentation/RealityKit/Resource)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)