2222
2323from .. import rendering , util
2424from ..transformations import translation_matrix
25+ from ..typed import ArrayLike , Callable , Dict , Iterable , Number , Optional
2526from ..visual import to_rgba
2627from .trackball import Trackball
2728
4647| | at world frame, or at every frame and world, |
4748| | and at every frame |
4849| `f` | Toggles between fullscreen and windowed mode |
50+ | `h` | Prints this help message |
4951| `m` | Maximizes the window |
5052| `q` | Closes the window |
5153|----------------------------|-----------------------------------------------|
@@ -56,24 +58,23 @@ class SceneViewer(pyglet.window.Window):
5658 def __init__ (
5759 self ,
5860 scene ,
59- smooth = True ,
60- flags = None ,
61- visible = True ,
62- resolution = None ,
63- fullscreen = False ,
64- resizable = True ,
65- start_loop = True ,
66- callback = None ,
67- callback_period = None ,
68- caption = None ,
69- fixed = None ,
70- offset_lines = True ,
71- line_settings = None ,
61+ smooth : bool = True ,
62+ flags : Optional [ Dict ] = None ,
63+ visible : bool = True ,
64+ resolution : Optional [ ArrayLike ] = None ,
65+ fullscreen : bool = False ,
66+ resizable : bool = True ,
67+ start_loop : bool = True ,
68+ callback : Optional [ Callable ] = None ,
69+ callback_period : Optional [ Number ] = None ,
70+ caption : Optional [ str ] = None ,
71+ fixed : Optional [ Iterable ] = None ,
72+ offset_lines : bool = True ,
73+ line_settings : Optional [ Dict ] = None ,
7274 background = None ,
7375 window_conf = None ,
74- profile = False ,
75- record = False ,
76- print_help : bool = False ,
76+ profile : bool = False ,
77+ record : bool = False ,
7778 ** kwargs ,
7879 ):
7980 """
@@ -84,43 +85,48 @@ def __init__(
8485 ---------------
8586 scene : trimesh.scene.Scene
8687 Scene with geometry and transforms
87- smooth : bool
88+ smooth
8889 If True try to smooth shade things
89- flags : dict
90+ flags
9091 If passed apply keys to self.view:
9192 ['cull', 'wireframe', etc]
92- visible : bool
93+ visible
9394 Display window or not
94- resolution : (2,) int
95+ resolution
9596 Initial resolution of window
96- fullscreen : bool
97- Determines whether the window is rendered in fullscreen mode.
98- resizable : bool
99- Determines whether the rendered window can be resized by the user.
100- start_loop : bool
97+ fullscreen
98+ Determines whether the window is rendered in fullscreen mode.
99+ resizable
100+ Determines whether the rendered window can be resized by the user.
101+ start_loop
101102 Call pyglet.app.run() at the end of init
102- callback : function
103+ callback
103104 A function which can be called periodically to
104105 update things in the scene
105- callback_period : float
106+ callback_period
106107 How often to call the callback, in seconds
107- fixed : None or iterable
108+ caption
109+ Caption for the window title
110+ fixed
108111 List of keys in scene.geometry to skip view
109112 transform on to keep fixed relative to camera
110- offset_lines : bool
113+ offset_lines
111114 If True, will offset lines slightly so if drawn
112115 coplanar with mesh geometry they will be visible
113- background : None or (4,) uint8
116+ line_settings
117+ Override default line width and point size with keys
118+ 'line_width' and 'point_size' in pixels
119+ background
114120 Color for background
115- window_conf : None, or gl.Config
121+ window_conf
116122 Passed to window init
117- profile : bool
123+ profile
118124 If set will run a `pyinstrument` profile for
119125 every call to `on_draw` and print the output.
120- record : bool
126+ record
121127 If True, will save a list of `png` bytes to
122128 a list located in `scene.metadata['recording']`
123- kwargs : dict
129+ kwargs
124130 Additional arguments to pass, including
125131 'background' for to set background color
126132 """
@@ -180,6 +186,9 @@ def __init__(
180186 else :
181187 scene .camera .resolution = resolution
182188
189+ if caption is None :
190+ caption = "Trimesh SceneViewer (`h` for help)"
191+
183192 # set the default line settings to a fraction
184193 # of our resolution so the points aren't tiny
185194 scale = max (resolution )
@@ -238,9 +247,6 @@ def __init__(
238247 self .reset_view (flags = flags )
239248 self .update_flags ()
240249
241- if print_help :
242- print (_HELP_MESSAGE )
243-
244250 # someone has passed a callback to be called periodically
245251 if self .callback is not None :
246252 # if no callback period is specified set it to default
@@ -700,6 +706,8 @@ def on_key_press(self, symbol, modifiers):
700706 self .maximize ()
701707 elif symbol == pyglet .window .key .F :
702708 self .toggle_fullscreen ()
709+ elif symbol == pyglet .window .key .H :
710+ print (_HELP_MESSAGE )
703711
704712 if symbol in [
705713 pyglet .window .key .LEFT ,
0 commit comments