Home > three-story-controls > Damper
Damper uses simple linear damping for a given collection of values. On every call to update, the damper will approach a given set of target values.
Signature:
export declare class Damper
const damper = new Damper({
values: {x: 0, y: 0},
dampingFactor: 0.4
})
damper.setTarget({ x: 1, y: 100 })
damper.update() // would generally be called in an animation loop
const values = damper.getCurrentValues() // values.x = 0.4; values.y = 40
Constructor | Modifiers | Description |
---|---|---|
(constructor)(props) | Constructs a new instance of the Damper class |
Method | Modifiers | Description |
---|---|---|
addToTarget(key, value) | Increment/Decrement a specifc damper target value | |
getCurrentValues() | Get the current values | |
getDeltaValues() | Get the change in values since the last update call | |
reachedTarget() | Whether the damper has reached its target | |
resetAll(value) | Reset all damper values to the fiven number | |
resetData(values) | Reset damper values as described by the given DamperValues object | |
setTarget(target) | Set the target values the damper needs to approach | |
update() | Update the damper, should generally be called on every frame |