# XrTrackedImage

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-tracked-image.js#L12

The tracked image interface that is created by the Image Tracking system and is provided as a
list from [XrImageTracking#images](https://api.playcanvas.com/engine/classes/XrImageTracking.md#images). It contains information about the tracking state as
well as the position and rotation of the tracked image.

## Accessors

### emulated

```ts
get emulated(): boolean
```

True if image was recently tracked but currently is not actively tracked due to inability of
identifying the image by the underlying AR system. Position and rotation will be based on
the previously known transformation assuming the tracked image has not moved.

### image

```ts
get image(): Blob | ImageBitmap | HTMLCanvasElement | HTMLImageElement | SVGImageElement | HTMLVideoElement | ImageData
```

Image that is used for tracking.

### trackable

```ts
get trackable(): boolean
```

True if image is trackable. A too small resolution or invalid images can be untrackable by
the underlying AR system.

### tracking

```ts
get tracking(): boolean
```

True if image is in tracking state and being tracked in real world by the underlying AR
system.

### width

```ts
get width(): number
set width(value: number)
```

Get the width (in meters) of image in real world.

## Methods

### getPosition

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

Get the world position of the tracked image.

**Returns** [`Vec3`](https://api.playcanvas.com/engine/classes/Vec3.md): Position in world space.

**Example**

```ts
// update entity position to match tracked image position
entity.setPosition(trackedImage.getPosition());
```

### getRotation

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

Get the world rotation of the tracked image.

**Returns** [`Quat`](https://api.playcanvas.com/engine/classes/Quat.md): Rotation in world space.

**Example**

```ts
// update entity rotation to match tracked image rotation
entity.setRotation(trackedImage.getRotation());
```

## Events

### EVENT_TRACKED

```ts
static EVENT_TRACKED: string = 'tracked'
```

Fired when image becomes actively tracked.

**Example**

```ts
trackedImage.on('tracked', () => {
    console.log('Image is now tracked');
});
```

### EVENT_UNTRACKED

```ts
static EVENT_UNTRACKED: string = 'untracked'
```

Fired when image is no longer actively tracked.

**Example**

```ts
trackedImage.on('untracked', () => {
    console.log('Image is no longer tracked');
});
```

## 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`
