Visualizing a glTF file#

In this tutorial, we will show how to display a glTF file in a scene.

from fury import window
from import fetch_gltf, read_viz_gltf
from fury.gltf import glTF

Create a scene.

scene = window.Scene()
scene.SetBackground(0.1, 0.1, 0.4)

Retrieving the gltf model.

fetch_gltf('Duck', 'glTF')
filename = read_viz_gltf('Duck')

Initialize the glTF object and get actors using actors method. Note: You can always manually create actor from polydata, and apply texture or materials manually afterwards. Experimental: For smooth mesh/actor you can set apply_normals=True.

gltf_obj = glTF(filename, apply_normals=False)
actors = gltf_obj.actors()

Add all the actor from list of actors to the scene.

Applying camera

cameras = gltf_obj.cameras
if cameras:

interactive = False

if interactive:, size=(1280, 720))

window.record(scene, out_path='viz_gltf.png', size=(1280, 720))
viz gltf

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

Gallery generated by Sphinx-Gallery