---
title: "replaceVertices(at:_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelmeshresource/replacevertices(at:_:)"
---

# replaceVertices(at:_:)

Replaces a vertex buffer synchronously on the CPU. The buffer’s contents are unspecified; you must populate the buffer with valid data.

## Declaration

```swift
final func replaceVertices<R, E>(at index: Int, _ body: @_lifetime(0: copy 0) (inout MutableRawSpan) throws(E) -> R) throws(E) -> R where E : Error, R : ~Copyable
```

## Parameters

- `index`: The vertex buffer index to replace.
- `body`: A closure that receives a mutable span over the buffer’s bytes to fully populate.

## Discussion

Discussion note: Any error thrown by body.

## See Also

### Accessing vertex data

- [readVertices(at:_:)](realitykit/lowlevelmeshresource/readvertices(at:_:).md)
- [updateVertices(at:_:)](realitykit/lowlevelmeshresource/updatevertices(at:_:).md)
- [readVertices(at:commandBuffer:)](realitykit/lowlevelmeshresource/readvertices(at:commandbuffer:).md)
- [replaceVertices(at:commandBuffer:)](realitykit/lowlevelmeshresource/replacevertices(at:commandbuffer:).md)
