.. 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.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.py: ======================= Visualizing a glTF file ======================= In this tutorial, we will show how to display a glTF file in a scene. .. GENERATED FROM PYTHON SOURCE LINES 7-12 .. 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 13-14 Create a scene. .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: Python scene = window.Scene() scene.SetBackground(0.1, 0.1, 0.4) .. GENERATED FROM PYTHON SOURCE LINES 19-20 Retrieving the gltf model. .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: Python fetch_gltf('Duck', 'glTF') filename = read_viz_gltf('Duck') .. GENERATED FROM PYTHON SOURCE LINES 24-28 Initialize the glTF object and get actors using `actors` method. Note: You can always manually create actor from polydata, and apply texture or materials manually afterwards. Experimental: For smooth mesh/actor you can set `apply_normals=True`. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python gltf_obj = glTF(filename, apply_normals=False) actors = gltf_obj.actors() .. GENERATED FROM PYTHON SOURCE LINES 33-34 Add all the actor from list of actors to the scene. .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python scene.add(*actors) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Applying camera .. GENERATED FROM PYTHON SOURCE LINES 39-50 .. code-block:: Python cameras = gltf_obj.cameras if cameras: scene.SetActiveCamera(cameras[0]) interactive = False if interactive: window.show(scene, size=(1280, 720)) window.record(scene, out_path='viz_gltf.png', size=(1280, 720)) .. image-sg:: /auto_examples/01_introductory/images/sphx_glr_viz_gltf_001.png :alt: viz gltf :srcset: /auto_examples/01_introductory/images/sphx_glr_viz_gltf_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.135 seconds) .. _sphx_glr_download_auto_examples_01_introductory_viz_gltf.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.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: viz_gltf.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_