<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ClothMeshResource/vertexIndex(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:22RealityFoundationCloth0C12MeshResourceC11vertexIndex2ats6UInt32VAG_tF"
  },
  "title" : "vertexIndex(at:)"
}
-->

# vertexIndex(at:)

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

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

## Return Value

The vertex index at the specified position.

## 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:)`](/documentation/RealityKit/ClothMeshResource/position(at:)):

```swift
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.

---

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)