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

Method damp

packages/melonjs/src/math/observableVector3d.ts:488–499  ·  view source on GitHub ↗

* Frame-rate independent exponential damping toward `target`. * Per-component wrapper around damp that triggers the * change-callback exactly once via the underlying set. * @param target - vector to approach (Vector2d treats `z` as 0) * @param lambda - decay rate in `1/second

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

Source from the content-addressed store, hash-verified

486 * @returns Reference to this object for method chaining
487 */
488 damp(
489 target: Vector2d | Vector3d | ObservableVector3d,
490 lambda: number,
491 dt: number,
492 ) {
493 this.set(
494 damp(this.x, target.x, lambda, dt),
495 damp(this.y, target.y, lambda, dt),
496 damp(this.z, "z" in target ? target.z : 0, lambda, dt),
497 );
498 return this;
499 }
500
501 /**
502 * interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.

Callers 1

simFunction · 0.95

Calls 2

setMethod · 0.95
dampFunction · 0.90

Tested by 1

simFunction · 0.76