.. 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 <sphx_glr_download_auto_examples_01_introductory_viz_gltf.py>`
        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-10

.. code-block:: Python


    import fury








.. GENERATED FROM PYTHON SOURCE LINES 11-12

Create a scene.

.. GENERATED FROM PYTHON SOURCE LINES 12-16

.. code-block:: Python


    scene = fury.window.Scene()
    scene.SetBackground(0.1, 0.1, 0.4)








.. GENERATED FROM PYTHON SOURCE LINES 17-18

Retrieving the gltf model.

.. GENERATED FROM PYTHON SOURCE LINES 18-21

.. code-block:: Python

    fury.data.fetch_gltf(name="Duck", mode="glTF")
    filename = fury.data.read_viz_gltf("Duck")








.. GENERATED FROM PYTHON SOURCE LINES 22-26

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 26-30

.. code-block:: Python


    gltf_obj = fury.gltf.glTF(filename, apply_normals=False)
    actors = gltf_obj.actors()








.. GENERATED FROM PYTHON SOURCE LINES 31-32

Add all the actor from list of actors to the scene.

.. GENERATED FROM PYTHON SOURCE LINES 32-35

.. code-block:: Python


    scene.add(*actors)








.. GENERATED FROM PYTHON SOURCE LINES 36-37

Applying camera

.. GENERATED FROM PYTHON SOURCE LINES 37-48

.. code-block:: Python


    cameras = gltf_obj.cameras
    if cameras:
        scene.SetActiveCamera(cameras[0])

    interactive = False

    if interactive:
        fury.window.show(scene, size=(1280, 720))

    fury.window.record(scene=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.533 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 <viz_gltf.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: viz_gltf.py <viz_gltf.py>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_