.. role:: ts-api-decorator

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

.. js:module:: cee.ug
   :noindex:

.. container:: ts-api-section

   .. js:class:: Animation

      Handles animation of a ``RemoteModel``.

      With this class you can control state animations (animations across the states of the CAE analysis), 
      particle trace animations and mode shape animations.

      To start a state animation, specify the states to animate over with the ``ModelSpec.stateIdArray`` property and call ``runAnimation(true)``.

      To start a particle trace animation, set the ``particleTraceAnimationStepCount`` property and call
      ``runParticleTraceAnimation(true)``. Note that you must first create a particle trace by calling
      ``RemoteModel.addParticleTraceGroup``.

      To start a mode shape animation, set the ``ModelSpec.modeShapeAnimationType`` and
      ``ModelSpec.modeShapeFrameCount`` properties and then call ``runAnimation(true)``. Note that you must first set a displacement result on the 
      model with ``ModelSpec.displacementResultId``, and that ``ModelSpec.stateIdArray`` must contain exactly one state id.

      You can access the animation object from the remote model with the ``RemoteModel.animation`` property.



.. container:: api-index-section

   .. rubric:: Accessors

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

   * :js:attr:`~cee.ug.Animation.particleTraceAnimationStepCount`
   * :js:attr:`~cee.ug.Animation.targetFrameRate`



.. container:: api-index-section

   .. rubric:: Methods

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

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





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

Accessors
=========

.. container:: ts-api-section

   .. js:function:: Animation.particleTraceAnimationStepCount()



      The number of steps to use for the particle trace animation.

      The number of steps will be used to calculate the delta time for each step in the animation
      based on the total time of all active traces.


      :rtype: number

   .. js:function:: Animation.particleTraceAnimationStepCount( numSteps)

      :param numSteps: None
      :type numSteps: number


      :rtype: void



.. container:: ts-api-section

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



      The target animation speed in frames per second (fps).

      This will be the maximum animation speed, but the actual speed may be lower for large
      models or slow clients.


      :rtype: number

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

      :param framesPerSecond: None
      :type framesPerSecond: number


      :rtype: void



Methods
=======

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

isAnyAnimationRunning
---------------------

.. js:method:: Animation.isAnyAnimationRunning()



   Returns true if either a state, mode shape or particle trace animation is running


   :rtype: boolean

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

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

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



   Returns true if either a state or mode shape animation is running


   :rtype: boolean

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

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

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

   :param run: None
   :type run: boolean


   Starts a state (transient) or mode shape animation.

   The steps are configured in the ``ModelSpec`` of the ``RemoteModel``. 

   To start a state (transient) animations, set the states you would like to animate over with ``ModelSpec.stateIdArray``. 
   The order of the states in the animation will be the same as in the array. Note that ``ModelSpec.modeShapeFrameCount``
   MUST be set to 0 for state (transient) animations.

   To start a mode shape animation, set the ``ModelSpec.modeShapeAnimationType`` and
   ``ModelSpec.modeShapeFrameCount`` properties and then call ``runAnimation(true)``. Note that you must first 
   set a displacement result on the model with ``ModelSpec.displacementResultId``, and that ``ModelSpec.stateIdArray`` 
   must contain exactly one state id.


   :rtype: void

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

runParticleTraceAnimation
-------------------------

.. js:method:: Animation.runParticleTraceAnimation( run)

   :param run: None
   :type run: boolean


   Starts a particle trace animation.

   The number of steps to use for the animation can be set with ``particleTraceAnimationStepCount``.


   :rtype: void

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

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

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

   :param animationFrameChangedCallback: None
   :type animationFrameChangedCallback: AnimationFrameChangedCallback


   Sets a handler function that will be called whenever a progress indication packet is received from the 
   visualization server.


   :rtype: void

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

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

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



   Sets the first step of the animation (if any) as the current step. This will stop the animation.


   :rtype: void

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

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

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



   Sets the last step of the animation (if any) as the current step. This will stop the animation.


   :rtype: void

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

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

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



   Sets the next step of the animation (if any) as the current step, wrapping around to the first step if on
   the last step. This will stop the animation.


   :rtype: void

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

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

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



   Sets the previous step of the animation (if any) as the current step, wrapping around to the last step if on
   the first step. This will stop the animation.


   :rtype: void

