Orientation2DTween

View source

ExtendsTween

Tweens an entity’s Orientation2D component in 2D space.

Orientation2DTween is the concrete ECS component for interpolating Orientation2D values between a starting orientation and an ending orientation. Attach it to the same entity as the target component and register a matching TweenPlugin, or use DefaultTweenPlugin for the standard transform integrations. The paired orientation follows the tween’s eased progress between its from and to values.

It inherits timing, easing, repeat, flip, and endpoint state from Tween. Set duration to control how long the transition takes, use easing to shape its progress, and use repeat or flip to control how it behaves across repeated cycles.

Examples

import { World } from '@wimaengine/ecs'
import { Orientation2D } from '@wimaengine/transform'
import { Orientation2DTween } from '@wimaengine/tween'

// Register DefaultTweenPlugin on the app that runs this world.
const world = new World()
world.spawn([
  new Orientation2D(1, 0),
  new Orientation2DTween(
    new Orientation2D(0, 1), // 90 degrees counter-clockwise
    new Orientation2D(1, 0),
    1
  )
])

Constructor


constructor(to: Orientation2D, from: Orientation2D, duration: number, repeat?: boolean, flip?: boolean, easing?: EasingFn)

View source

Creates tween state for an ending value, starting value, and duration.

Values are assigned directly; the constructor does not clone to or from, or validate duration. The optional booleans are stored on the instance; use TweenRepeat and TweenFlip to opt into repeated cycles and endpoint swapping.

Parameters

NameDescriptionDefault
to

Value passed to interpolation at progress 1.

—
from

Value passed to interpolation at progress 0.

—
duration

Total tween duration in seconds.

—
repeat?

Stored repeat option.

false
flip?

Stored flip option.

true
easing?

Function applied to normalized progress.

Easing.linear