.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/01_introductory/viz_gltf_animated.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_01_introductory_viz_gltf_animated.py: ======================= Visualizing a glTF file ======================= In this tutorial, we will show how to display a simple animated glTF in a scene. .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: Python from fury import window from fury.data import fetch_gltf, read_viz_gltf from fury.gltf import glTF .. GENERATED FROM PYTHON SOURCE LINES 14-15 Create a scene. .. GENERATED FROM PYTHON SOURCE LINES 15-24 .. code-block:: Python scene = window.Scene() showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) showm.initialize() .. GENERATED FROM PYTHON SOURCE LINES 25-26 Retrieving the gltf model. .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: Python fetch_gltf('InterpolationTest', 'glTF') filename = read_viz_gltf('InterpolationTest') .. GENERATED FROM PYTHON SOURCE LINES 30-32 Initialize the glTF object and get actors using `actors` method. Get the main_timeline (which contains multiple Timeline objects). .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python gltf_obj = glTF(filename) timeline = gltf_obj.main_animation() .. GENERATED FROM PYTHON SOURCE LINES 37-38 Add the timeline to the scene (No need to add actors separately). .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python scene.add(timeline) .. GENERATED FROM PYTHON SOURCE LINES 42-43 define a timer_callback that updates the timeline. .. GENERATED FROM PYTHON SOURCE LINES 43-58 .. code-block:: Python interactive = False def timer_callback(_obj, _event): timeline.update_animation() showm.render() showm.add_timer_callback(True, 10, timer_callback) if interactive: showm.start() window.record(scene, out_path='viz_gltf_animated.png', size=(900, 768)) .. image-sg:: /auto_examples/01_introductory/images/sphx_glr_viz_gltf_animated_001.png :alt: viz gltf animated :srcset: /auto_examples/01_introductory/images/sphx_glr_viz_gltf_animated_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.156 seconds) .. _sphx_glr_download_auto_examples_01_introductory_viz_gltf_animated.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: viz_gltf_animated.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: viz_gltf_animated.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_