[FEATURE] Better touch rotation for perspective projection #1688
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.
Touch rotation is currently bound to magic numbers (1 for full horizontal rotation and 1.5 for half vertical rotation).
This PR change the way
rotateDeltaY
androtateDeltaX
are computed. The new computation is based on thex
andy
axisfov
and the canvas aspect ratio. Doing so, the touch rotation in perspective projection behaves more like what is it done on other viewers like Autodesk, Catenda and Dalux (it is possible to test with free demo data on the last one).The rotation behavior is described as follows:
CorrectTouchRotation.mov
(video recorded using the mouse but the code is for touch handler ONLY)
When you touch a specific area on the model and then rotate, the finger stays above the previously touched area. The touched area follows the finger (minus some perspective distortion on the canvas edges).
To prevent breaking changes and still get the expected behaviour, the
configs.dragRotationRate
must be set to-360
, the opposite as the default value360
. I did not change this default value of360
and it is handled in the new code, when divided by360
when computingdx
anddy
.NB: touch rotation is changed in this PR for perspective projection ONLY. For the other projections, the behavior is kept the same as before.