Skip to content

[FEATURE] Better touch rotation for perspective projection#1688

Open
Kurtil wants to merge 1 commit intoxeokit:masterfrom
Kurtil:patch-22
Open

[FEATURE] Better touch rotation for perspective projection#1688
Kurtil wants to merge 1 commit intoxeokit:masterfrom
Kurtil:patch-22

Conversation

@Kurtil
Copy link
Contributor

@Kurtil Kurtil commented Oct 4, 2024

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 and rotateDeltaX are computed. The new computation is based on the x and y axis fov 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 value 360. I did not change this default value of 360 and it is handled in the new code, when divided by 360 when computing dx and dy.

NB: touch rotation is changed in this PR for perspective projection ONLY. For the other projections, the behavior is kept the same as before.

@ijlal99 ijlal99 requested a review from xeolabs November 19, 2024 21:15
@xeolabs
Copy link
Member

xeolabs commented Dec 3, 2024

@Kurtil Sorry for the delay getting to this PR!

One thing I'd like to change, if agreeable to you - can we introduce a new flag (with getter/setter) on CameraControl called smartDragRotate, set true by default. When true, that would enable the new drag rotation behaviour of this PR. Then dragRotationRate can have whatever value, while the flag controls the mode.

I think this would be fine for users to get by default!

@Kurtil
Copy link
Contributor Author

Kurtil commented Dec 3, 2024

Ok ! I will do that soon.

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.

2 participants