---
title: "patch(size:targetEdgeLength:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/clothmeshresource/patch(size:targetedgelength:)"
---

# patch(size:targetEdgeLength:)

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

## Declaration

```swift
@MainActor static func patch(size: SIMD2<Float>, targetEdgeLength: Float = defaultTargetEdgeLength) throws -> Self
```

## Return Value

Return Value The generated patch mesh resource.

## Discussion

Discussion The generated patch will be a rectangular mesh in the XZ plane, with the face normals pointing towards +Y. The patch is centered at the origin. size: The dimensions (width, height) of the generated patch, in meters. The resulting patch will extend from -dimensions/2 until +dimensions/2. 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)
- [box(size:targetEdgeLength:)](realitykit/clothmeshresource/box(size:targetedgelength:).md)
- [sphere(radius:targetEdgeLength:)](realitykit/clothmeshresource/sphere(radius:targetedgelength:).md)
- [capsule(height:radius:targetEdgeLength:)](realitykit/clothmeshresource/capsule(height:radius:targetedgelength:).md)
- [cylinder(height:radius:withCaps:targetEdgeLength:)](realitykit/clothmeshresource/cylinder(height:radius:withcaps:targetedgelength:).md)
- [defaultTargetEdgeLength](realitykit/clothmeshresource/defaulttargetedgelength.md)
