Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'roll' controls and custom 'up' vector support #45

Merged
merged 13 commits into from
Feb 10, 2024
Merged

Add 'roll' controls and custom 'up' vector support #45

merged 13 commits into from
Feb 10, 2024

Conversation

Plonq
Copy link
Owner

@Plonq Plonq commented Feb 10, 2024

closes #41

Adds the ability to control the 3rd rotational axis (roll), in addition to yaw/tilt (alpha/beta). Adding the 3rd axis can make things weird, in that it changes what the camera treats as 'up' (the up vector). And once the up vector has changed, it's practically impossible to reset it back to default with just the camera controls. You have to reset it programmatically. For this reason, roll is disabled by default in both mouse/kb controls and touch controls.
Also, the concept of being 'upside down' makes no sense when you can change what 'up' means, and so allow_upside_down should typically be set to true when enabling roll or changing the up vector.

The roll control is implemented by introducing a 'base transform' upon which all other transformations are applied. By default, when roll is disabled, this base transform is identical to the world transform, i.e. Transform::IDENTITY. Changing the rotation of the base transform changes the 'up' vector. Changing the translation of it is not supported but theoretically it will effectively just change what 'zero pan' means, so isn't that useful. (Transform is used instead of a rotation like Quat or Mat3 because it provides useful methods.)

This PR also introduces a touch_enabled property which can be used to disable touch controls entirely (it's true by default). Disabling this may result in slightly better performance, but I haven't tested and I suspect the difference would be negligible in most cases.

  • Add key_roll_left and key_roll_right properties, defaulting to None (i.e. roll disabled)
  • Add touch_enabled and touch_roll_enabled, defaulting to true and false respectively
  • Update touch example to enable roll
  • Update advanced example to enable roll
  • Add alternate_up_vector example
  • Replace apply_limits util function with trait (more rusty!?)
  • Various additions/improvements to comments/docs and minor code cleanup

Roll with keyboard controls:

Screen.Recording.2024-02-10.at.11.43.28.am.mov

Roll with touch controls:

Screen.Recording.2024-02-10.at.4.10.34.pm.mov

@Plonq Plonq changed the title 3rd axis Add 'roll' controls and custom 'up' vector support Feb 10, 2024
@Plonq Plonq merged commit abb913b into master Feb 10, 2024
4 checks passed
@Plonq Plonq deleted the 3rd-axis branch February 10, 2024 07:02
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.

Feature request: changing the UP vector of the camera
1 participant