Skip to content

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

Open
wants to merge 214 commits into
base: main
Choose a base branch
from

Conversation

kpal81xd
Copy link
Contributor

@kpal81xd kpal81xd commented Mar 3, 2025

Overview

This PR aims to split the camera controls down into two core components:

  • Input Sources which represent a collection of deltas generated from one or more input devices. These can range from a mouse movement delta to a gamepad joystick delta.
  • Input Controllers which represent the constrained transformations that are to be performed e.g. orbiting around a particular focus point or camera flying (unconstrained) .

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

… layout parameter and update default layout values
@kpal81xd kpal81xd requested review from Copilot and willeastcott and removed request for willeastcott May 21, 2025 15:14
Copy link
Contributor

@Copilot Copilot AI left a 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; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants