cduss Claude Opus 4.5 commited on
Commit
dc426da
·
1 Parent(s): 1edf14b

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>

Files changed (1) hide show
  1. 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">Left</span>
729
- <span class="joystick-label right">Right</span>
730
  </div>
731
  <div class="roll-control">
732
- <span class="roll-label">Roll +</span>
733
- <input type="range" class="roll-slider" id="rollJoystick" min="-100" max="100" value="0">
734
- <span class="roll-label">Roll -</span>
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
- rollSlider.addEventListener('mouseup', () => { rollSlider.value = 0; });
1224
- rollSlider.addEventListener('touchend', () => { rollSlider.value = 0; });
 
1225
  }
1226
 
1227
  function startContinuousMovement() {
@@ -1231,15 +1231,16 @@
1231
  if (!joystickActive) return;
1232
 
1233
  const speed = 1.5; // degrees per tick
1234
- const rollSlider = document.getElementById('rollJoystick');
1235
- const rollInput = parseFloat(rollSlider.value) / 100;
1236
 
1237
  // Joystick mapping:
1238
- // Left/Right (X) controls Yaw: right = turn head right (negative yaw)
1239
- // Up/Down (Y) controls Pitch: up = look up (negative pitch in this coord system)
1240
- targetYaw += -joystickX * speed;
1241
- targetPitch += joystickY * speed; // Fixed: up (neg Y) → neg pitch → look up
1242
- targetRoll += rollInput * speed;
 
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));