pygfx.utils.show.Display

class pygfx.utils.show.Display(canvas=None, renderer=None, controller=None, camera=None, before_render=None, after_render=None, draw_function=None, stats=False)

Bases: object

A Helper to display an object or scene

This class provides the basic scaffolding needed to visualize a given WorldObject. To do so the class chooses a sensible default for each part of the full setup unless the value is explicitly set by the user or exists as a child of object. For example, it will create a camera unless you explicitly set a value for camera or if there is (at least) one camera in the scene.

Parameters:
  • canvas (WgpuCanvas) – The canvas used to display the object. If both renderer and canvas are set, then the renderer needs to use the set canvas.

  • renderer (gfx.Renderer) – The renderer to use while drawing the scene. If both renderer and canvas are set, then the renderer needs to use the set canvas.

  • controller (gfx.Controller) – The camera controller to use.

  • camera (gfx.Camera) – The camera to use. If not set, Display will use the first camera in the scene graph. If there is none, Display will create one.

  • before_render (Callable) – A callback that will be executed during each draw call before a new render is made.

  • after_render (Callable) – A callback that will be executed during each draw call after a new render is made.

  • draw_function (Callable) – Replaces the draw callback with a custom one. If set, both before_render and after_render will have no effect.

  • stats (bool) – Display performance statistics such as FPS and draw time in the corner of the screen. Defaults to False.

show(object: WorldObject, up=(0, 1, 0))

Display a WorldObject

This function provides you with the basic scaffolding to visualize a given WorldObject in a new window. While it does add scaffolding, it aims to be fully customizable so that you can replace each piece as needed.

Parameters:
  • object (gfx.WorldObject) – The object to show. If it is not a gfx.Scene then Display will wrap it into a new scene containing lights and a background.

  • up (ndarray) – If set, and object does not contain a controller, set the camera controller’s up vector to this value.

Notes

If you want to display multiple objects, use gfx.Group instead of gfx.Scene if you want lights and background to be added.