Class
AnimationEffector
View sourceDefines the base contract for effectors that apply interpolated animation values to entity components.
Concrete effectors specify the number of values in each keyframe and how
those values are applied to their target component. Use a concrete effector
with an AnimationTrack.
Examples
import { World } from '@wimaengine/ecs'
import { AnimationEffector, AnimationTrack } from '@wimaengine/animation'
class Opacity {
value = 1
}
class OpacityAnimationEffector extends AnimationEffector {
static apply(world, entity, results) {
world.get(entity, Opacity).value = results[0]
}
static elementSize() {
return 1
}
}
const track = new AnimationTrack(OpacityAnimationEffector)
track.times = [0, 1]
track.keyframes = [0, 1]
const world = new World()
const entity = world.spawn([new Opacity()])
OpacityAnimationEffector.apply(world, entity, track.getCurrent(0.5))Constructor
Methods
staticapply(_world: World, _entity: EntityHandle, _results: number[]): void
View sourceApplies interpolated values to an animation target.
The base implementation intentionally ignores every argument. A concrete
effector should use world and entity to find the target component and
write the values in results to it.
staticelementSize(): number
View sourceReturns the number of numeric values in each keyframe.
The base implementation returns 0. Concrete effectors must override it
with the width expected by AnimationEffector.apply so that
AnimationTrack can validate and interpolate flattened keyframes.
