Skip to content

Separate polar / azimuth rotation actions (mouse + touch)#633

Open
codedpalette wants to merge 6 commits into
yomotsu:devfrom
expofp:separate-rotation
Open

Separate polar / azimuth rotation actions (mouse + touch)#633
codedpalette wants to merge 6 commits into
yomotsu:devfrom
expofp:separate-rotation

Conversation

@codedpalette

Copy link
Copy Markdown

Fixes #618

Summary

Adds four new actions that let a binding drive a single rotation axis:

  • ACTION.ROTATE_AZIMUTH / ACTION.ROTATE_POLAR (mouse)
  • ACTION.TOUCH_ROTATE_AZIMUTH / ACTION.TOUCH_ROTATE_POLAR (touch)

Setting the existing ACTION.ROTATE / ACTION.TOUCH_ROTATE still enables both
axes — because they're now defined as the composite of the two new primitives:

ROTATE       = ROTATE_AZIMUTH       | ROTATE_POLAR
TOUCH_ROTATE = TOUCH_ROTATE_AZIMUTH | TOUCH_ROTATE_POLAR

Works for mouse buttons, mouse wheel, and single-finger touch.

Motivation

Previously rotation was all-or-nothing per binding; the only way to lock an axis
was to zero azimuthRotateSpeed/polarRotateSpeed globally. These actions make
axis restriction a per-binding choice (e.g. left-drag = azimuth only).

What changed

  • ACTION is now composable. Each capability owns one primitive bit, and every
    existing named action is a bitwise-OR of primitives (e.g.
    TOUCH_DOLLY_ROTATE = TOUCH_DOLLY | TOUCH_ROTATE). No combined action needs its
    own dedicated bit anymore.
  • Pointer/wheel dispatch tests primitive bits (state & PRIMITIVE) instead of
    exact-matching whole composites, so single-axis actions fire correctly and
    combined touch gestures decompose cleanly.
  • _rotateInternal gates each axis by the rotate bits present in the current
    state (azimuth from deltaX, polar from deltaY).
  • Docs + example: README and JSDoc config tables list the new constants;
    examples/config.html exposes them in every mouse/touch picker.

Bug fix (bonus)

The collapse fixes a latent bug in the drag-start handler where
TOUCH_ZOOM_SCREEN_PAN was compared against TOUCH_DOLLY_SCREEN_PAN (mismatched
constants), so two-finger zoom+screen-pan never reset target movement on drag start.

Backward compatibility

All existing ACTION member names are retained. Their numeric values
change
(the enum was re-laid-out around primitives), so code that persisted raw
numeric action values rather than referencing CameraControls.ACTION.* would need
updating. Behavior of all existing bindings is unchanged.

Verification

This repo has no unit-test suite; verified via:

  • npx tsc --noEmit — clean
  • eslint src — clean
  • npm run build — succeeds; bundle exports the new actions
  • Behavioral test in examples/config.html (mouse + touch): ROTATE moves both
    axes; ROTATE_AZIMUTH moves azimuth only (polar unchanged); ROTATE_POLAR
    moves polar only (azimuth unchanged). Existing composite actions like TOUCH_DOLLY_ROTATE still work as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate actions for ROTATE_POLAR/ROTATE_AZIMUTH

1 participant