AnimationAction constructor

AnimationAction(
  1. AnimationMixer mixer,
  2. AnimationClip clip, {
  3. Object3D? localRoot,
  4. int? blendMode,
})

mixer - the AnimationMixer that is controlled by this action.

clip - the AnimationClip that holds the animation data for this action.

localRoot - the root object on which this action is performed.

blendMode - defines how the animation is blended/combined when two or more animations are simultaneously played.

Note: Instead of calling this constructor directly you should instantiate an AnimationAction with AnimationMixer.clipAction since this method provides caching for better performance.

Implementation

AnimationAction(this.mixer, this.clip, {this.localRoot, int? blendMode}) {
  this.blendMode = blendMode ?? clip.blendMode;

  final tracks = clip.tracks;
  final nTracks = tracks.length;

  final interpolants = List<Interpolant?>.filled(nTracks, null);

  final interpolantSettings = {
    "endingStart": ZeroCurvatureEnding,
    "endingEnd": ZeroCurvatureEnding
  };

  for (int i = 0; i != nTracks; ++i) {
    final interpolant = tracks[i].createInterpolant!(null);
    interpolants[i] = interpolant;
    interpolant.settings = interpolantSettings;
  }

  _interpolantSettings = interpolantSettings;

  this.interpolants = interpolants; // bound by the mixer

  // inside: PropertyMixer (managed by the mixer)
  propertyBindings = List<PropertyMixer?>.filled(nTracks, null);

  cacheIndex = null; // for the memory manager
  byClipCacheIndex = null; // for the memory manager

  _timeScaleInterpolant = null;
  _weightInterpolant = null;

  loop = LoopRepeat;
  _loopCount = -1;

  // global mixer time when the action is to be started
  // it's set back to 'null' upon start of the action
  _startTime = null;

  // scaled local time of the action
  // gets clamped or wrapped to 0..clip.duration according to loop
  time = 0;

  timeScale = 1;
  _effectiveTimeScale = 1;

  weight = 1;
  _effectiveWeight = 1;

  repetitions = double.infinity; // no. of repetitions when looping

  paused = false; // true -> zero effective time scale
  enabled = true; // false -> zero effective weight

  clampWhenFinished = false; // keep feeding the last frame?

  zeroSlopeAtStart = true; // for smooth interpolation w/o separate
  zeroSlopeAtEnd = true; // clips for start, loop and end
}