generateTweenUpdateSystem

View sourcegenerateTweenUpdateSystem<T>(component: object, tween: typeof Tween, interpolate: TweenLerp<T>): SystemFunc

Creates a system that interpolates a component from a concrete tween.

The returned system queries entities containing both component and the supplied concrete Tween constructor. For each match it computes tween.easing(tween.timeTaken / tween.duration) and calls interpolate with from, to, the eased progress, and the live component as its output value. This helper does not advance time, clamp progress, or handle a zero duration; JavaScript’s division result is passed to the easing function.

Examples

const updateSystem = generateTweenUpdateSystem(
  Position2D,
  Position2DTween,
  (from, to, progress, out) => out.set(from, to, progress)
)

Type Parameters

T

Parameters

NameDescriptionDefault
component

Component constructor to update.

—
tween

Concrete tween constructor to query.

—
interpolate

Function that writes the interpolated value into the component.

—

Returns

World system that updates matched component values.