Class
Position3DAnimationEffector
View sourceExtendsAnimationEffector
Applies interpolated 3D position values to an entity’s
Position3D component.
This class implements the AnimationEffector contract for 3D
position animation. Pass it to an AnimationTrack; each keyframe
contains x, y, and z values in that order.
Examples
import { World } from '@wimaengine/ecs'
import { AnimationTrack, Position3DAnimationEffector } from '@wimaengine/animation'
import { Position3D } from '@wimaengine/transform'
const world = new World()
const entity = world.spawn([new Position3D()])
const track = new AnimationTrack(Position3DAnimationEffector)
track.times = [0, 1]
track.keyframes = [0, 0, 0, 10, 20, 30]
Position3DAnimationEffector.apply(world, entity, track.getCurrent(0.5))
// The entity's position is now (5, 10, 15).Constructor
Properties
staticcomponentType: typeof Position3D
View sourceComponent constructor read by
Position3DAnimationEffector.apply. The method accesses this
through this.componentType, so a compatible subclass can replace the
constructor it looks up.
Default: Position3D
Methods
staticapply(world: World, entity: EntityHandle, results: number[]): void
View sourceWrites the current x, y, and z values to the target position
component.
Position3DAnimationEffector.apply reads this.componentType from
world for entity, then
calls set(results[0], results[1], results[2]) on the returned component.
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 set() call to fail.
staticelementSize(): number
View sourceReturns the number of values consumed from each keyframe.
AnimationTrack therefore stores and interpolates three consecutive
values per timestamp for this effector.
