mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-02-18 06:03:50 +00:00
make joystick use camera pitch
This commit is contained in:
parent
f814d71c53
commit
40724a49e6
22 changed files with 28 additions and 27 deletions
|
|
@ -163,19 +163,20 @@ export function TouchCameraMovement({
|
|||
const joyX = Math.cos(angle); // right component
|
||||
const joyY = Math.sin(angle); // forward component
|
||||
|
||||
// Get camera forward projected onto XZ ground plane
|
||||
// Forward/backward: use full camera direction (including Y) so
|
||||
// looking up and pushing forward moves upward, like ObserverControls.
|
||||
camera.getWorldDirection(forwardVec.current);
|
||||
forwardVec.current.y = 0;
|
||||
forwardVec.current.normalize();
|
||||
|
||||
// Get camera right vector on XZ plane
|
||||
sideVec.current.crossVectors(forwardVec.current, camera.up).normalize();
|
||||
// Left/right: move along XZ plane
|
||||
sideVec.current.crossVectors(camera.up, forwardVec.current).normalize();
|
||||
|
||||
// Combine: joyY pushes forward, joyX pushes right
|
||||
// Combine: joyY pushes forward, joyX pushes right.
|
||||
// sideVec points left (up × forward), so negate joyX.
|
||||
moveVec.current
|
||||
.set(0, 0, 0)
|
||||
.addScaledVector(forwardVec.current, joyY)
|
||||
.addScaledVector(sideVec.current, joyX);
|
||||
.addScaledVector(sideVec.current, -joyX);
|
||||
|
||||
if (moveVec.current.lengthSq() > 0) {
|
||||
moveVec.current.normalize().multiplyScalar(speed * delta);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue