itowns
itowns copied to clipboard
feat(globeControls): zoom on mouse position while using wheel
Description
In globe view, zoom to the cursor position while using mousewheel.
Motivation and Context
Linked issue: https://github.com/iTowns/itowns/issues/2011
From what i understand of this PR, the purpose is that when you zoom in or out, the terrain under the mouse should always stay the same.
I tried this PR on a globe view. I noticed that zooming in on the mouse position seems to work when you are at close range but not at all when you are far enought and the zoom out never stay at the mouse position. I havn't really gone into the code yet, and from my first test, the aim is not achived.
Thanks for the feedback.
I use zoom coordinates interpolated between the mouse position and the camera position that's why we don't go directly to the mouse position. This allows us to have a smoother transition. The behaviour is similar to the globe view of Google Maps. This alpha parameter (interpolation factor) is fixed but depending on feedback, could be edited before release. Concerning the zoom out, the factor is different (dezoom_interp) to avoid brutal rotation while zooming out. Same as alpha, this could be edited before release. I could even make these values as parameters of globecontrols, then the user could decide of the zoom behaviour.
@ftoromanoff @AnthonyGlt @jailln By the way, take a look at this control. It has all useful functions. I've mentioned it here in another discussion.
I think it would be great to integrate it in iTowns. Also for navigation under the ground or in hidden globe mode.
With your PR, the target position doesn't stay under the mouse cursor.
https://user-images.githubusercontent.com/11291849/233647952-99628964-9631-4e0f-8397-aad7f396ccaa.mp4
In the same condition with google earth, the target position stay under the cursor and doesn't come out of the screen.
https://user-images.githubusercontent.com/11291849/233649762-fdc19375-c9dc-4198-8ba5-758b611694a8.mp4
I was referring to Google Maps (cf attached record). If this isn't an appropriate solution, an alternative could be implemented to have a similar zoom as Google Earth instead. Currenctly, I used a bit of a mix of the zoom function from the planarControls (interpolation) and the double click zoom from the globeControls (travel -> lookAtCoordinate).
https://user-images.githubusercontent.com/126568810/234286574-3025cbcd-d436-4035-98c6-a20d39f43a27.mp4
it's good feature that improves the user experience.
I'm asking if it would be possible to factor your code for use in the handleDolly(event)
method (call by pressing the middle button)
it's good feature that improves the user experience. I'm asking if it would be possible to factor your code for use in the
handleDolly(event)
method (call by pressing the middle button)
It's now implemented. I store the coordinates when the wheel button is clicked to zoom at the precise mouse location. But it's not really a "dolly" anymore. In a future improvement, we could also store the first coordinates when the mouse wheel is used, to zoom to the exact mouse location. I did it on another branch of my repo. I did a draft PR on it: https://github.com/iTowns/itowns/pull/2091
https://user-images.githubusercontent.com/126568810/236457349-444ab904-15cd-4567-8309-7e53c7891212.mp4
@Desplandis rebased :+1: