Smoother(count)

This class can be used to smooth the result of a vector calculation. One use case is the smoothing of the velocity vector of game entities in order to avoid a shaky movements due to conflicting forces.

new Smoother(count)

Constructs a new smoother.

Parameters:
Name Type Default Description
count Number 10

The amount of samples the smoother will use to average a vector.

Author:

Members

count :Number

The amount of samples the smoother will use to average a vector.

Default Value:
  • 10

Methods

calculate(value, average) → {Vector3}

Calculates for the given value a smooth average.

Parameters:
Name Type Description
value Vector3

The value to smooth.

average Vector3

The calculated average.

Returns:
Vector3 -

The calculated average.

fromJSON(json) → {Smoother}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
Smoother -

A reference to this smoother.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.