Class: Lerp

Lerp(value, cycles, rate) → {Lerp}

Encapsulates the linear interpolation functionality

Found in Chapter 7, page 347 of the textbook

Example: 7.2 Camera Interpolations

Constructor

new Lerp(value, cycles, rate) → {Lerp}

Parameters:
Name Type Description
value float starting value of interpolation
cycles integer number of cycles it should take to reach the target value
rate float rate at which the value should change at each cycle
Source:
Returns:
a new Lerp instance
Type
Lerp

Methods

_interpolateValue()

Calculates the next value using the current value, rate, and diffence between current and target. Internally called by update
Source:

config(stiffness, duration)

Sets the rate and number of cyles of this Lerp
Parameters:
Name Type Description
stiffness float the new rate for this Lerp
duration integer the new number of cycles for this Lerp
Source:

get() → {float}

Returns the current value of this Lerp
Source:
Returns:
mCurrentValue - the current value of this Lerp
Type
float

setFinal(v)

Sets the final value for this Lerp and starts interpolation
Parameters:
Name Type Description
v float the target value to be set
Source:

update() → {void}

Method called by Gameloop, interpolates value if there are remaining cycles
Source:
Returns:
Type
void