---
title: "vertexIndex(at:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/clothmeshresource/vertexindex(at:)"
---

# vertexIndex(at:)

Returns the vertex index at the given position in the mesh’s flattened primitive index array.

## Declaration

```swift
final func vertexIndex(at index: UInt32) -> UInt32
```

## Return Value

Return Value The vertex index at the specified position.

## Discussion

Discussion The mesh is formed by triangles with three vertices each. Different triangles can share the same vertex (for example, two adjacent triangles share the two vertices joined by their common edge). For example, if you want to retrieve the index of the second vertex in the eleventh triangle, you would use myMesh.vertexIndex(at: 3 * 10 + 1). This is because each triangle is formed by three vertices, and indices start at zero, so the eleventh triangle starts at index 3 ⨉ 10. You then add one to get the second vertex within that triangle. You can use the returned vertex index to inspect vertex properties. You can retrieve the position, for example, by using position(at:): let vertexIndex = myMesh.vertexIndex(at: 3 * 10 + 1) let vertexPosition = myMesh.position(at: vertexIndex) print("The second vertex of the eleventh triangle is at X=\(vertexPosition.x)") index: Index of the vertex to be retrieved within the list of vertex indices for all the mesh primitives.

## See Also

### Accessing vertex data

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