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
ConstructorsConstructorDescriptionCreates a new world navigation input tracker. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCalled when the component loses keyboard focus.booleanfocusReceived(ViewPanel viewPanel) Called when the component receives keyboard focus.booleankeyPressed(KeyEvent event, ViewPanel viewContext) Called when a key is pressed while the component has focus.booleankeyReleased(KeyEvent event, ViewPanel viewContext) Called when a key is released while the component has focus.booleanCalled before each frame render, allowing the listener to update state and indicate whether a repaint is needed.
-
Constructor Details
-
WorldNavigationUserInputTracker
public WorldNavigationUserInputTracker()Creates a new world navigation input tracker.
-
-
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
Description copied from interface:KeyboardInputHandlerCalled when the component loses keyboard focus.- Specified by:
focusLostin interfaceKeyboardInputHandler- Parameters:
viewPanel- the view panel that owns this handler- Returns:
trueif view needs to be re-rendered
-
focusReceived
Description copied from interface:KeyboardInputHandlerCalled when the component receives keyboard focus.- Specified by:
focusReceivedin interfaceKeyboardInputHandler- Parameters:
viewPanel- the view panel that owns this handler- Returns:
trueif view needs to be re-rendered
-
keyPressed
Description copied from interface:KeyboardInputHandlerCalled when a key is pressed while the component has focus.- Specified by:
keyPressedin interfaceKeyboardInputHandler- Parameters:
event- the key eventviewContext- the view panel that owns this handler- Returns:
trueif view needs to be re-rendered
-
keyReleased
Description copied from interface:KeyboardInputHandlerCalled when a key is released while the component has focus.- Specified by:
keyReleasedin interfaceKeyboardInputHandler- Parameters:
event- the key eventviewContext- the view panel that owns this handler- Returns:
trueif view needs to be re-rendered
-