MCPcopy Create free account
hub / github.com/melonjs/melonJS / damp

Method damp

packages/melonjs/src/math/vector3d.ts:404–409  ·  view source on GitHub ↗

* Frame-rate independent exponential damping toward `target`. * Wrapper around damp applied per component. * @param target - vector to approach (Vector2d treats `z` as 0) * @param lambda - decay rate in `1/seconds` (higher = snappier) * @param dt - delta time in **seconds** * @retu

(target: Vector2d | Vector3d, lambda: number, dt: number)

Source from the content-addressed store, hash-verified

402 * camera.pos.damp(target.pos, 5, dt / 1000);
403 */
404 damp(target: Vector2d | Vector3d, lambda: number, dt: number) {
405 this.x = damp(this.x, target.x, lambda, dt);
406 this.y = damp(this.y, target.y, lambda, dt);
407 this.z = damp(this.z, "z" in target ? target.z : 0, lambda, dt);
408 return this;
409 }
410
411 /**
412 * interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.

Callers 8

simFunction · 0.95
updateTargetMethod · 0.45
vector2d.spec.tsFile · 0.45
math.spec.jsFile · 0.45
simFunction · 0.45
vector3d.spec.tsFile · 0.45
tickPlayerInputMethod · 0.45

Calls 1

dampFunction · 0.90

Tested by 2

simFunction · 0.76
simFunction · 0.36