---
title: "withPositions(_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/clothmeshresource/withpositions(_:)"
---

# withPositions(_:)

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

## Declaration

```swift
final func withPositions<Result>(_ callback: (Span<SIMD3<Float>>) -> Result) -> Result
```

## Parameters

- `callback`: A closure that receives a span over the vertex positions.

## Return Value

Return Value The value returned by callback.

## Discussion

Discussion The provided span is only valid for the lifetime of the callback. warning: These positions correspond to the mesh used to generate the bodies, rather than the bodies themselves. Therefore, these positions do not change as the body deforms when this resource is used in mesh.

## See Also

### Accessing vertex data

- [vertexCount](realitykit/clothmeshresource/vertexcount.md)
- [positions](realitykit/clothmeshresource/positions.md)
- [position(at:)](realitykit/clothmeshresource/position(at:).md)
- [vertexIndex(at:)](realitykit/clothmeshresource/vertexindex(at:).md)
- [vertexIndex(primitive:vertex:)](realitykit/clothmeshresource/vertexindex(primitive:vertex:).md)
- [vertices(in:center:orientation:)](realitykit/clothmeshresource/vertices(in:center:orientation:).md)
