.. role:: ts-api-decorator

#########
Animation
#########

.. js:module:: cee.pt
   :noindex:

.. container:: ts-api-section

   .. js:class:: Animation

      Controls time-step animation of a ``ParticleModel``.

      Access via ``ParticleModel.animation``. Frames advance inside the
      render loop at the configured ``targetFrameRate``.

      :example:  .. code-block:: typescript     const model = new cee.pt.ParticleModel({ preloadFrameCount: 5 });    await model.openModel(url);    await model.setFrame(0);     model.animation.targetFrameRate = 30;    model.animation.runAnimation(true); 



.. container:: api-index-section

   .. rubric:: Accessors

   .. rst-class:: api-index-list-item api-kind-accessor api-parent-kind-class

   * :js:attr:`~cee.pt.Animation.frameStride`
   * :js:attr:`~cee.pt.Animation.loop`
   * :js:attr:`~cee.pt.Animation.targetFrameRate`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.pt.Animation.isModelAnimationRunning`
   * :js:meth:`~cee.pt.Animation.runAnimation`
   * :js:meth:`~cee.pt.Animation.setAnimationFrameChangedCallback`
   * :js:meth:`~cee.pt.Animation.setFirstFrame`
   * :js:meth:`~cee.pt.Animation.setLastFrame`
   * :js:meth:`~cee.pt.Animation.setNextFrame`
   * :js:meth:`~cee.pt.Animation.setPreviousFrame`





------------

Accessors
=========

.. container:: ts-api-section

   .. js:function:: Animation.frameStride()



      Frames to advance per step. Default ``1``.

      E.g. stride 5 with ``targetFrameRate = 30`` gives a 150x speedup.
      Also used by ``setNextFrame`` and ``setPreviousFrame``.


      :rtype: number

   .. js:function:: Animation.frameStride( value)

      :param value: None
      :type value: number


      :rtype: void



.. container:: ts-api-section

   .. js:function:: Animation.loop()



      Wraps from the last frame to the first. Default ``true``.


      :rtype: boolean

   .. js:function:: Animation.loop( value)

      :param value: None
      :type value: boolean


      :rtype: void



.. container:: ts-api-section

   .. js:function:: Animation.targetFrameRate()



      Target animation speed in frames per second.
      Actual speed may be lower if data is not yet cached.


      :rtype: number

   .. js:function:: Animation.targetFrameRate( fps)

      :param fps: None
      :type fps: number


      :rtype: void



Methods
=======

.. rst-class:: ts-api-section

isModelAnimationRunning
-----------------------

.. js:method:: Animation.isModelAnimationRunning()



   Whether the animation is running.


   :rtype: boolean

.. rst-class:: ts-api-section

runAnimation
------------

.. js:method:: Animation.runAnimation( start)

   :param start: None
   :type start: boolean


   Start or stop playback.


   :rtype: void

.. rst-class:: ts-api-section

setAnimationFrameChangedCallback
--------------------------------

.. js:method:: Animation.setAnimationFrameChangedCallback( callback)

   :param callback: None
   :type callback: AnimationFrameChangedCallback


   Register a callback invoked on each frame change.


   :rtype: void

.. rst-class:: ts-api-section

setFirstFrame
-------------

.. js:method:: Animation.setFirstFrame()



   Seek to the first frame. Stops animation.


   :rtype: void

.. rst-class:: ts-api-section

setLastFrame
------------

.. js:method:: Animation.setLastFrame()



   Seek to the last frame. Stops animation.


   :rtype: void

.. rst-class:: ts-api-section

setNextFrame
------------

.. js:method:: Animation.setNextFrame()



   Advance by ``frameStride`` frames. Stops animation.


   :rtype: void

.. rst-class:: ts-api-section

setPreviousFrame
----------------

.. js:method:: Animation.setPreviousFrame()



   Rewind by ``frameStride`` frames. Stops animation.


   :rtype: void

