<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ClothMeshResource/capsule(height:radius:targetEdgeLength:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:22RealityFoundationCloth0C12MeshResourceC7capsule6height6radius16targetEdgeLengthACXDSf_S2ftKFZ"
  },
  "title" : "capsule(height:radius:targetEdgeLength:)"
}
-->

# capsule(height:radius:targetEdgeLength:)

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

```
@MainActor static func capsule(height: Float, radius: Float, targetEdgeLength: Float = defaultTargetEdgeLength) throws -> Self
```

## Return Value

The generated capsule mesh resource.

## Discussion

- height: The height of the cylinder portion of the capsule, in meters.
  The total capsule height is `height + 2 * radius`.
- radius: The radius of the body and the caps of the generated capsule, in meters.
- targetEdgeLength: The targeted average edge length for the generated mesh, in meters.
  The generated mesh will contain edges with a length as close as possible to this.

---

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)