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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanfocusReceived(ViewPanel viewPanel) booleankeyPressed(KeyEvent event, ViewPanel viewContext) booleankeyReleased(KeyEvent event, ViewPanel viewContext) booleanCalled before each frame render, allowing the listener to update state and indicate whether a repaint is needed.
-
Constructor Details
-
WorldNavigationUserInputTracker
public WorldNavigationUserInputTracker()
-
-
Method Details
-
onFrame
Description copied from interface:FrameListenerCalled 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:
onFramein interfaceFrameListener- Parameters:
viewPanel- the view panel being renderedmillisecondsSinceLastFrame- time elapsed since the previous frame, for frame-rate-independent updates- Returns:
trueif the view should be re-rendered this frame,falseif this listener has no visual changes
-
focusLost
- Specified by:
focusLostin interfaceKeyboardInputHandler- Returns:
trueif view needs to be re-rendered.
-
focusReceived
- Specified by:
focusReceivedin interfaceKeyboardInputHandler- Returns:
trueif view needs to be re-rendered.
-
keyPressed
- Specified by:
keyPressedin interfaceKeyboardInputHandler- Returns:
trueif view needs to be re-rendered.
-
keyReleased
- Specified by:
keyReleasedin interfaceKeyboardInputHandler- Returns:
trueif view needs to be re-rendered.
-