Position3DTween

View source

ExtendsTween

Pairs with an entity’s Position3D component to animate its 3D position over time.

Attach Position3DTween to the same entity as Position3D and configure the app’s tween support. It inherits timing, easing, repeat, and flip behavior from Tween, using its from and to values to move the paired position between its start and end values.

Set duration to control how long the transition takes. Use repeat to replay it and flip to alternate the direction between cycles.

Examples

import { World } from '@wimaengine/ecs'
import { Position3D } from '@wimaengine/transform'
import { Position3DTween } from '@wimaengine/tween'

// Register DefaultTweenPlugin on the app that runs this world.
const world = new World()
world.spawn([
  new Position3D(0, 0, 0),
  new Position3DTween(
    new Position3D(100, 50, 25),
    new Position3D(0, 0, 0),
    2
  )
])

Constructor


constructor(to: Position3D, from: Position3D, 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