Spaces:
Running
Running
Change joystick to control pitch and roll
Browse files- Joystick X axis: Roll (tilt head left/right)
- Joystick Y axis: Pitch (look up/down)
- Vertical slider: Yaw (turn head left/right)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- index.html +16 -15
index.html
CHANGED
|
@@ -725,13 +725,13 @@
|
|
| 725 |
<div class="joystick-knob" id="joystickKnob"></div>
|
| 726 |
<span class="joystick-label top">Up</span>
|
| 727 |
<span class="joystick-label bottom">Down</span>
|
| 728 |
-
<span class="joystick-label left">
|
| 729 |
-
<span class="joystick-label right">
|
| 730 |
</div>
|
| 731 |
<div class="roll-control">
|
| 732 |
-
<span class="roll-label">
|
| 733 |
-
<input type="range" class="roll-slider" id="
|
| 734 |
-
<span class="roll-label">
|
| 735 |
</div>
|
| 736 |
</div>
|
| 737 |
<div class="joystick-hint">Hold and drag to move head continuously</div>
|
|
@@ -1156,7 +1156,6 @@
|
|
| 1156 |
function initJoystick() {
|
| 1157 |
const joystick = document.getElementById('joystick');
|
| 1158 |
const knob = document.getElementById('joystickKnob');
|
| 1159 |
-
const rollSlider = document.getElementById('rollJoystick');
|
| 1160 |
|
| 1161 |
function getPosition(e) {
|
| 1162 |
const rect = joystick.getBoundingClientRect();
|
|
@@ -1220,8 +1219,9 @@
|
|
| 1220 |
document.addEventListener('mouseup', endJoystick);
|
| 1221 |
document.addEventListener('touchend', endJoystick);
|
| 1222 |
|
| 1223 |
-
|
| 1224 |
-
|
|
|
|
| 1225 |
}
|
| 1226 |
|
| 1227 |
function startContinuousMovement() {
|
|
@@ -1231,15 +1231,16 @@
|
|
| 1231 |
if (!joystickActive) return;
|
| 1232 |
|
| 1233 |
const speed = 1.5; // degrees per tick
|
| 1234 |
-
const
|
| 1235 |
-
const
|
| 1236 |
|
| 1237 |
// Joystick mapping:
|
| 1238 |
-
// Left/Right (X) controls
|
| 1239 |
-
// Up/Down (Y) controls Pitch: up = look up (negative pitch
|
| 1240 |
-
|
| 1241 |
-
|
| 1242 |
-
|
|
|
|
| 1243 |
|
| 1244 |
// Clamp to limits
|
| 1245 |
targetYaw = Math.max(-45, Math.min(45, targetYaw));
|
|
|
|
| 725 |
<div class="joystick-knob" id="joystickKnob"></div>
|
| 726 |
<span class="joystick-label top">Up</span>
|
| 727 |
<span class="joystick-label bottom">Down</span>
|
| 728 |
+
<span class="joystick-label left">Tilt L</span>
|
| 729 |
+
<span class="joystick-label right">Tilt R</span>
|
| 730 |
</div>
|
| 731 |
<div class="roll-control">
|
| 732 |
+
<span class="roll-label">Turn L</span>
|
| 733 |
+
<input type="range" class="roll-slider" id="yawSlider" min="-100" max="100" value="0">
|
| 734 |
+
<span class="roll-label">Turn R</span>
|
| 735 |
</div>
|
| 736 |
</div>
|
| 737 |
<div class="joystick-hint">Hold and drag to move head continuously</div>
|
|
|
|
| 1156 |
function initJoystick() {
|
| 1157 |
const joystick = document.getElementById('joystick');
|
| 1158 |
const knob = document.getElementById('joystickKnob');
|
|
|
|
| 1159 |
|
| 1160 |
function getPosition(e) {
|
| 1161 |
const rect = joystick.getBoundingClientRect();
|
|
|
|
| 1219 |
document.addEventListener('mouseup', endJoystick);
|
| 1220 |
document.addEventListener('touchend', endJoystick);
|
| 1221 |
|
| 1222 |
+
const yawSlider = document.getElementById('yawSlider');
|
| 1223 |
+
yawSlider.addEventListener('mouseup', () => { yawSlider.value = 0; });
|
| 1224 |
+
yawSlider.addEventListener('touchend', () => { yawSlider.value = 0; });
|
| 1225 |
}
|
| 1226 |
|
| 1227 |
function startContinuousMovement() {
|
|
|
|
| 1231 |
if (!joystickActive) return;
|
| 1232 |
|
| 1233 |
const speed = 1.5; // degrees per tick
|
| 1234 |
+
const yawSlider = document.getElementById('yawSlider');
|
| 1235 |
+
const yawInput = parseFloat(yawSlider.value) / 100;
|
| 1236 |
|
| 1237 |
// Joystick mapping:
|
| 1238 |
+
// Left/Right (X) controls Roll: right = tilt head right (positive roll)
|
| 1239 |
+
// Up/Down (Y) controls Pitch: up = look up (negative pitch)
|
| 1240 |
+
// Slider controls Yaw: left = turn left (positive yaw)
|
| 1241 |
+
targetRoll += joystickX * speed;
|
| 1242 |
+
targetPitch += joystickY * speed;
|
| 1243 |
+
targetYaw += -yawInput * speed;
|
| 1244 |
|
| 1245 |
// Clamp to limits
|
| 1246 |
targetYaw = Math.max(-45, Math.min(45, targetYaw));
|