Orientation3DAnimationEffector

View source

Writes four interpolated quaternion values from an AnimationTrack to an entity’s Orientation3D component.

Use the class itself as the track effector. Each keyframe contains four values in x, y, z, w order. apply() receives the interpolated values, target World, and EntityHandle. The target entity must already have an Orientation3D component.

Examples

import { World } from '@wimaengine/ecs'
import { AnimationTrack, Orientation3DAnimationEffector } from '@wimaengine/animation'
import { Orientation3D } from '@wimaengine/transform'

const world = new World()
const entity = world.spawn([new Orientation3D()])
const track = new AnimationTrack(Orientation3DAnimationEffector)
track.times = [0, 1]
track.keyframes = [0, 0, 0, 1, 0, 0, 1, 0]

Orientation3DAnimationEffector.apply(world, entity, track.getCurrent(0.5))
// The component now contains the interpolated quaternion [0, 0, 0.5, 0.5].

Constructor


constructor()

Properties


staticcomponentType: typeof Orientation3D

View source

Component constructor used by Orientation3DAnimationEffector.apply when it reads the target from the world. A compatible subclass can replace this value and the inherited apply method will use that constructor through this.componentType.

Default: Orientation3D

Methods


staticapply(world: World, entity: EntityHandle, results: number[]): void

View source

Writes four interpolated quaternion values to the target orientation.

The method calls world.get(entity, this.componentType), then passes results[0], results[1], results[2], and results[3] to the returned component’s set() method. It does not normalize the quaternion, 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.

Parameters

NameDescriptionDefault
world

World containing the target entity.

—
entity

Handle of the entity to update.

—
results

Interpolated quaternion values in x, y, z, w order.

—

staticelementSize(): number

View source

Returns the number of values consumed from each keyframe.

AnimationTrack uses this width when validating and interpolating the flattened keyframe array for this effector.

Returns

Always 4.