CLEAR

AnimationModule


The AnimationModule class implements object animation.

Example

const Animation = require('Animation');
const Scene = require('Scene');
const FaceTracking = require('FaceTracking');

const plane = Scene.root.find('plane0');

// Animate the Face Mesh's vertical scale according to the mouth openness
const mouthOpennessDriver = Animation.valueDriver(FaceTracking.face(0).mouth.openness, 0.1, 0.6);
const linearSampler = Animation.samplers.linear(1, 2);
const scaleAnimation = Animation.animate(mouthOpennessDriver, linearSampler);

plane.transform.scaleY = scaleAnimation;

// Animate the Face Mesh's horizontal position continuously
const timeDriver = Animation.timeDriver({durationMilliseconds: 1500, loopCount: Infinity, mirror: true});
const quadraticSampler = Animation.samplers.easeInOutQuad(-0.1, 0.1);
const translationAnimation = Animation.animate(timeDriver, quadraticSampler);

plane.transform.x = translationAnimation;
timeDriver.start(); // TimeDriver-based animations need to be started explicitly.

Properties

PropertyDescription

samplers

(get) samplers: SamplerFactory (set) (Not Available)

Specifies an instance of a SamplerFactory object.

Methods

MethodDescription

animate

animate(driver: Driver, sampler: ScalarSampler): ScalarSignal animate(driver: Driver, sampler: ArrayOfScalarSamplers): ArrayOfScalarSignals animate(driver: Driver, sampler: RotationSampler): RotationSignal animate(driver: Driver, sampler: ColorSampler): RgbaSignal

Combines the driver and the sampler to create a signal that can be used to animate arbitrary properties of arbitrary objects.

For TimeDriver-based animations the animation will start only when TimeDriver.start is invoked.

timeDriver

timeDriver(timeDriverParams: {durationMilliseconds: number, loopCount: ?number, mirror: ?boolean}): TimeDriver

Returns a TimeDriver object that drives an animation for the specified parameters. loopCount defines the number of iterations before the time driver stops; this can be infinity. When mirror is TRUE, the time driver follows a yoyo effect with every odd iteration going forwards and every even iteration going backwards.

valueDriver

valueDriver(value: ScalarSignal, min: number, max: number): ValueDriver

Returns a ValueDriver object that drives an animation based on values emitted from a ScalarValue. The signal values are normalized and clamped to maximum and minimum values.

Classes

ClassDescription

ArrayOfScalarSamplers

The ArrayOfScalarSamplers class describes an array of scalar samplers.

ArrayOfScalarSignals

The ArrayOfScalarSignals class describes an array of scalar signals.

ColorSampler

The ColorSampler class encapsulates a color sampler.

Driver

The Driver class encapsulates an animation driver.

RotationSampler

The RotationSampler class is an animation sampler for object rotation.

SamplerFactory

The SamplerFactory class creates different types of animation samplers.

ScalarSampler

The ScalarSampler class encapsulates a scalar value sampler.

SignalRecord

The SignalRecord class encapsulates recording data for a value signal

SignalRecorder

The SignalRecorder class enables recording and playback of signal values

TimeDriver

The TimeDriver class controls an animation.

ValueDriver

The ValueDriver class controls an animation value.