@pixi/3d
    Preparing search index...

    Class AnimationState

    Playback state for a single Animation on an AnimationPlayer

    AnimationPlayer#play and AnimationPlayer#getState return one. Use it to control playback, looping, speed and blend weight. The playback methods follow pixi's AnimatedSprite: stop() freezes in place and play() resumes from there.

    const walk = model.player.play('walk');

    walk.animationSpeed = 0.5;
    walk.stop(); // freeze at the current pose
    walk.play(); // resume from the same time
    walk.gotoAndStop(0); // rewind and show the first pose
    Index
    animation: Animation

    Animation this state plays

    walk.gotoAndStop(walk.animation.duration);
    
    animationSpeed: number = 1

    Playback speed multiplier; negative values play backwards

    walk.animationSpeed = 2;
    rewind.animationSpeed = -1;
    1
    
    loop: boolean = true

    Whether playback wraps around at the animation's ends

    const jump = player.play('jump');

    jump.loop = false;
    true
    
    onComplete: (() => void) | null = null

    Called once when a non-looping state reaches its end

    The state has already stopped, holding its final pose, so the callback can start the next animation.

    const attack = player.getState('attack');

    attack.loop = false;
    attack.onComplete = () => player.play('idle');
    attack.gotoAndPlay(0);
    null
    
    onLoop: (() => void) | null = null

    Called each time a looping state wraps around its duration

    walk.onLoop = () => footsteps.play();
    
    null
    

    Player that owns this state

    attack.onComplete = () => attack.player.play('idle');
    
    time: number = 0

    Current playback time in seconds

    Writing it moves the playhead without applying the pose. Use gotoAndStop() to seek and show the pose at once.

    const progress = walk.time / walk.animation.duration;
    
    0
    
    weight: number = 1

    Share of the blend when several playing states drive the same property through tracks with the same label

    Weights are relative: at 1 and 3, the property ends up a quarter one state and three quarters the other. They don't fade a state against the rest pose; a state that is the only one driving a property applies in full at any weight above 0. At 0 the state keeps advancing but writes nothing.

    const walk = player.play('walk');
    const run = player.play('run');

    walk.weight = 1 - speed;
    run.weight = speed;
    1
    
    • get playing(): boolean

      Whether this state is advancing on its player's updates

      Returns boolean

      if (!attack.playing) attack.gotoAndPlay(0);
      
    • Jumps to a time and starts playing from there

      Parameters

      • time: number

        Playback time in seconds

      Returns this

      This state for chaining

      attackButton.on('pointertap', () => attack.gotoAndPlay(0));
      
    • Stops playback at a time and applies that pose to the target right away

      The pose is this state's alone, not blended with others; a state still playing overwrites the properties it drives on the next update. Does nothing once the owning player is destroyed.

      Parameters

      • time: number

        Playback time in seconds

      Returns this

      This state for chaining

      slider.on('change', (value: number) => walk.gotoAndStop(value * walk.animation.duration));
      
    • Starts or resumes playback from the current time

      A one-shot animation that already finished completes again on the next update; use gotoAndPlay(0) to restart it, or gotoAndPlay(animation.duration) for one a negative animationSpeed plays backwards. Does nothing once the owning player is destroyed.

      Returns this

      This state for chaining

      pauseButton.on('pointertap', () => (walk.playing ? walk.stop() : walk.play()));
      
    • Stops playback, holding the current time and pose

      To rewind, call gotoAndStop(0).

      Returns this

      This state for chaining

      player.getState('walk').stop();