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

Method damp

packages/melonjs/src/math/vector2d.ts:354–358  ·  view source on GitHub ↗

* Frame-rate independent exponential damping toward `target`. * Wrapper around damp applied per component. * @param target - vector to approach * @param lambda - decay rate in `1/seconds` (higher = snappier) * @param dt - delta time in **seconds** * @returns Reference to this objec

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

Source from the content-addressed store, hash-verified

352 * this.pos.damp(target.pos, 5, dt / 1000);
353 */
354 damp(target: Vector2d, lambda: number, dt: number) {
355 this.x = damp(this.x, target.x, lambda, dt);
356 this.y = damp(this.y, target.y, lambda, dt);
357 return this;
358 }
359
360 /**
361 * interpolate the position of this vector towards the given one by the given maximum step.

Callers 1

simFunction · 0.95

Calls 1

dampFunction · 0.90

Tested by 1

simFunction · 0.76