Skip to content

Commit

Permalink
Viewer.add_mesh: pass through pygfx.Mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed May 12, 2024
1 parent b90a8f5 commit e9b0614
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions octarine/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,9 @@ def add_mesh(self, mesh, name=None, color=None, alpha=None, center=True):
Parameters
----------
mesh : Mesh-like
Mesh to plot.
Mesh to plot. If this is a pygfx.Mesh, it will be added
directly to the scene without modification (i.e. `color`,
`alpha`, etc. will be ignored).
name : str, optional
Name for the visual.
color : str | tuple, optional
Expand All @@ -849,7 +851,11 @@ def add_mesh(self, mesh, name=None, color=None, alpha=None, center=True):
elif not isinstance(name, str):
name = str(name)

visual = mesh2gfx(mesh, color=color, alpha=alpha)
if not isinstance(mesh, gfx.Mesh):
visual = mesh2gfx(mesh, color=color, alpha=alpha)
else:
visual = mesh

visual._object_id = name if name else uuid.uuid4()

self._add_to_scene(visual, center)
Expand Down

0 comments on commit e9b0614

Please sign in to comment.