Skip to content
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

Maintain camera heading on zoom #4639

Closed
rutsky opened this issue Nov 11, 2016 · 8 comments · Fixed by #5603
Closed

Maintain camera heading on zoom #4639

rutsky opened this issue Nov 11, 2016 · 8 comments · Fixed by #5603

Comments

@rutsky
Copy link
Contributor

rutsky commented Nov 11, 2016

By default panning Earth in 3D has nice property that no matter how I pan tiles on Earth surface will always be oriented "vertically":

earth-panning-optimized

When zoom to mouse is used (either using mouse wheel, or by holding right mouse button), Earth axis is being tilted (the further away from screen center zooming is done, the stronger axis tilt):

earth-zoom-to-mouse2

If I disable zooming to mouse position (by hardcoding in Cesium source code) or if I zoom exactly to screen center this issue is not reproduced.

This is very inconvenient when you navigate over Earth using panning and zooming and at some point see that tiles on the map are rotated.

Also mentioned here: https://groups.google.com/d/msg/cesium-dev/Kv_dSET4Bjs/Z0XJp1JIBQAJ

@hpinkos hpinkos changed the title Zoom to mouse position rotates Earth rotation axis Maintain camera heading on zoom Nov 11, 2016
@hpinkos
Copy link
Contributor

hpinkos commented Nov 11, 2016

Thanks @rutsky, this is something that has come up a few times on the forum as well.
Until we address this, you can add a preRender event to always keep the camera heading such that north is up. Here is an example:

var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.scene.camera;
viewer.scene.preRender.addEventListener(function() {
    camera.setView({
        orientation: {
            heading: 0,
            pitch: camera.pitch,
            roll: camera.roll
        }
    });
});

@rutsky
Copy link
Contributor Author

rutsky commented Nov 14, 2016

@hpinkos thanks for the workaround!

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 2, 2017

CC #2816

@wallw-teal
Copy link
Contributor

I am attempting a fix for this, but I'm a little stuck.

My attempted solution was to grab the heading, pitch, and roll from the camera at Source/Scene/ScreenSpaceCameraController.js:488 and then apply them back via camera.setView(...) at the end of the function. This works great and keeps the heading at 0 (or 360), except that if you zoom in far enough, something outside of that function modifies the camera heading to a non-zero value (haven't checked pitch and roll yet). I can consistently reproduce this using the viewer and only the mouse wheel to zoom. Still trying to track down what is causing that.

wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jun 23, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jun 23, 2017
@wallw-teal
Copy link
Contributor

My employer is working on a corporate CLA. Should be good to go on Monday and I'll open the PR.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 27, 2017

@wallw-bits thanks for working on the fix, looking forward to it!

wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jul 11, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jul 11, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jul 26, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Jul 26, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Aug 2, 2017
wallw-teal added a commit to wallw-teal/cesium that referenced this issue Aug 2, 2017
@cesium-concierge
Copy link

Congratulations on closing the issue! I found these Cesium forum links in the comments above:

https://groups.google.com/d/msg/cesium-dev/Kv_dSET4Bjs/Z0XJp1JIBQAJ

If this issue affects any of these threads, please post a comment like the following:

The issue at #4639 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https:/AnalyticalGraphicsInc/cesium.

I am a bot who helps you make Cesium awesome! Thanks again.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 8, 2017

Thanks again for the bug report, @rutsky! This was fixed in #5603.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants