pyvista.Plotter.export_gltf#

Plotter.export_gltf(filename, inline_data=True, rotate_scene=True, save_normals=True)[source]#

Export the current rendering scene as a glTF file.

Visit https://gltf-viewer.donmccurdy.com/ for an online viewer.

See https://vtk.org/doc/nightly/html/classvtkGLTFExporter.html for limitations regarding the exporter.

Parameters:
filenamestr

Path to export the gltf file to.

inline_databool, default: True

Sets if the binary data be included in the json file as a base64 string. When True, only one file is exported.

rotate_scenebool, default: True

Rotate scene to be compatible with the glTF specifications.

save_normalsbool, default: True

Saves the point array 'Normals' as 'NORMAL' in the outputted scene.

Notes

The VTK exporter only supports pyvista.PolyData datasets. If the plotter contains any non-PolyData datasets, these will be converted in the plotter, leading to a copy of the data internally.

Examples

Output a simple point cloud represented as balls.

>>> import numpy as np
>>> import pyvista as pv
>>> rng = np.random.default_rng(seed=0)
>>> point_cloud = rng.random((100, 3))
>>> pdata = pv.PolyData(point_cloud)
>>> pdata['orig_sphere'] = np.arange(100)
>>> sphere = pv.Sphere(radius=0.02)
>>> pc = pdata.glyph(scale=False, geom=sphere, orient=False)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(
...     pc,
...     cmap='reds',
...     smooth_shading=True,
...     show_scalar_bar=False,
... )
>>> pl.export_gltf('balls.gltf')  
>>> pl.show()

Output the orientation plotter.

>>> from pyvista import demos
>>> pl = demos.orientation_plotter()
>>> pl.export_gltf('orientation_plotter.gltf')  
>>> pl.show()