Capítulo 284 de 859

Chapter 284: AnimationAction

Core Idea

An instance of AnimationAction schedules the playback of an animation which is stored in AnimationClip.

Key Concepts

  • blendMode : NormalAnimationBlendMode | AdditiveAnimationBlendMode: Defines how the animation is blended/combined when two or more animations are simultaneously played.
  • clampWhenFinished : boolean: If set to true the animation will automatically be paused on its last frame.
  • enabled : boolean: If set to false, the action is disabled so it has no impact.
  • loop : LoopRepeat | LoopOnce | LoopPingPong: The loop mode, set via AnimationAction#setLoop.
  • paused : boolean: If set to true, the playback of the action is paused.
  • repetitions : number: The number of repetitions of the performed clip over the course of this action. Can be set via [AnimationAction#setLoop](AnimationAction.ht…
  • time : number: The local time of this action (in seconds, starting with 0).
  • timeScale : number: Scaling factor for the AnimationAction#time. A value of 0 causes the animation to pause. Negative values cau…
  • weight : number: The degree of influence of this action (in the interval [0, 1]). Values between 0 (no impact) and 1 (full impact) can be used to blen…
  • zeroSlopeAtEnd : boolean: Enables smooth interpolation without separate clips for start, loop and end.

Reference Tables

Constructor

Signature
`new AnimationAction( mixer : AnimationMixer, clip : AnimationClip, localRoot : Object3D, blendMode : NormalAnimationBlendMode

Properties

PropertyDescription
`.blendMode : NormalAnimationBlendModeAdditiveAnimationBlendMode`
.clampWhenFinished : booleanIf set to true the animation will automatically be paused on its last frame.
.enabled : booleanIf set to false, the action is disabled so it has no impact.
`.loop : LoopRepeatLoopOnce
.paused : booleanIf set to true, the playback of the action is paused.
.repetitions : numberThe number of repetitions of the performed clip over the course of this action. Can be set via AnimationAction#setLoop.
.time : numberThe local time of this action (in seconds, starting with 0).
.timeScale : numberScaling factor for the AnimationAction#time. A value of 0 causes the animation to pause. Negative values cause the animation to play backwards.
.weight : numberThe degree of influence of this action (in the interval [0, 1]). Values between 0 (no impact) and 1 (full impact) can be used to blend between several actions.
.zeroSlopeAtEnd : booleanEnables smooth interpolation without separate clips for start, loop and end.
.zeroSlopeAtStart : booleanEnables smooth interpolation without separate clips for start, loop and end.

Methods

MethodDescription
.crossFadeFrom( fadeOutAction : AnimationAction, duration : number, warp : boolean ) : AnimationActionCauses this action to fade in and the given action to fade out, within the passed time interval.
.crossFadeTo( fadeInAction : AnimationAction, duration : number, warp : boolean ) : AnimationActionCauses this action to fade out and the given action to fade in, within the passed time interval.
.fadeIn( duration : number ) : AnimationActionFades the animation in by increasing its weight gradually from 0 to 1, within the passed time interval.
.fadeOut( duration : number ) : AnimationActionFades the animation out by decreasing its weight gradually from 1 to 0, within the passed time interval.
.getClip() : AnimationClipReturns the animation clip of this animation action.
.getEffectiveTimeScale() : numberReturns the effective time scale of this action.
.getEffectiveWeight() : numberReturns the effective weight of this action.
.getMixer() : AnimationMixerReturns the animation mixer of this animation action.
.getRoot() : Object3DReturns the root object of this animation action.
.halt( duration : number ) : AnimationActionDecelerates this animation's speed to 0 within the passed time interval.
.isRunning() : booleanReturns true if the animation is running.
.isScheduled() : booleanReturns true when AnimationAction#play has been called.
.play() : AnimationActionStarts the playback of the animation.
.reset() : AnimationActionResets the playback of the animation.
.setDuration( duration : number ) : AnimationActionSets the duration for a single loop of this action.
.setEffectiveTimeScale( timeScale : number ) : AnimationActionSets the effective time scale of this action.
.setEffectiveWeight( weight : number ) : AnimationActionSets the effective weight of this action.
`.setLoop( mode : LoopRepeatLoopOnce
.startAt( time : number ) : AnimationActionDefines the time when the animation should start.
.stop() : AnimationActionStops the playback of the animation.
.stopFading() : AnimationActionStops any fading which is applied to this action.
.stopWarping() : AnimationActionStops any scheduled warping which is applied to this action.
.syncWith( action : AnimationAction ) : AnimationActionSynchronizes this action with the passed other action.
.warp( startTimeScale : number, endTimeScale : number, duration : number ) : AnimationActionChanges the playback speed, within the passed time interval, by modifying AnimationAction#timeScale gradually from startTimeScale to endTimeScale.

Key Takeaways

  1. Most relevant properties: blendMode, clampWhenFinished, enabled, loop.
  2. Key methods: crossFadeFrom, crossFadeTo, fadeIn, fadeOut.

Connects To