export_gltf

Plotter.export_gltf(filename, inline_data=True, rotate_scene=True, save_normals=True)

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, optional

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

rotate_scenebool, optional

Rotate scene to be compatible with the glTF specifications.

save_normalsbool, optional

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

Examples

Output a simple point cloud represented as balls.

>>> import numpy as np
>>> import pyvista
>>> point_cloud = np.random.random((100, 3))
>>> pdata = pyvista.PolyData(point_cloud)
>>> pdata['orig_sphere'] = np.arange(100)
>>> sphere = pyvista.Sphere(radius=0.02)
>>> pc = pdata.glyph(scale=False, geom=sphere)
>>> pl = pyvista.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()