animator

A helper object for scripting reusable keyframe-based animations.

Summary
animatorA helper object for scripting reusable keyframe-based animations.
Preference DialogNone.
CommentsThe animator assists you in scripting a reusable keyframe-based animation.
Properties
interpolationTypeconst, ( r, w )
lengthfloat, ( r, w )
keyTypeconst, ( r, w )
alignbool, ( r, w )
timeScalefloat, ( r, w )
dimobject, ( r, w )
rposfloat [0, 1], ( r, w )
rorifloat [0, 1], ( r, w )
rsclfloat [0, 1], ( r, w )
keysarray, ( r )
Functions
addKey
apply
remove

Preference Dialog

None.

Comments

The animator assists you in scripting a reusable keyframe-based animation.  Once complete, you can apply the resulting animation to any 3D entity OR object with numerical properties.

Here is an annotated example code that uses both animator and replicator to animate a swarm of cubes.

var r = new animator();
r.interpolationType = animator.LINEAR;
// not specifying rot and scl means they will stay
// the same as previous values, in this case, the initial valus.
var k = r.addKey();
k.time = 0.5;
k.position = {x:0,y:300,z:0};
k = r.addKey();
k.time = 1.5;
k.position = {x:200,y:300,z:0};
k.scale = {x:0.2,y:0.2,z:0.2};
k = r.addKey();
k.time = 2.0;
k.position = {x:200,y:300,z:500};
k.rotation = {x:0,y:90,z:0};
// leaving the last pos, scl, rot undefined
// means it will loop back to settings at time 0.0
k = r.addKey();
k.time = 2.5;
// add large randomenss to its movement including
// position, rotation, and scale in all 3 dimensions.
r.dim = {x:350,y:350,z:350};
r.rpos = {x:0.9,y:0.9,z:0.9};
r.rori = {x:0.9,y:0.9,z:0.9};
r.rscl = {x:0.9,y:0.9,z:0.9};
// now replicate a cube manualobject molecule.
// first hide the original cube.
// The replication works as follows:
// a grid of 7x7 with 49 cells is introduced
// on the xz plane with origin at (0, 200, 0).
// Each cell has dimension (300, 300, 300).
// the cube is randomly placed in the cell
// with amount of randomness (0.2, 0.6, 0.2).
// Finally call run() to start the replication.
var rp = new replicator(this.cube);
this.cube.hide();
rp.origin = {x:0,y:200,z:0};
rp.mul = {x:7,y:1,z:7};
rp.dim = {x:300, y:300, z:300};
rp.rpos = {x:0.2,y:0.6,z:0.2};
rp.run();
// Apply the animation to each of the 49 cubes.
// Use replicator.access() to get to each cube by index.
// and animator.apply() to obtain its animation track.
// finally call track.play(true) to play the animation in a loop.
for (var i=0; i<49; i++)
{
  var a = r.apply(rp.access(i));
  a.play(true);
}

Properties

interpolationType

const, ( r, w )

Type of interpolation between keyframes,

animator.LINEARlinear
animator.SPLINEbezier-based spline
animator.SPLINE2catmullrom-based spline

length

float, ( r, w )

Length of animation in seconds.

keyType

const, ( r, w )

Type of keyframe,

animator.RELATIVEkey values (position, rotation, and scale) are realtive to their initial values.
animator.ABSOLUTEkey values (position, rotation, and scale) are absolute values.

align

bool, ( r, w )

Align object’s direction to the animation path.  If object’s direction is not defined, use local z-dir instead.(see Mesh Molecule.direction.)

timeScale

float, ( r, w )

Specified to time scale of animation.  The default is 1.0.

dim

object, ( r, w )

To enable random movement, this property specifies a cube in space centered in origin wherein random offset values in Vector3 are generated to add to the position of the animated object.

rpos

float [0, 1], ( r, w )

Specifies the amount of randomness that will affect the position of the animated object.

rori

float [0, 1], ( r, w )

Specifies the amount of randomness that will affect the orientation of the animated object.

rscl

float [0, 1], ( r, w )

Specifies the amount of randomness that will affect the scale of the animated object.

keys

array, ( r )

Returns an array of keyframes for this animation.

Functions

addKey

addKey();

Add a keyframe to this path animation.

Parameters

N/A

Returns

(object) a keyframe object.

apply

apply(entity);

Apply this animation to either a mesh, manualobject, light, or particle molecule or any javascript object containing animatable numerical properties.

Parameters

entity(object) a mesh, manualobject, light, or particle molecule or object with animatable properties.  (e.g.  {strength: 0.2}.)

Returns

(object)an animation track.

remove

remove(id);

Removes an animation track by id.  If no id is given, all tracks are removed.

Parameters

id(string) Optional. a valid track id.

Returns

N/A

A helper object for scripting reusable keyframe-based animations.
A helper object for replicating 3D objects with controlled randomness.
object, ( r, w )
The keyframe object.
A track object of a keyframe-based animation.
Close