# XrMesh

Class · extends [`EventHandler`](https://api.playcanvas.com/engine/classes/EventHandler.md) · category: XR

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/framework/xr/xr-mesh.js#L15

Detected Mesh instance that provides its transform (position, rotation), triangles (vertices,
indices) and its semantic label. Any of its properties can change during its lifetime.

## Accessors

### indices

```ts
get indices(): Uint32Array<ArrayBufferLike>
```

Array of mesh indices.

### label

```ts
get label(): string
```

Semantic Label of a mesh that is provided by underlying system. Current list includes (but
not limited to): https://github.com/immersive-web/semantic-labels/blob/master/labels.json

### vertices

```ts
get vertices(): Float32Array<ArrayBufferLike>
```

Array of mesh vertices. This array contains 3 components per vertex (`x, y, z`).

## Methods

### getPosition

```ts
getPosition(): Vec3
```

Get the world space position of a mesh.

**Returns** [`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md): The world space position of a mesh.

### getRotation

```ts
getRotation(): Quat
```

Get the world space rotation of a mesh.

**Returns** [`Quat`](https://api.playcanvas.com/engine/classes/Quat.md): The world space rotation of a mesh.

## Events

### EVENT_CHANGE

```ts
static EVENT_CHANGE: string = 'change'
```

Fired when [XrMesh](https://api.playcanvas.com/engine/classes/XrMesh.md) attributes such as vertices, indices and/or label have been
changed. Position and rotation can change at any time without triggering a `change` event.

**Example**

```ts
mesh.on('change', () => {
    // mesh attributes have been changed
});
```

### EVENT_REMOVE

```ts
static EVENT_REMOVE: string = 'remove'
```

Fired when an [XrMesh](https://api.playcanvas.com/engine/classes/XrMesh.md) is removed. Its attributes, such as its vertices and label,
keep their last values.

**Example**

```ts
mesh.once('remove', () => {
    // mesh is no longer available
});
```

## Inherited from [EventHandler](https://api.playcanvas.com/engine/classes/EventHandler.md)

- `fire(name: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): EventHandler`
- `hasEvent(name: string): boolean`
- `off(name?: string, callback?: HandleEventCallback, scope?: any): EventHandler`
- `on(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `once(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
