Class WorldNavigationUserInputTracker

java.lang.Object
eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationUserInputTracker
All Implemented Interfaces:
FrameListener, KeyboardInputHandler

public class WorldNavigationUserInputTracker extends Object implements KeyboardInputHandler, FrameListener
Default keyboard input handler that translates arrow key presses into camera (avatar) movement through the 3D world.

This handler is automatically registered as the default focus owner in the KeyboardFocusStack. It listens for arrow key presses on each frame and applies acceleration to the avatar's movement vector accordingly:

  • Up arrow - move forward (positive Z)
  • Down arrow - move backward (negative Z)
  • Right arrow - move right (positive X)
  • Left arrow - move left (negative X)

Movement acceleration scales with the time delta between frames for smooth, frame-rate-independent navigation. It also scales with current speed for a natural acceleration curve.

See Also:
  • Constructor Details

    • WorldNavigationUserInputTracker

      public WorldNavigationUserInputTracker()
  • Method Details

    • onFrame

      public boolean onFrame(ViewPanel viewPanel, int millisecondsSinceLastFrame)
      Description copied from interface: FrameListener
      Called before each frame render, allowing the listener to update state and indicate whether a repaint is needed.

      Each registered listener is called exactly once per frame tick. The frame is only rendered if at least one listener returns true (or if the view was explicitly marked for repaint).

      Specified by:
      onFrame in interface FrameListener
      Parameters:
      viewPanel - the view panel being rendered
      millisecondsSinceLastFrame - time elapsed since the previous frame, for frame-rate-independent updates
      Returns:
      true if the view should be re-rendered this frame, false if this listener has no visual changes
    • focusLost

      public boolean focusLost(ViewPanel viewPanel)
      Specified by:
      focusLost in interface KeyboardInputHandler
      Returns:
      true if view needs to be re-rendered.
    • focusReceived

      public boolean focusReceived(ViewPanel viewPanel)
      Specified by:
      focusReceived in interface KeyboardInputHandler
      Returns:
      true if view needs to be re-rendered.
    • keyPressed

      public boolean keyPressed(KeyEvent event, ViewPanel viewContext)
      Specified by:
      keyPressed in interface KeyboardInputHandler
      Returns:
      true if view needs to be re-rendered.
    • keyReleased

      public boolean keyReleased(KeyEvent event, ViewPanel viewContext)
      Specified by:
      keyReleased in interface KeyboardInputHandler
      Returns:
      true if view needs to be re-rendered.