# CustomMesh.BuilderFromMeshData

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/CustomMesh.kt+class:androidx.xr.scenecore.CustomMesh.BuilderFromMeshData) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
class CustomMesh.BuilderFromMeshData
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` providing raw data directly.

This builder implicitly creates an underlying `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer` for you. It supports creating either a static (immutable) mesh or a dynamic mesh with fixed GPU capacities that can be updated at runtime.

### Static Mesh

To create an immutable mesh, provide the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` and `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/VertexLayout`, along with required initial vertex and index data:


    val builder = CustomMesh.BuilderFromMeshData(session, myLayout)
         .addVertexData(myVertexData)
         .setIndexData(myIndexData)

### Dynamic Mesh

To create a dynamic mesh supporting runtime updates, specify the maximum vertex and index capacities:


    val builder = CustomMesh.BuilderFromMeshData(
         session,
         myLayout,
         maxVertices = 100,
         maxIndices = 300,
    )

For dynamic meshes, initial vertex and index data are optional. Passing `null` or omitting initial data allocates zero-initialized GPU buffers up to the specified capacities. Vertex and index data can later be updated at runtime using `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer#updateVertexData(kotlin.Int,androidx.xr.scenecore.ByteBufferRegion,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer#updateIndexData(androidx.xr.scenecore.ByteBufferRegion,kotlin.Int)` accessed via `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh#meshBuffer()`.

### Topology and Subsets

From here, you have two options for defining the mesh topology:

- You can explicitly add one or more subsets:


    builder.addSubset(MeshSubset(MeshSubsetTopology.TRIANGLES, 0, subset1Count))
    builder.addSubset(MeshSubset(MeshSubsetTopology.TRIANGLES, subset1Count, subset2Count))

- Or, if the entire mesh uses the same topology, you can define a single subset that spans all the provided index data (or maximum capacity for dynamic meshes):


    builder.setTopology(MeshSubsetTopology.TRIANGLES)

### Bounds and Building

For dynamic meshes, it is strongly recommended to set an explicit bounding box using `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setBounds(androidx.xr.runtime.math.BoundingBox)` that encompasses all possible deformed positions across the mesh's lifetime, as automatic bounds computation only considers initial vertex data.

Finally, build the mesh:


    val mesh = builder.build()

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#BuilderFromMeshData(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout)(session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, vertexLayout: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/VertexLayout)` Creates a builder for an immutable, static `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh`. |
| `@https://developer.android.com/reference/kotlin/androidx/xr/runtime/RequiresSpatialApi(value = 4) https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#BuilderFromMeshData(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout,kotlin.Int,kotlin.Int)( session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, vertexLayout: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/VertexLayout, maxVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxIndices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a builder for a dynamic `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` with fixed GPU buffer capacities. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addSubset(androidx.xr.scenecore.MeshSubset)(subset: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubset)` Adds a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubset` defining a part of the mesh. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addSubset(androidx.xr.scenecore.MeshSubsetTopology,kotlin.Int,kotlin.Int)( topology: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubsetTopology, indexOffset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, indexCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Adds a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubset` defining a part of the mesh using the specified topology, index offset, and index count. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addVertexData(androidx.xr.scenecore.ByteBufferRegion)(vertexData: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ByteBufferRegion?)` Adds vertex data for a single buffer. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addVertexData(java.nio.ByteBuffer,kotlin.Int,kotlin.Int)( buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html, offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, size: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Adds vertex data for a single buffer using the provided `https://developer.android.com/reference/java/nio/ByteBuffer.html`, `offset`, and `size`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()()` Builds a new `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setBounds(androidx.xr.runtime.math.BoundingBox)(bounds: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox)` Sets an optional user-supplied bounding box for culling. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setIndexData(androidx.xr.scenecore.ByteBufferRegion)(indexData: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ByteBufferRegion?)` Sets the index data. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setIndexData(java.nio.ByteBuffer,kotlin.Int,kotlin.Int)( buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html, offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, size: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the index data using the provided `https://developer.android.com/reference/java/nio/ByteBuffer.html`, `offset`, and `size`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setTopology(androidx.xr.scenecore.MeshSubsetTopology)(topology: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubsetTopology)` Sets the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubsetTopology` to use for the entire mesh, defining a single subset that spans all provided index data. |

## Public constructors

### BuilderFromMeshData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
BuilderFromMeshData(session: Session, vertexLayout: VertexLayout)
```

Creates a builder for an immutable, static `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh`.

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` |
| `vertexLayout: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/VertexLayout` | vertex layout describing the format of vertex attributes |

### BuilderFromMeshData

Added in [1.1.0-alpha01](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.1.0-alpha01)

```
@RequiresSpatialApi(value = 4)
BuilderFromMeshData(
    session: Session,
    vertexLayout: VertexLayout,
    maxVertices: @IntRange(from = 1) Int,
    maxIndices: @IntRange(from = 1) Int
)
```

Creates a builder for a dynamic `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` with fixed GPU buffer capacities.

The `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout,kotlin.Int,kotlin.Int)` parameters define the fixed maximum capacity of the underlying GPU buffers. The allocated buffer cannot be resized after creation. Any runtime updates via `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer#updateVertexData(kotlin.Int,androidx.xr.scenecore.ByteBufferRegion,kotlin.Int)` or `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer#updateIndexData(androidx.xr.scenecore.ByteBufferRegion,kotlin.Int)` that exceed these capacities will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`.

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` |
| `vertexLayout: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/VertexLayout` | vertex layout describing the format of vertex attributes |
| `maxVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | fixed maximum number of vertices this mesh buffer can hold |
| `maxIndices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | fixed maximum number of indices this mesh buffer can hold |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout,kotlin.Int,kotlin.Int)` or `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#(androidx.xr.runtime.Session,androidx.xr.scenecore.VertexLayout,kotlin.Int,kotlin.Int)` is not positive |

## Public functions

### addSubset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun addSubset(subset: MeshSubset): CustomMesh.BuilderFromMeshData
```

Adds a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubset` defining a part of the mesh.

This cannot be used in combination with `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setTopology(androidx.xr.scenecore.MeshSubsetTopology)`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a topology has already been set |

### addSubset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun addSubset(
    topology: MeshSubsetTopology,
    indexOffset: @IntRange(from = 0) Int,
    indexCount: @IntRange(from = 0) Int
): CustomMesh.BuilderFromMeshData
```

Adds a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubset` defining a part of the mesh using the specified topology, index offset, and index count.

This cannot be used in combination with `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setTopology(androidx.xr.scenecore.MeshSubsetTopology)`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a topology has already been set |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addSubset(androidx.xr.scenecore.MeshSubsetTopology,kotlin.Int,kotlin.Int)` or `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addSubset(androidx.xr.scenecore.MeshSubsetTopology,kotlin.Int,kotlin.Int)` is negative |

### addVertexData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun addVertexData(vertexData: ByteBufferRegion?): CustomMesh.BuilderFromMeshData
```

Adds vertex data for a single buffer.

The order in which this method is called determines the buffer index. The first call provides data for buffer index 0, the second for buffer index 1, etc. The data is copied during `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()`, so the original `https://developer.android.com/reference/java/nio/ByteBuffer.html` can be modified or released after `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()` without affecting the underlying `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer`.

When creating a dynamic mesh, initial vertex data is optional. Passing `null` allows skipping initial data for a specific buffer index in a multi-buffer layout while leaving that buffer zero-initialized. When creating a static mesh, passing `null` will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`.

| Parameters |
|---|---|
| `vertexData: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ByteBufferRegion?` | initial vertex data for this buffer, or null if this buffer is dynamic and should be allocated without initial data |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | this builder instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addVertexData(androidx.xr.scenecore.ByteBufferRegion)` is null when creating a static mesh |

### addVertexData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun addVertexData(
    buffer: ByteBuffer,
    offset: @IntRange(from = 0) Int = 0,
    size: @IntRange(from = 1) Int = buffer.capacity() - offset
): CustomMesh.BuilderFromMeshData
```

Adds vertex data for a single buffer using the provided `https://developer.android.com/reference/java/nio/ByteBuffer.html`, `offset`, and `size`.

The order in which this method is called determines the buffer index. The first call provides data for buffer index 0, the second for buffer index 1, etc. The data is copied during `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()`, so the original `https://developer.android.com/reference/java/nio/ByteBuffer.html` can be modified or released after `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()` without affecting the underlying `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer`.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html` | containing the data |
| `offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | absolute starting position within the buffer (ignoring its current position) in bytes (defaults to 0) |
| `size: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = buffer.capacity() - offset` | number of bytes in the region (defaults to the remaining capacity of the buffer after the given offset) |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `offset` is negative, if `size` is zero or negative, if `offset` exceeds `buffer.capacity()`, or if `offset + size` exceeds `buffer.capacity()`. |

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
fun build(): CustomMesh
```

Builds a new `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` | a new `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if index data or vertex data are missing when constructing a static mesh, or if initial dynamic data exceeds allocated capacities |

### setBounds

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun setBounds(bounds: BoundingBox): CustomMesh.BuilderFromMeshData
```

Sets an optional user-supplied bounding box for culling.

The bounding box does not need to be perfectly tight, but tighter bounds will result in more efficient culling. It is an axis-aligned bounding box in the mesh's local coordinate space.

If not provided, an auto-computed bounding box for the supplied vertex and index data will be used.

### setIndexData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun setIndexData(indexData: ByteBufferRegion?): CustomMesh.BuilderFromMeshData
```

Sets the index data.

The data is copied during `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()`, so the original `https://developer.android.com/reference/java/nio/ByteBuffer.html` can be modified or released after `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()` without affecting the underlying `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer`.

When creating a dynamic mesh, initial index data is optional. Passing `null` (or omitting this call entirely) allocates the index buffer with zero-initialized content. When creating a static mesh, passing `null` will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`.

| Parameters |
|---|---|
| `indexData: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ByteBufferRegion?` | initial 32-bit index data, or null if the index buffer is dynamic and should be allocated without initial data |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` | this builder instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#setIndexData(androidx.xr.scenecore.ByteBufferRegion)` is null when creating a static mesh |

### setIndexData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun setIndexData(
    buffer: ByteBuffer,
    offset: @IntRange(from = 0) Int = 0,
    size: @IntRange(from = 1) Int = buffer.capacity() - offset
): CustomMesh.BuilderFromMeshData
```

Sets the index data using the provided `https://developer.android.com/reference/java/nio/ByteBuffer.html`, `offset`, and `size`.

The data is copied during `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()`, so the original `https://developer.android.com/reference/java/nio/ByteBuffer.html` can be modified or released after `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#build()` without affecting the underlying `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshBuffer`.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html` | containing the data |
| `offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | absolute starting position within the buffer (ignoring its current position) in bytes (defaults to 0) |
| `size: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = buffer.capacity() - offset` | number of bytes in the region (defaults to the remaining capacity of the buffer after the given offset) |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `offset` is negative, if `size` is zero or negative, if `offset` exceeds `buffer.capacity()`, or if `offset + size` exceeds `buffer.capacity()`. |

### setTopology

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
fun setTopology(topology: MeshSubsetTopology): CustomMesh.BuilderFromMeshData
```

Sets the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/MeshSubsetTopology` to use for the entire mesh, defining a single subset that spans all provided index data.

This cannot be used in combination with `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData#addSubset(androidx.xr.scenecore.MeshSubset)`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if subsets have already been added |