Skip to content

Move and rotate the selection with gizmo handles - #37

Open
prihoda wants to merge 1 commit into
RosettaCommons:mainfrom
prihoda:move-rotate-selection
Open

prihoda wants to merge 1 commit into
RosettaCommons:mainfrom
prihoda:move-rotate-selection

Conversation

@prihoda

@prihoda prihoda commented Nov 27, 2026 •

Copy link
Copy Markdown

Hi all,

this PR implements a move and rotate gizmo per issue #38

Screenshot:

image

I also have a version that works fully in the browser in combination with the web-based RFD4 generation as in https://web.rfd4-proteina.org/ (I wasn't able to find the source code but I made it work locally with the js bundles). I can provide more details if needed.

Claude's description of the PR:

Three arrows (move) or three rings (rotate) drawn in the Mol* scene, picked with Mol*'s own object picking, with the camera's drag bindings suspended while a handle is held.

An arrow follows the closest point between the pointer ray and its axis; a ring turns by the angle swept around the gizmo's projected centre, signed by which side of the rotation plane the camera is on.

Move and Rotate sit at the start of the selection popover's action row, so Apply stays where it was. Dragging previews the motion by redrawing the document with only the selected atoms moved (moveCif now takes an atom selector), and Apply commits it as one undoable edit before the popover's condition edits. Closing the popover, or picking a different selection, drops the handles and puts the document back.

The commit is a document mutation, POST /sessions/{id}/transform, so Undo, validation and the changed notification behave as they do for any other edit:

rigid_transform rotates about a pivot -- the selection's own centroid unless
one is given -- and then translates. Atoms without coordinates keep their NaN
rather than being given an invented position, and a transform that moves
nothing is not an edit, so Undo gains no empty step.

Saved absolute-coordinate conditioning moves with the atoms. A model builds from those stored positions, not from the CIF's columns, so moving one without the other left the structure and its conditioning in different places and a design came back where the atoms used to be -- visible only after generating, since the file looks correct every time it is opened. Internal coordinates and rigid-body shapes are relative and stay correct under a rigid motion, so they are deliberately left alone; a chain's centroid target covers a whole chain a selection may only partly cover, so it is left for the user to re-set.

The handles are Mol*-only for now (capabilities.transformGizmo), as they are drawn with its shape representation; Patinae reports false and the controls do not appear.

Ported from the molstar-editor gizmos: three arrows (move) or three rings
(rotate) drawn in the Mol* scene, picked with Mol*'s own object picking, with
the camera's drag bindings suspended while a handle is held. An arrow follows
the closest point between the pointer ray and its axis; a ring turns by the
angle swept around the gizmo's projected centre, signed by which side of the
rotation plane the camera is on.

Move and Rotate sit at the start of the selection popover's action row, so Apply
stays where it was. Dragging previews the motion by redrawing the document with
only the selected atoms moved (moveCif now takes an atom selector), and Apply
commits it as one undoable edit before the popover's condition edits. Closing
the popover, or picking a different selection, drops the handles and puts the
document back.

The commit is a document mutation, POST /sessions/{id}/transform, so Undo,
validation and the changed notification behave as they do for any other edit:

  rigid_transform rotates about a pivot -- the selection's own centroid unless
  one is given -- and then translates. Atoms without coordinates keep their NaN
  rather than being given an invented position, and a transform that moves
  nothing is not an edit, so Undo gains no empty step.

Saved absolute-coordinate conditioning moves with the atoms. A model builds
from those stored positions, not from the CIF's columns, so moving one without
the other left the structure and its conditioning in different places and a
design came back where the atoms used to be -- visible only after generating,
since the file looks correct every time it is opened. Internal coordinates and
rigid-body shapes are relative and stay correct under a rigid motion, so they
are deliberately left alone; a chain's centroid target covers a whole chain a
selection may only partly cover, so it is left for the user to re-set.

The handles are Mol*-only for now (capabilities.transformGizmo), as they are
drawn with its shape representation; Patinae reports false and the controls do
not appear.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant