1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
"""
.. _load_gltf:
Working with glTF Files
~~~~~~~~~~~~~~~~~~~~~~~
Import a glTF file directly into a PyVista plotting scene. For more
details regarding the glTF format, see:
https://www.khronos.org/gltf/
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.
"""
from __future__ import annotations
import pyvista
from pyvista import examples
helmet_file = examples.gltf.download_damaged_helmet()
texture = examples.download_dikhololo_night()
# %%
# Set up the plotter and enable environment textures. This works well
# for physically based rendering enabled meshes like the damaged
# helmet example. Use :func:`pyvista.Plotter.import_gltf` to import file.
# sphinx_gallery_start_ignore
PYVISTA_GALLERY_FORCE_STATIC = True
# sphinx_gallery_end_ignore
pl = pyvista.Plotter()
pl.import_gltf(helmet_file)
pl.set_environment_texture(texture)
pl.camera.zoom(1.7)
pl.show()
# %%
# You can also directly read in gltf files and extract the underlying
# mesh.
block = pyvista.read(helmet_file)
mesh = block[0][0][0]
mesh.plot(color='lightblue', show_edges=True, cpos='xy')
|