{ "cells": [ { "cell_type": "markdown", "id": "ae15252f", "metadata": {}, "source": [ "# Animation\n", "\n", "WeasWidget supports animations using a **list of ASE Atoms objects** or an **ASE Trajectory**.\n", "\n", "## Example: Rotating a Molecule" ] }, { "cell_type": "code", "execution_count": null, "id": "c3e3d00b", "metadata": {}, "outputs": [], "source": [ "from ase.build import molecule\n", "from weas_widget import WeasWidget\n", "atoms = molecule(\"C2H6SO\")\n", "# create a list of atoms by rotating it.\n", "images = []\n", "for i in range(0, 360, 10):\n", " new_atoms = atoms.copy()\n", " new_atoms.rotate(\"z\", i)\n", " images.append(new_atoms)\n", "viewer = WeasWidget()\n", "viewer.from_ase(images)\n", "viewer" ] }, { "cell_type": "markdown", "id": "20687ac6", "metadata": {}, "source": [ "## Animation Controls\n", "\n", "### Timeline Interaction\n", "\n", "- You can play the animation using the timeline bar.\n", "- In **play mode**, only atomic positions are updated, preventing unnecessary re-drawing of bonds and polyhedra.\n", "- In **pause mode**, behavior depends on the `continuous_update` setting.\n", "\n", "### Continuous Update Behavior\n", "\n", "You can toggle this setting as follows:\n", "\n", "```python\n", "viewer.avr.continuous_update = False\n", "```\n", "\n", "- Enabled (default):\n", "\n", " - The entire visualization (bonds, image atoms, polyhedra) updates dynamically as the user drags the timeline slider.\n", " - This provides real-time feedback but may be computationally expensive for large systems.\n", "\n", "- Disabled:\n", "\n", " - The model updates only when the user releases the timeline slider.\n", " - This reduces rendering overhead and improves performance for large animations.\n" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }