# CustomMesh

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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class CustomMesh implements AutoCloseable
```

<br />

*** ** * ** ***

A resource that defines the structure of a renderable mesh.

A `CustomMesh` is composed of a `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer` and a list of `https://developer.android.com/reference/androidx/xr/scenecore/MeshSubset`. Each `MeshSubset` defines a part of the mesh that can be rendered with a single `https://developer.android.com/reference/androidx/xr/scenecore/Material`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh.BuilderFromMeshBuffer` Builder for `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh` using an existing `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer`. |
| `public final class https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh.BuilderFromMeshData` Builder for `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh` providing raw data directly. |

| ### Public methods |
|---|---|
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh#close()()` Closes the given `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh#getBounds()()` Bounding box of the mesh, used for culling. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer` | `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh#getMeshBuffer()()` The `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer` containing the vertex and index data for this mesh. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/MeshSubset>` | `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh#getSubsets()()` The list of `https://developer.android.com/reference/androidx/xr/scenecore/MeshSubset` defining the parts of the mesh. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh#setBounds(androidx.xr.runtime.math.BoundingBox)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox value)` Bounding box of the mesh, used for culling. |

## Public methods

### close

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

```
@MainThread
public void close()
```

Closes the given `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh`.

The `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh` can be explicitly closed at anytime or garbage collected. An exception will be thrown if the `https://developer.android.com/reference/androidx/xr/scenecore/CustomMesh` is used after being closed.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the resource has already been closed. |

### getBounds

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

```
public final @NonNull BoundingBox getBounds()
```

Bounding box of the mesh, used for culling.

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

When the vertex positions are dynamically updated in the underlying `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer`, this culling volume is not automatically recalculated on the CPU to avoid expensive synchronization or active memory copies. Instead, the application can manually set this property to specify the updated bounds.

The setter for this property must be called on the main thread.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the property is set after this mesh has been closed. |

### getMeshBuffer

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

```
public final @NonNull MeshBuffer getMeshBuffer()
```

The `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer` containing the vertex and index data for this mesh.

### getSubsets

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

```
public final @NonNull List<@NonNull MeshSubset> getSubsets()
```

The list of `https://developer.android.com/reference/androidx/xr/scenecore/MeshSubset` defining the parts of the mesh.

### setBounds

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

```
@MainThread
public final void setBounds(@NonNull BoundingBox value)
```

Bounding box of the mesh, used for culling.

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

When the vertex positions are dynamically updated in the underlying `https://developer.android.com/reference/androidx/xr/scenecore/MeshBuffer`, this culling volume is not automatically recalculated on the CPU to avoid expensive synchronization or active memory copies. Instead, the application can manually set this property to specify the updated bounds.

The setter for this property must be called on the main thread.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the property is set after this mesh has been closed. |