<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/MeshBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation10MeshBufferV"
  },
  "title" : "MeshBuffer"
}
-->

# MeshBuffer

Mesh buffer containing elements of any type.

```
struct MeshBuffer<Element>
```

## Topics

### Creating a mesh buffer

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-13uzl)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-1f0ai)

Create buffer from an array of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-1hyiz)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-2okpc)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-3bqai)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-3pbx9)

Create a buffer from any sequence of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-4ahf1)

Create a buffer from any sequence of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-5a11h)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-5sh0b)

Create buffer from an array of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-650mf)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-6hldv)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-77mou)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-7d6t8)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-8m4zg)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-8p5ux)

Create a buffer from any sequence of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-8yhn7)

Create a buffer from any sequence of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-94e5y)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-991gl)

Create buffer from an array of elements.

[`init<S>(S)`](/documentation/RealityKit/MeshBuffer/init(_:)-9eppl)

Create a buffer from any sequence of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-9o6sp)

Create buffer from an array of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-9tja8)

Create buffer from an array of elements.

[`init([Element])`](/documentation/RealityKit/MeshBuffer/init(_:)-11fcy)

Create buffer from an array of elements.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-2f47d)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-2nr7l)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-2wcfg)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-3m3mo)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-4kg29)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-4yxh4)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-5mhon)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-76tes)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-7gw7i)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-8dbzg)

Create buffer from an array of element values and an array of indices into that value array.

[`init(elements: [Element], indices: [UInt32])`](/documentation/RealityKit/MeshBuffer/init(elements:indices:)-97yff)

Create buffer from an array of element values and an array of indices into that value array.

### Inspecting a mesh

[`var elements: [Element]`](/documentation/RealityKit/MeshBuffer/elements)

Access the buffer as an array. This may create a copy if the data are not already an array.

[`var rate: MeshBuffers.Rate`](/documentation/RealityKit/MeshBuffer/rate)

Rate of the buffer.

### Iterating the elements of a buffer

[`func forEach((Element, Element) throws -> Void) rethrows`](/documentation/RealityKit/MeshBuffer/forEach(_:)-53vhs)

Iterate over pairs of elements.

[`func forEach((Element, Element, Element) throws -> Void) rethrows`](/documentation/RealityKit/MeshBuffer/forEach(_:)-7o3tb)

Iterate over three elements per step.

[`func forEach((Element, Element, Element, Element) throws -> Void) rethrows`](/documentation/RealityKit/MeshBuffer/forEach(_:)-xhri)

Iterate over four elements per step.

[`func usingRate(MeshBuffers.Rate) -> MeshBuffer<Element>`](/documentation/RealityKit/MeshBuffer/usingRate(_:))

New object with updated rate.

### Initializers

[`init(_:)`](/documentation/RealityKit/MeshBuffer/init(_:))

Create buffer from an array of elements.

[`init(elements:indices:)`](/documentation/RealityKit/MeshBuffer/init(elements:indices:))

Create buffer from an array of element values and an array of indices into that value array.

### Instance Properties

[`let count: Int`](/documentation/RealityKit/MeshBuffer/count)

The number of elements in the buffer.

### Instance Methods

[`func forEach(_:)`](/documentation/RealityKit/MeshBuffer/forEach(_:))

Iterate over pairs of elements.

## Relationships

### Conforms To

[`Sequence`](/documentation/Swift/Sequence)

---

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)