<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LowLevelDeformation/Renormalization-swift.struct/replaceTriangleIndices(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:22RealityCoreDeformation08LowLevelC0C15RenormalizationV22replaceTriangleIndicesyxxs14MutableRawSpanVzXEKRi_zlF"
  },
  "title" : "replaceTriangleIndices(_:)"
}
-->

# replaceTriangleIndices(_:)

Fills the triangle index buffer using the given closure.

```
func replaceTriangleIndices<R>(_ body: @_lifetime(0: copy 0) (inout MutableRawSpan) -> R) throws -> R where R : ~Copyable
```

## Parameters

`body`

A closure that receives a mutable span over the buffer.

## Return Value

The value returned by `body`.

## Discussion

After the closure returns, the framework validates every vertex index against
the vertex count. An out-of-range index causes a throw.

> Throws: If any vertex index is outside `[0, vertexCount)`.

---

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)