Class
Orientation2DAnimationEffector
View sourceExtendsAnimationEffector
Converts one interpolated angle into an entity’s
Orientation2D component value.
Pass this class itself to AnimationTrack. Each keyframe contains a
single angle in radians. Orientation2DAnimationEffector.apply looks
up the component in the target World using its EntityHandle,
converts the angle with Rotary.fromAngle, and copies the resulting
cosine/sine pair into the component. The entity must already have the
component when the animation runs.
Examples
import { World } from '@wimaengine/ecs'
import { AnimationTrack, Orientation2DAnimationEffector } from '@wimaengine/animation'
import { Orientation2D } from '@wimaengine/transform'
const world = new World()
const entity = world.spawn([new Orientation2D()])
const track = new AnimationTrack(Orientation2DAnimationEffector)
track.times = [0, 1]
track.keyframes = [0, Math.PI]
Orientation2DAnimationEffector.apply(world, entity, track.getCurrent(0.5))
// The entity is now rotated by a quarter turn (PI / 2 radians).Constructor
Properties
staticcomponentType: typeof Orientation2D
View sourceComponent constructor read by
Orientation2DAnimationEffector.apply. The method accesses this
through this.componentType, so a compatible subclass can replace the
constructor it looks up.
Default: Orientation2D
Methods
staticapply(world: World, entity: EntityHandle, results: number[]): void
View sourceConverts the current angle and writes it to the target orientation.
The method reads this.componentType from world for entity, creates a
Rotary with Rotary.fromAngle(results[0]), and copies
that value into the returned component. The angle is interpreted in
radians. It does not add a missing component or check the lookup result; a
stale handle, an unknown entity, or an entity without the component
therefore causes the subsequent copy() call to fail.
staticelementSize(): number
View sourceReturns the number of values consumed from each keyframe.
AnimationTrack therefore stores and interpolates one angle per
timestamp for this effector.
