KeyframeTrack class

A KeyframeTrack is a timed sequence of keyframes, which are composed of lists of times and related values, and which are used to animate a specific property of an object.

For an overview of the different elements of the three.js animation system see the "Animation System" article in the "Next Steps" section of the manual.

In contrast to the animation hierarchy of the JSON model format a KeyframeTrack doesn't store its single keyframes as objects in a "keys" array (holding the times and the values for each frame together in one place).

Instead of this there are always two arrays in a KeyframeTrack: the times array stores the time values for all keyframes of this track in sequential order, and the values array contains the corresponding changing values of the animated property.

A single value, belonging to a certain point of time, can not only be a simple number, but (for example) a vector (if a position is animated) or a quaternion (if a rotation is animated). For this reason the values array (which is a flat array, too) might be three or four times as long as the times array.

Corresponding to the different possible types of animated values there are several subclasses of KeyframeTrack, inheriting the most properties and methods:

  • BooleanKeyframeTrack
  • ColorKeyframeTrack
  • NumberKeyframeTrack
  • QuaternionKeyframeTrack
  • StringKeyframeTrack
  • VectorKeyframeTrack
  • Some examples of how to manually create AnimationClips with different sorts of KeyframeTracks can be found in the AnimationClipCreator file.

    Since explicit values are only specified for the discrete points of time stored in the times array, all values in between have to be interpolated.

    The track's name is important for the connection of this track with a specific property of the animated node (done by PropertyBinding).

    Implementers

    Constructors

    KeyframeTrack.new(String name, List<num> times, List<num> values, [int? interpolation])
    name - the identifier for the KeyframeTrack.

    Properties

    createInterpolant Function?
    getter/setter pair
    defaultInterpolation int
    getter/setter pair
    hashCode int
    The hash code for this object.
    no setterinherited
    name String
    getter/setter pair
    runtimeType Type
    A representation of the runtime type of the object.
    no setterinherited
    timeBufferType String
    getter/setter pair
    times List<num>
    getter/setter pair
    valueBufferType String
    getter/setter pair
    values List<num>
    getter/setter pair
    valueTypeName String
    getter/setter pair

    Methods

    clone() KeyframeTrack
    Returns a copy of this track.
    getInterpolation() int?
    Returns the interpolation type.
    getValueSize() int
    Returns the size of each value (that is the length of the values array divided by the length of the times array).
    interpolantFactoryMethodDiscrete(dynamic result) Interpolant?
    Creates a new DiscreteInterpolant from the times and values. A Float32Array can be passed which will receive the results. Otherwise a new array with the appropriate size will be created automatically.
    interpolantFactoryMethodLinear(dynamic result) Interpolant?
    Creates a new LinearInterpolant from the times and values. A Float32Array can be passed which will receive the results. Otherwise a new array with the appropriate size will be created automatically.
    interpolantFactoryMethodSmooth(dynamic result) Interpolant?
    Create a new CubicInterpolant from the times and values. A Float32Array can be passed which will receive the results. Otherwise a new array with the appropriate size will be created automatically.
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    optimize() KeyframeTrack
    Removes equivalent sequential keys, which are common in morph target sequences.
    scale(double timeScale) KeyframeTrack
    Scales all keyframe times by a factor
    setInterpolation(int interpolation) KeyframeTrack
    shift(dynamic timeOffset) KeyframeTrack
    Moves all keyframes either forward or backward in time.
    toString() String
    A string representation of this object.
    inherited
    trim(dynamic startTime, dynamic endTime) KeyframeTrack
    Removes keyframes before startTime and after endTime, without changing any values within the range `startTime`, `endTime`.
    validate() bool
    Performs minimal validation on the tracks. Returns true if valid.

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited

    Static Methods

    toJson(KeyframeTrack track) Map<String, dynamic>
    Converts the track to JSON.