Skip to content

Commit

Permalink
shift the center of the control in z direction by 1
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Oct 8, 2024
1 parent c697d27 commit 08b4235
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aiidalab_widgets_base/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,14 @@ def _observe_displayed_structure(self, change):
self._viewer.add_unitcell()
self._viewer._add_shape(set(bonds), name="bonds")
self._viewer.center()
# In case of a single atom, the `_viewer.center` method will show a black sphere.
if len(self.displayed_structure) == 1:
# get center of mass of the displayed structure
com = self.displayed_structure.get_center_of_mass()
# The default camera should be in the z direction, so we
# shift the center of the control in z direction by 1
com[2] -= 1
self._viewer.control.center(com)

self.displayed_selection = []

Expand Down

0 comments on commit 08b4235

Please sign in to comment.