---
title: "capsule(height:radius:targetEdgeLength:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/clothmeshresource/capsule(height:radius:targetedgelength:)"
---

# capsule(height:radius:targetEdgeLength:)

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

## Declaration

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

## Return Value

Return Value The generated capsule mesh resource.

## Discussion

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.

## See Also

### Creating a cloth mesh

- [init(positions:triangleIndices:)](realitykit/clothmeshresource/init(positions:triangleindices:).md)
- [patch(size:targetEdgeLength:)](realitykit/clothmeshresource/patch(size:targetedgelength:).md)
- [box(size:targetEdgeLength:)](realitykit/clothmeshresource/box(size:targetedgelength:).md)
- [sphere(radius:targetEdgeLength:)](realitykit/clothmeshresource/sphere(radius:targetedgelength:).md)
- [cylinder(height:radius:withCaps:targetEdgeLength:)](realitykit/clothmeshresource/cylinder(height:radius:withcaps:targetedgelength:).md)
- [defaultTargetEdgeLength](realitykit/clothmeshresource/defaulttargetedgelength.md)
