-
Notifications
You must be signed in to change notification settings - Fork 1.4k
CameraControls rework (Input/Controller overhaul) #7398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ut comment from DualTouchSource
… layout parameter and update default layout values
…urce implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the camera controls system by separating input handling into distinct sources (touch, joystick, keyboard/mouse, gamepad) and controllers (fly and orbit), while updating example applications to use the new interface.
- Introduces dedicated classes for various input sources with coordinated delta‐calculation logic.
- Refactors camera controller examples to use updated API properties (e.g. using “cc” instead of “cameraControls”) and integrates joystick-based UI events.
- Updates input controller (FlyController) with damping and smoothing configurations.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/extras/input/sources/virtual-joystick.js | Implements virtual joystick input with delta clamping logic. |
src/extras/input/sources/single-gesture-source.js | Adds support for single-touch/joystick input handling. |
src/extras/input/sources/multi-touch-source.js | Implements multi-touch handling with pinch and pan support. |
src/extras/input/sources/keyboard-mouse-source.js | Defines keyboard and mouse input with custom button state transitions. |
src/extras/input/sources/gamepad-source.js | Provides gamepad input support by reading axes. |
src/extras/input/sources/dual-gesture-source.js | Implements dual gesture input combining two input modes based on screen side. |
src/extras/input/input.js | Defines common input delta and source base classes. |
src/extras/input/controllers/fly-controller.js | Refactors fly controller with damping and smoothing transform logic. |
src/extras/index.js | Updates exports to include the new input and controller modules. |
examples/* | Updates various example files to integrate the refactored camera and input system APIs. |
Comments suppressed due to low confidence (1)
src/extras/input/sources/keyboard-mouse-source.js:154
- [nitpick] Consider adding a comment explaining why a released button state is represented by -1 (as opposed to 0), to clarify the intended semantics of the _button array for future maintainers.
if (this._button[i] === 1) { this._button[i] = -1; continue; }
Overview
This PR aims to split the camera controls down into two core components:
Together the deltas from an Input can be collected into a "frame" of deltas which are then applied to the specified controller to perform the required action.
Input Sources
SingleGestureSource - Single touch or virtual joystick input
DualGestureSource - Split screen touch or virtual joystick input
MultiTouchSource - Multi touch input (includes pinch handling)
KeyboardMouseSource - Keyboard and mouse input
GamepadSource - Game pad input
Input Controllers
FlyController - Applies free-fly mechanics to a base transform
OrbitController - Applies orbiting mechanics to a base transform
Design Doc
https://docs.google.com/document/d/1r2ywuzxbte6DwlEJzWgyD-fTDNyp-7P0PKLFefrgV9Y/edit?usp=sharing