pmndrs/leva

Add joystick to Vector3d

Opened this issue · 8 comments

s4l4x commented

I love the joystick and would love to use it to set a Vector 3d. One way it could work is if we allow the user to set the vector plane by plane and let them quickly change between planes.

Tap the joystick to show the existing 2d joystick applied to a plane. Tap a button to switch planes, or use modifier keys, to quickly switch between them. As an added bonus the joystick grid could rotate to the new plane when switching.

Thoughts?

image

s4l4x commented

I'm not sure of the following:

  • which plane should be the default
  • how to indicate that the other planes can be easily accessed via modifier keys (using the current text and button styles)

beautiful!

s4l4x commented

Draft PR here: #433

I added the 2d Joystick to the Vector3d and it can control an arbitrary pair of dimensions. Next up:

  • Control the dimension pair aka plane with the keyboard
  • Add buttons for the planes
s4l4x commented

Currently looks like this:
image

Next issues:

  • Dragging to the edge "upsets" the values
  • Draw the Joystick buttons below
s4l4x commented

Currently looks like this:
image

Next up:

  • Add dimensionality to the joystick
s4l4x commented
  • Added hotkey labels to the buttons
  • Changed zx to xz so that moving the mouse in x changed the value in x (and not z)
  • Changed the hotkeys to Control and Meta to allow for the simultaneous use of the precision modifier
  • Reordered the buttons to physically match the keyboard
    image
s4l4x commented
  • Added some depth and animation 😇
  • Changed YZ to ZY to shat moving the mouse in y changed the value of y (and not z)
Screen.Recording.2023-01-26.at.18.36.27.mov
s4l4x commented
  • I added comments in the code where I could use help. I'm sure there's more.
  • I also just remembered I'm getting an error in the console regarding validateDOMNesting(...): <button> cannot appear as a descendant of <button>. In effect I'm using buttons, but I'm not really using them as buttons.
  • I'm also wondering how this would work on touch devices (probably more like buttons ;)