# XrPlaneDetection

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

Source: https://github.com/playcanvas/engine/blob/b5b983982a9860d21e0c1dafb2f85f72e2c01afb/src/framework/xr/xr-plane-detection.js#L28

Plane Detection provides the ability to detect real world surfaces based on estimations of the
underlying AR system.

```javascript
// start session with plane detection enabled
app.xr.start(camera, XRTYPE_VR, XRSPACE_LOCALFLOOR, {
    planeDetection: true
});
```

```javascript
app.xr.planeDetection.on('add', (plane) => {
    // new plane been added
});
```

## Accessors

### available

```ts
get available(): boolean
```

True if Plane Detection is available. This information is available only when the session has started.

### planes

```ts
get planes(): XrPlane[]
```

Array of [XrPlane](https://api.playcanvas.com/engine/classes/XrPlane.md) instances that contain individual plane information.

### supported

```ts
get supported(): boolean
```

True if Plane Detection is supported.

## Events

### EVENT_ADD

```ts
static EVENT_ADD: string = 'add'
```

Fired when new [XrPlane](https://api.playcanvas.com/engine/classes/XrPlane.md) is added to the list. The handler is passed the
[XrPlane](https://api.playcanvas.com/engine/classes/XrPlane.md) instance that has been added.

**Example**

```ts
app.xr.planeDetection.on('add', (plane) => {
    // new plane is added
});
```

### EVENT_AVAILABLE

```ts
static EVENT_AVAILABLE: string = 'available'
```

Fired when plane detection becomes available.

**Example**

```ts
app.xr.planeDetection.on('available', () => {
    console.log('Plane detection is available');
});
```

### EVENT_REMOVE

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

Fired when a [XrPlane](https://api.playcanvas.com/engine/classes/XrPlane.md) is removed from the list. The handler is passed the
[XrPlane](https://api.playcanvas.com/engine/classes/XrPlane.md) instance that has been removed.

**Example**

```ts
app.xr.planeDetection.on('remove', (plane) => {
    // new plane is removed
});
```

### EVENT_UNAVAILABLE

```ts
static EVENT_UNAVAILABLE: string = 'unavailable'
```

Fired when plane detection becomes unavailable.

**Example**

```ts
app.xr.planeDetection.on('unavailable', () => {
    console.log('Plane detection is unavailable');
});
```

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