-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WIP: OrbitControls: added support for zoom to cursor #17145
Conversation
Hint: Consider to use draft PRs if your code is really WIP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior looks great 👍
Just pointing out some places where a division by zero is possible and you didn't clearly state with comments.
The desired behavior is confirmed with touchpad pinch-to-zoom on Chrome for Windows. Does it work on touch screens too? I think I agree that disabling panning should also disable this feature. Also that zoom to (through?) cursor should be default for MapControls and not for OrbitControls. |
The updated example looks great 👍 |
@WestLangley This change is great! But what about the concerns of @sciecode here #17145 (comment)? Apart from that, I think it's okay to remove the WIP label and updating the docs/TS instead. Would be nice to have this feature in context of |
I now have a version that supports touch, too. I'll get back to this soon... |
@WestLangley Friendly ping. 😇 I too think this would be a great default for |
@Peque check out the PR, he exports MapControls and OrbitControls! |
@duhaime Not sure what you mean... 😅 😊 |
Haha, no worries, I just meant that this PR includes a zoom to cursor implementation for the Map controls. The OrbitControls here exports both OrbitControls and MapControls objects. Did you see @WestLangley's MapControls demo with zoom to cursor? That might be the easiest way to see the zoom to cursor in action... |
@duhaime Thanks. With my comment I just wanted to upvote this MR and ask @WestLangley if they were planning to work on this to get it merged. 😊 |
In particular, I wanted to upvote for MapControls to zoom to cursor by default, which I think is what most people would expect nowadays (matching OpenStreetMaps, Google Maps, Bing Maps...). |
@WestLangley I tried your code here and found one issue, in case you are still interested in this. 😇 The problem occurs when using an |
@Peque there are comments informing of this limitation in the commit: this.maxPolarAngle = Math.PI / 3; // must be less than pi/2 when zoomToCursor is true |
@sciecode Do you know how to work-around that limitation? |
From a design point of view there is no work-around, because we keep From a project stand point, you could simply make it so the "map" is not oriented facing up ( normal pointing to +Y ). Change the orientation to something else, for example... facing +Z. |
@sciecode Thanks for your feedback! 😊 I have an application with the map facing +Z, but I seem to find the same issue. 😕 I do set |
We should note this in the docs as well. |
Thank you @WestLangley for this! |
@WestLangley Is this something that is ready to be merged? |
I for one am confused. Has this been added? Is it stable now? |
When a PR is open then it is not yet merged. And that means the code is not yet added to the repo. |
Well, I am forced to use your code by my current client because his people think its great. Sitting on your hands whilst a PR is open with just has a cryptic message at the bottom is not my idea of fun. So get snotty with me all you like, but you know you guys are starting to drop the ball on this, and then I am going to have to migrate this company back to the real thing. I would love to say I have never seen so much confusion in a code base, but unfortunately I have, so waddle on. |
I'm using this PR's code without problems since a few months even though it hasn't been merged yet – just do it this way? |
I am using it as is, and then my client reads somewhere (not here) that you can now zoom to cursor. Now he wants to know from me if I used ThreeJS at all, because he tested and his website does not zoom to cursor. He substantiates his claims by sighting some blog post that reports you must set some keyword to true. Little does he know that the keyword has already been removed again by the very people that are supposed to guard against such behavior. The control js files in all their flavors, are not supposed to be part of the code base (its in examples), but it is treated as part of it in here, or is it part of it? I simply cannot tell anymore. It might help if the examples are moved to their own repo. Also there has been so many settings/keywords used in it that has been added and then removed again that I have lost count. These were added/removed at the whim of every person coming in here with a new suggestion/complaint. These keywords then start losing their meaning, because the word that describes the effect has been used and removed already. My suggestion (for what it is worth) is make only one controls.js and make it part of the core. Then use settings/keywords to change it into map-/orbit-/camera-/whatever-/controls. Now using js (pseudo) pointers at the start of the file will send the request to the correct function (i.e. there will be no trackballcontrolls or orbitcontrols, but you could have either based on a setting like "Don't orbit all the way around the y axis or yAxisOrbitLimit=90"). If I remember correctly that is the difference between the two. At the moment you are trying to mimic google maps in one file and a plane in another. This can all be one file. I saw in r120 someone made a cameracontrols.js in its own sub folder and I was hoping it was to merge all this, but here we go again with zoom to mouse and we all sit in limbo waiting to see if our next update is going to break this again. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manually picked from mrdoob/three.js#17145
is there any chance this can be merged? It pretty basic and commonly expected behaviour. that said I've just tried using it locally and i have issues because my camera always looks along Z. The camera's position ends up as NaN. Any ideas why this might be? |
would be great to merge ! |
Hey. So, what's preventing this from being merged? Should we just create a new PR? |
Updated to the latest release... Support for touch in progress... |
I have come to the conclusion that this approach is not going to work. (1) It only works when damping is enabled. That is not acceptable in my view. (2) Touch is not supported. (My mobile devices do not support pointer events, so I am no longer able to test the code I wrote previously.) To prevent further delay, I suggest someone else give this a try. |
It's best to not use orbit controls: Use camera controls |
@WestLangley I used https://raw.githack.com/westlangley/three.js/dev-zoom_to_cursor/examples/misc_controls_map.html source code. But It didn't work |
As suggested in #16961 (comment).
I think this should be the default for
MapControls
. I'm not sure if it makes as much sense forOrbitControls
, but it can be toggled on.This is a WIP. Feedback welcome.
<EDIT - live link removed>