Add 'roll' controls and custom 'up' vector support #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 totrue
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.key_roll_left
andkey_roll_right
properties, defaulting toNone
(i.e. roll disabled)touch_enabled
andtouch_roll_enabled
, defaulting totrue
andfalse
respectivelyalternate_up_vector
exampleapply_limits
util function with trait (more rusty!?)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