How to prevent camera tilt/rotation?

49 views
Skip to first unread message

ste...@climaterisk.com.au

unread,
Aug 25, 2019, 9:45:54 PM8/25/19
to cesium-dev
1. A concise explanation of the problem you're experiencing.
I am unable to find a way to prevent the camera from tilting or rotating when using the map in the 'globe' view. When viewing a flat map there is no problem, but using the flat map is not an option for my application.


2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
I've attempted to constrain the axis using :
camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;
but there is no disernable change. 
I've also attempted to set defaultLookAmount and defaultRotateAmount to 0 and that has no impact on behaviour of the camera.


3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

The look and rotate are unnessesary for my application, and make navigating/zooming on mobile nearly impossible. The globe constantly turns and tilts, often resulting in a misconfigured map that needs to be refreshed to return to home.


4. The Cesium version you're using, your operating system and browser.
Currently using 1.6, Kubuntu and Firefox, but this issue is common to all major OS and browsers.


Omar Shehata

unread,
Aug 26, 2019, 2:14:06 PM8/26/19
to cesium-dev
Hey Stephen,

Have you tried disabling tilt on the camera controller?

viewer.scene.screenSpaceCameraController.enableTilt = false;

There's a few other options you can disable there too. This camera code example disables all camera movement and overrides it with keyboard controls (for your case it would be a good reference just to see how to disable the various interactions):


You may also want to override the home button to go to a view/with your custom logic, that way the user doesn't have to refresh to get back to some home state in your application:

viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function (e) {
    e.cancel = true;
    // Add any custom code here, such as flying to some saved view.
});

Let me know if this helps!

Stephen Haynes

unread,
Aug 26, 2019, 7:44:56 PM8/26/19
to cesiu...@googlegroups.com
That worked! Thanks Omar!

Thanks,

Stephen

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/9dSpOnYAuVU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cesium-dev/f421ebc8-777f-4e25-bfb0-69d3115dd717%40googlegroups.com.

kulvin...@gmail.com

unread,
Apr 2, 2020, 7:50:13 AM4/2/20
to cesium-dev
Thanks Omar!!
Reply all
Reply to author
Forward
0 new messages