mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-12 23:14:58 +00:00
add deadzones to dual sticks
This commit is contained in:
parent
2d3cfccf9b
commit
d9a23cade3
22 changed files with 32 additions and 26 deletions
|
|
@ -7,6 +7,8 @@ import { useControls } from "./SettingsProvider";
|
|||
const BASE_SPEED = 80;
|
||||
const LOOK_SENSITIVITY = 0.004;
|
||||
const STICK_LOOK_SENSITIVITY = 2.5;
|
||||
const DUAL_MOVE_DEADZONE = 0.1;
|
||||
const DUAL_LOOK_DEADZONE = 0.2;
|
||||
const SINGLE_STICK_DEADZONE = 0.15;
|
||||
const MAX_PITCH = Math.PI / 2 - 0.01; // ~89°
|
||||
|
||||
|
|
@ -240,13 +242,15 @@ export function TouchCameraMovement({
|
|||
if (touchMode === "dualStick") {
|
||||
// Right stick → camera rotation
|
||||
const look = lookJoystickState.current;
|
||||
if (look.force > 0) {
|
||||
if (look.force > DUAL_LOOK_DEADZONE) {
|
||||
const lookForce =
|
||||
(look.force - DUAL_LOOK_DEADZONE) / (1 - DUAL_LOOK_DEADZONE);
|
||||
const lookX = Math.cos(look.angle);
|
||||
const lookY = Math.sin(look.angle);
|
||||
|
||||
euler.current.setFromQuaternion(camera.quaternion, "YXZ");
|
||||
euler.current.y -= lookX * look.force * STICK_LOOK_SENSITIVITY * delta;
|
||||
euler.current.x += lookY * look.force * STICK_LOOK_SENSITIVITY * delta;
|
||||
euler.current.y -= lookX * lookForce * STICK_LOOK_SENSITIVITY * delta;
|
||||
euler.current.x += lookY * lookForce * STICK_LOOK_SENSITIVITY * delta;
|
||||
euler.current.x = Math.max(
|
||||
-MAX_PITCH,
|
||||
Math.min(MAX_PITCH, euler.current.x),
|
||||
|
|
@ -255,8 +259,10 @@ export function TouchCameraMovement({
|
|||
}
|
||||
|
||||
// Left stick → movement
|
||||
if (force > 0) {
|
||||
const speed = BASE_SPEED * speedMultiplier * force;
|
||||
if (force > DUAL_MOVE_DEADZONE) {
|
||||
const moveForce =
|
||||
(force - DUAL_MOVE_DEADZONE) / (1 - DUAL_MOVE_DEADZONE);
|
||||
const speed = BASE_SPEED * speedMultiplier * moveForce;
|
||||
const joyX = Math.cos(angle);
|
||||
const joyY = Math.sin(angle);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue