pygfx.utils.load.load_scene

pygfx.utils.load.load_scene(path, flatten=False, meshes=True, materials=True, volumes=True, lights='auto', camera='auto', remote_ok=False)

Load file into a scene.

When reading file formats that can contain more than just meshes (e.g. .glb) this function will attempt to import the entire scene, including lights, cameras, volumes and materials. If the file format is mesh-only (e.g. .stl) or volume-only (e.g. .binvox) we will instead construct a minimal scene.

This function requires the trimesh library.

Parameters:
  • path (str) – The filepath. Can be a local file or a URL.

  • flatten (bool) – If True, will ignore any hierarchical structure in the scene graph and instead import as a flat list of objects. Default is False.

  • meshes (bool) – Whether to load meshes. Default is True.

  • materials (bool) – Whether to load materials. Default is True.

  • volumes (bool) – Whether to load 3D image volumes. Default is True.

  • lights ("auto" | "file" | "none") – Whether to import lights. “auto” (default) will always add lights to the scene even if the file does not contain any; “file” will import only lights defined in the file; “none” will not add any lights to the scene.

  • camera ("auto" | "file" | "none") – Whether to import camera. “auto” (default) will always add a camera to the scene even if the file does not contain any; “file” will import only cameras defined in the file; “none” will not add any cameras to the scene.

  • remote_ok (bool) – Whether to allow loading files from URLs. Default is False.

Returns:

scene – The loaded scene.

Return type:

pygfx.Scene

See also

load_mesh

Returns the flat meshes contained in a file.