{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Working with glTF Files {#load_gltf}\n\nImport a glTF file directly into a PyVista plotting scene. For more\ndetails regarding the glTF format, see: <https://www.khronos.org/gltf/>\n\nFirst, download the examples. Note that here we\\'re using a high dynamic\nrange texture since glTF files generally contain physically based\nrendering and VTK v9 supports high dynamic range textures.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import pyvista\nfrom pyvista import examples\n\nhelmet_file = examples.gltf.download_damaged_helmet()\ntexture = examples.download_dikhololo_night()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Set up the plotter and enable environment textures. This works well for\nphysically based rendering enabled meshes like the damaged helmet\nexample. Use `pyvista.Plotter.import_gltf`{.interpreted-text\nrole=\"func\"} to import file.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "pl = pyvista.Plotter()\npl.import_gltf(helmet_file)\npl.set_environment_texture(texture)\npl.camera.zoom(1.7)\npl.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "You can also directly read in gltf files and extract the underlying\nmesh.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "block = pyvista.read(helmet_file)\nmesh = block[0][0][0]\nmesh.plot(color='lightblue', show_edges=True, cpos='xy')"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}