<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LowLevelMeshResource/replaceVertices(at:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:19RealityCoreRenderer20LowLevelMeshResourceC15replaceVertices2at_xSi_xs14MutableRawSpanVzq_YKXEtq_YKs5ErrorR_Ri_zr0_lF"
  },
  "title" : "replaceVertices(at:_:)"
}
-->

# replaceVertices(at:_:)

Replaces the entire contents of a vertex buffer synchronously on the CPU.

```
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 and fully populates it.

## Discussion

You pass a closure that receives a mutable span representing the contents of the vertex buffer.
Upon entry the buffer’s contents are undefined; the closure is responsible for
populating it with valid data. This span is valid only for the duration of the closure.

> Throws: Any error thrown by `body`.

---

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)