# InputDelta

Class · category: Input

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/extras/input/input.js#L15

Represents an input delta: a fixed-length array of numbers that accumulates input between reads.
Sources [append](https://api.playcanvas.com/engine/classes/InputDelta.md#append) raw values to it as events arrive, and [read](https://api.playcanvas.com/engine/classes/InputDelta.md#read) returns the total and
resets it to zero, so each read yields the change since the previous one. An [InputFrame](https://api.playcanvas.com/engine/classes/InputFrame.md)
groups named deltas together.

## Constructors

### constructor

```ts
new InputDelta(arg: number | number[])
```

**Parameters**

- `arg` (`number | number[]`): The size of the delta or an array of initial values.

## Methods

### add

```ts
add(other: InputDelta): InputDelta
```

Adds another InputDelta instance to this one.

**Parameters**

- `other` ([`InputDelta`](https://api.playcanvas.com/engine/classes/InputDelta.md)): The other InputDelta instance to add.

**Returns** [`InputDelta`](https://api.playcanvas.com/engine/classes/InputDelta.md): Self for chaining.

### append

```ts
append(offsets: number[]): InputDelta
```

Appends offsets to the current delta values.

**Parameters**

- `offsets` (`number[]`): The offsets.

**Returns** [`InputDelta`](https://api.playcanvas.com/engine/classes/InputDelta.md): Self for chaining.

### copy

```ts
copy(other: InputDelta): InputDelta
```

Copies the values from another InputDelta instance to this one.

**Parameters**

- `other` ([`InputDelta`](https://api.playcanvas.com/engine/classes/InputDelta.md)): The other InputDelta instance to copy from.

**Returns** [`InputDelta`](https://api.playcanvas.com/engine/classes/InputDelta.md): Self for chaining.

### length

```ts
length(): number
```

The magnitude of the delta, calculated as the square root of the sum of squares
of the values.

**Returns** `number`: - The magnitude of the delta.

### read

```ts
read(): number[]
```

Returns the current value of the delta and resets it to zero.

**Returns** `number[]`: - The current value of the delta.
