Request

Response

    Autodesk.Viewing.Extensions

    AnimationExtension

    AnimationExtension adds a toolbar with buttons (play/pause/forward/backward/goto start/end) and timeline scrubber to control animation playback. The extension provides api methods that will be reflected by the animation toolbar.

    The extension id is: Autodesk.Fusion360.Animation

    Examples

    // When ANIMATION_READY_EVENT is fired, object tree has been created and animation data has been processed
    viewer.addEventListener(Autodesk.Viewing.ANIMATION_READY_EVENT, function () {
      const animationExt = viewer.getExtension('Autodesk.Fusion360.Animation');
      animationExt.play();
    });
    

    Methods

    Adds a toolbar button and hooks animation listeners.

    Removes toobar button and unhooks animation listeners.

    Plays the animation. Invoke pause() to stop the animation.

    Pauses an active animation. Can resume by invoking play()

    Whether the animation is currently playing. Always returns the opposite of isPaused()

    Returns

    typedescription
    boolean

    isPaused()

    Whether the animation is currently paused. Always returns the opposite of isPlaying()

    Returns

    typedescription
    boolean

    rewind()

    Rewinds and pauses the animation.

    setTimelineValue(scale)

    Sets the animation at the very beginning (0), at the end(1) or anywhere in between. For example, use value 0.5 to set the animation half way through it’s completion. Will pause a playing animation.

    Parameters

    scale*
    number
    value between 0 and 1
    * Required

    prevKeyframe()

    Sets animation onto the previous keyframe. Will pause the animation if playing.

    nextKeyframe()

    Sets animation onto the next keyframe. Will pause the animation if playing.

    getDuration()

    Returns how many seconds does the animation take to complete.

    Returns

    typedescription
    number

    getDurationLabel()

    Returns duration as a formatted String h:mm:ss (hours:minutes:seconds)

    Returns

    typedescription
    string

    getCurrentTime()

    Returns the elapsed time (in seconds) of the animation.

    Returns

    typedescription
    number

    getCurrentTimeLabel()

    Returns the current animation time as a formatted String h:mm:ss (hours:minutes:seconds)

    Returns

    typedescription
    string

    setFollowCamera(followCam)

    Whether a playing animation updates the camera position.

    Parameters

    followCam*
    boolean
    true to allow animation to update camera position (default behavior).
    * Required

    Returns

    typedescription
    boolean true if the operation was successful.

    isFollowingCamera()

    Returns

    typedescription
    boolean Whether animations will update the camera’s position (true) or not (false)

    setSpeedModifier(value)

    Changes the speed at which the animation is played. Use value 1 to run the animation at default speed, use value 2 to run it at double the speed, use value 0.5 to run it at half the speed.

    Parameters

    value*
    number
    A multiplier for the animation’s elapsed time.
    * Required

    getSpeedModifier()

    Returns

    typedescription
    number The playback speed multiplier.

    setLooping(loop)

    Sets whether the animation rewinds and plays as soon as the animation finishes playing.

    Parameters

    loop*
    boolean
    true to have the animation loop continuously.
    * Required

    isLooping()

    Returns

    typedescription
    boolean Whether the animation will loop continuously.

    onToolbarCreated(toolbar)

    Invoked by the viewer when the toolbar UI is available.

    Parameters

    toolbar*toolbar instance.
    * Required

    openPanel()

    Opens a panel with options to configure the animation extension.

    activate()

    Plays the animation.

    deactivate()

    Pauses the animation.

    isActive()

    Returns

    typedescription
    boolean true when the animation is playing.