Working with glTF Files

Import a glTF file directly into a PyVista plotting scene. For more details regarding the glTF format, see:

Note this feature is only available for vtk>=9.

First, download the examples. Note that here we’re using a high dynamic range texture since glTF files generally contain physically based rendering and VTK v9 supports high dynamic range textures.

import pyvista
from pyvista import examples

helmet_file = examples.gltf.download_damaged_helmet()
texture = examples.hdr.download_dikhololo_night()

Setup the plotter and enable environment textures. This works well for physically based rendering enabled meshes like the damaged helmet example.

pl = pyvista.Plotter()
load gltf

You can also directly read in gltf files and extract the underlying mesh.

block =
mesh = block[0][0][0]
mesh.plot(color='tan', show_edges=True, cpos='xy')
load gltf

Total running time of the script: ( 0 minutes 58.965 seconds)

Gallery generated by Sphinx-Gallery