java.lang.Object
com.j3d.engine.interact.cmd.commands.transform.handles.Handle

public class Handle extends Object
Represents a single, interactive 3D handle (gizmo) used for manipulating objects in the scene.

A handle is a visual component (e.g., an arrow or a cube) that the user can click and drag to perform a transformation (like translate, rotate, or scale) along a specific axis. This class encapsulates the handle's 3D position, its type (axis), its selection state, and the logic required to draw it on the screen.

Author:
Lehlogonolo Poole
See Also:
  • Field Details

  • Constructor Details

    • Handle

      public Handle(HandleType handleType, Vector3 position, BiConsumer<Graphics2D,ScreenPoint> draw)
      Constructs a new Handle.
      Parameters:
      handleType - The type or axis of this handle (X, Y, or Z).
      position - The initial 3D position of the handle in world space.
      draw - A BiConsumer containing the logic to draw the handle's shape on the screen, given a Graphics2D context and a 2D ScreenPoint.
  • Method Details

    • extraDetail

      public Handle extraDetail(Consumer<Graphics2D> extraDetail)
      Sets an optional drawing function for rendering extra details when the handle is selected.
      Parameters:
      extraDetail - A Consumer to draw additional visual feedback.
      Returns:
      This Handle instance for method chaining.
    • extraDetailRegardless

      public Handle extraDetailRegardless(Consumer<Graphics2D> extraDetail)
    • clear

      public void clear()
    • draw

      public Handle draw(Graphics2D g)
      Renders the handle on the screen.

      This method projects the handle's 3D position to a 2D screen point and executes the drawing logic. If the handle is selected, it also renders its name and any extra details.

      Parameters:
      g - The Graphics2D context to draw on.
      Returns:
      This Handle instance.
    • toSp

      public ScreenPoint toSp()
      Converts the handle's 3D world position to a 2D screen position.
      Returns:
      The calculated ScreenPoint.
    • handleType

      public HandleType handleType()
      Returns the type (axis) of this handle.
      Returns:
      The HandleType.
    • setPos

      public void setPos(Vector3 newPos)
      Updates the 3D position of the handle.
      Parameters:
      newPos - The new position Vector3 in world space.
    • unselect

      public void unselect()
      Marks the handle as not selected.
    • selected

      public void selected()
      Marks the handle as selected.
    • getPos

      public Vector3 getPos()
      Gets the current 3D position of the handle.
      Returns:
      The position Vector3.