---
title: "replaceTriangleIndices(_:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowleveldeformation/renormalizing-swift.struct/replacetriangleindices(_:)"
---

# replaceTriangleIndices(_:)

Fills the triangle index buffer using the given closure.

## Declaration

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

## Parameters

- `body`: A closure that receives a mutable span over the buffer.

## Return Value

Return Value The value returned by body.

## Discussion

Discussion After the closure returns, the framework validates every vertex index against the vertex count. An out-of-range index causes a throw. note: If any vertex index is outside [0, vertexCount).

## See Also

### Replacing geometry data

- [replaceAdjacencies(_:)](realitykit/lowleveldeformation/renormalizing-swift.struct/replaceadjacencies(_:).md)
- [replaceAdjacencyEndIndices(_:)](realitykit/lowleveldeformation/renormalizing-swift.struct/replaceadjacencyendindices(_:).md)
