Skip to content

Commit b71692c

Browse files
committed
add a help message to SceneViewer
1 parent 67acf0a commit b71692c

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

README.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ print(mesh.bounding_box_oriented.volume,
127127
* Import meshes from binary/ASCII STL, Wavefront OBJ, ASCII OFF, binary/ASCII PLY, GLTF/GLB 2.0, 3MF, XAML, 3DXML, etc.
128128
* Export meshes as GLB/GLTF, binary STL, binary PLY, ASCII OFF, OBJ, COLLADA, etc.
129129
* Import and export 2D or 3D vector paths with DXF or SVG files
130-
* Preview meshes using an OpenGL `pyglet` window, or in-line in jupyter/marimo notebooks using three.js
130+
* Preview meshes using an OpenGL `pyglet` window, or in-line in jupyter or marimo notebooks using `three.js`
131131
* Automatic hashing from a subclassed numpy array for change tracking using MD5, zlib CRC, or xxhash, and internal caching of expensive values.
132132
* Calculate face adjacencies, face angles, vertex defects, convex hulls, etc.
133133
* Calculate cross sections for a 2D outline, or slice a mesh for a 3D remainder mesh, i.e. slicing for 3D-printing.
@@ -148,32 +148,9 @@ print(mesh.bounding_box_oriented.volume,
148148
* Simple scene graph and transform tree which can be rendered (pyglet window, three.js in a jupyter/marimo notebook or exported.
149149
* Many utility functions, like transforming points, unitizing vectors, aligning vectors, tracking numpy arrays for changes, grouping rows, etc.
150150

151-
152-
## Viewer
153-
154-
Trimesh includes an optional `pyglet<2` based viewer for debugging and inspecting. In the mesh view window, opened with `mesh.show()`, the following commands can be used:
155-
156-
* `mouse click + drag` rotates the view
157-
* `ctl + mouse click + drag` pans the view
158-
* `mouse wheel` zooms
159-
* `z` returns to the base view
160-
* `w` toggles wireframe mode
161-
* `c` toggles backface culling
162-
* `g` toggles an XY grid with Z set to lowest point
163-
* `a` toggles an XYZ-RGB axis marker between: off, at world frame, or at every frame and world, and at every frame
164-
* `f` toggles between fullscreen and windowed mode
165-
* `m` maximizes the window
166-
* `q` closes the window
167-
168-
If called from inside a `jupyter` or `marimo` notebook, `mesh.show()` displays an in-line preview using `three.js` to display the mesh or scene.
169-
170151
## Additional Notes
171152

172153
- Check out some cool stuff people have done in the [GitHub network](https://github.com/mikedh/trimesh/network/dependents).
173154
- Generally `trimesh` API changes should have a one-year period of [printing a `warnings.DeprecationWarning`](https://trimesh.org/contributing.html#deprecations) although that's not always possible (i.e. the pyglet2 viewer rewrite that's been back-burnered for several years.)
174155
- Docker containers are available on Docker Hub as [`trimesh/trimesh`](https://hub.docker.com/r/trimesh/trimesh/tags) and there's a [container guide](https://trimesh.org/docker.html) in the docs.
175156
- If you're choosing which format to use, you may want to try [GLB](https://trimesh.org/formats.html) as a fast modern option.
176-
177-
178-
179-

trimesh/viewer/windowed.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,27 @@
2929

3030
import pyglet.gl as gl # NOQA
3131

32-
# smooth only when fewer faces than this
33-
_SMOOTH_MAX_FACES = 100000
32+
# help message for the viewer
33+
_HELP_MESSAGE = """
34+
# SceneViewer Controls
35+
36+
| Input | Action |
37+
|----------------------------|-----------------------------------------------|
38+
| `mouse click + drag` | Rotates the view |
39+
| `ctl + mouse click + drag` | Pans the view |
40+
| `mouse wheel` | Zooms the view |
41+
| `z` | Resets to the initial view |
42+
| `w` | Toggles wireframe mode |
43+
| `c` | Toggles backface culling |
44+
| `g` | Toggles an XY grid with Z set to lowest point |
45+
| `a` | Toggles an XYZ-RGB axis marker between: off, |
46+
| | at world frame, or at every frame and world, |
47+
| | and at every frame |
48+
| `f` | Toggles between fullscreen and windowed mode |
49+
| `m` | Maximizes the window |
50+
| `q` | Closes the window |
51+
|----------------------------|-----------------------------------------------|
52+
"""
3453

3554

3655
class SceneViewer(pyglet.window.Window):
@@ -54,6 +73,7 @@ def __init__(
5473
window_conf=None,
5574
profile=False,
5675
record=False,
76+
print_help: bool = False,
5777
**kwargs,
5878
):
5979
"""
@@ -218,6 +238,9 @@ def __init__(
218238
self.reset_view(flags=flags)
219239
self.update_flags()
220240

241+
if print_help:
242+
print(_HELP_MESSAGE)
243+
221244
# someone has passed a callback to be called periodically
222245
if self.callback is not None:
223246
# if no callback period is specified set it to default

0 commit comments

Comments
 (0)