How to Limit Tilt

I would like to be able to limit the tilt. Using a mouse we can easily and consistently end up “under ground” or get “lost” in the scene by clicking on the globe and moving the mouse to tilt the scene to both extremes (+/- 90 degrees) repeatedly. The severity of the problem caused in the scene depends on the zoom level.

I’ve read through numerous posts regarding this issue, but I haven’t found a method that addresses the problem.

I do see several references to using a constrainedAxis, but I’m not sure how to implement this. The “setReferenceFrame” function in the Sandcastle Camera demo constrains the axis but also locks the scene to a particular position.

It seems that if I could limit the tilt to just less than +/- 90 degrees it might prevent this issue.

Is there a way to do this without having to modify Cesium’s source code?


The following community forum post discusses a lot of details related to Camera tilt in CesiumJS. I think reading through this discussion might be a good place for you to start.

Limiting the tilt with the Camera object might be your best bet. The following sandcastle demo shows how this (and a lot of other Camera) functionality can be implemented:

Specifically, Camera.constrainedAxis might be what you are looking for. I hope this helps! Let me know if you have any other questions or concerns.


Hi Sam. Thanks for responding. However, I already pointed out that I felt there might be a solution related to the constrainedAxis. I also pointed out the Sandcastle Camera demo and specifically the “setReferenceFrame” function.

But I stated that I haven’t figured out a way to utilize the constrainedAxis to solve the issue. I would greatly appreciate a simple code example that limits the tilt to just under +/- 90 degrees but doesn’t lock the scene in a specific position.

Can you provide an example like that?

1 Like


I apologize for the repeated information. Since I did not see links to Sandcastle demos or our API, I wanted to make sure that you had the correct resources. I will check in with our development team and get back to you with a more cohesive sandcastle demo ASAP.


Thanks, Sam. I’ll be watching for an example/demo. Thanks!


I have been thinking about this functionality for the past few hours and I believe that the best solution involves modifying our source code. This issue has come up in numerous other community forum posts (as you mentioned) so a more robust solution may be appropriate.

Do you have any suggestions for how this might be optimally implemented? I think adding an additional function called limitTilt() to the Camera object may make sense.


Hi Sam,

I think having a limitTilt function would be a great addition. However, I’m guessing that we’d be looking at weeks to months before the Cesium team would be able to release a new function like that.

I was really hoping for someone on the team to be able to provide an example approach for accomplishing this with the current code base. I really don’t want to modify the Cesium code since we update Cesium in our projects within days of the Cesium monthly release schedule.

Can someone on the Cesium dev team provide a Sandcastle example of a way to limit the tilt without locking the scene in any other fashion?

Or… if there is another approach to preventing the problems I described from happening that would be terrific as well. The problems being that it’s very easy (even using any of the Sandcastle examples) to tilt the globe and either end up under ground or lost in the scene. Just run any of the demos, zoom so that the entire globe is in view, then begin tilting the globe/scene to both extremes (+/- 90 degees). It won’t take long for you to experience one of the various issues. Do the same thing but zoomed in very close to the surface and you’ll likely experience more of the issues. These are the problems I’m trying to avoid by limiting the tilt.


If limiting the camera tilt is being used as a temporary workaround to fixing more fundamental issues, I would prefer that we focus our attention on the underlying bugs. CesiumJS bugs can be submitted here for review.

I believe that this pull request addresses some of the issues that you just brought up. Is this correct? Our team should review this pull request in the near future - I expect it to be part of our upcoming CesiumJS release.

As you know, we always look for community support in the pull request review process. Your support in reviewing this pull request can ensure that these features are implemented in a timely manner.

Given that the Camera sandcastle doesn’t have the functionality that you are looking for, I just wanted to check in with a few more questions. How are you expecting the camera tilt to work? Can you share a .gif of the bug? What camera movement is necessary for your scene?


Hi Sam,

I’m not sure that the pull request you referenced addresses any of the issues I described (or the ones described in many other posts about the desire to limit tilt).

I’m on a tight deadline this week, but I’ll try to upload a clip showing the problem soon. However this is such an easy problem to reproduce in any Sandcastle demo, and it’s been reported in numerous posts going back quite a few years.

As for what camera movement is necessary for our scene… We need full/default/standard behavior for the camera. Our projects center around the earth. And panning/zooming/tilting is all expected to occur with the earth as the center point. With that being said you can easily produce the problems I’ve described by simply tilting the camera to the limits (+/- 90 degrees) repeatedly in any of the Sandcastle demos. Sometimes a problem is produce the very first time you tilt. Other times you may have to tilt several times to produce these problems.


Thanks for the details on your current project. I understand that you are under tight time constraints. I checked in with a few other developers and we agree that there needs to be an issue open on GitHub for limiting tilt. It would be a great feature to support.

We put together this sandcastle demo that limits camera tilt. It isn’t perfect but maybe it can be used as a starting point.

Let me know what you think. Also, I just added an issue on GitHub that should address this functionality.

Feel free to add any feedback.


Hi Sam,

Thanks for working on this! I really appreciate it. And I do believe having a method to limit tilt will be a real benefit.

I’d like to emphasize the REASON I’m wanting to limit the tilt (and the reason expressed by many forum posts) is to avoid the problems that can be experienced when tilting the scene. These problems include apparently ending up underground or getting entirely lost in the scene (completely turned around, in black space, don’t know where you are). It’s even possible to sometimes get into a state that Cesium can’t recover from.

I’ve been experimenting with the Sandcastle demo you provided. This does seem to help limit the problems that can be caused by tilting, so it’s a good starting point or temporary improvement. It seems to work better the closer you are to the globe. But as you zoom out from the globe you can still easily get into trouble when tilting the scene.

Here’s a quick video of one problem that is extremely easy to reproduce in the demo you provided:


I’ll try to grab some videos of other issues as well.

But, again, I really appreciate the attention to this issue. It’s a problem we’ve wanted to address for a very long time.

Using the Hello World Sandcastle demo here’s an example of the click/anchor point for the tilt being lost. This happens very frequently.

Notice the cursor did not leave (or even hit the upper edge of) the canvas. However, additional errors/bugs can be encountered if the cursor leaves the canvas during tilt.

I’m holding down the Ctrl Key and right-clicking on the globe. Then moving the mouse forward and backward to tilt the scene… never letting up on the mouse button. But after the second tilt the anchor point is lost and the scene no longer tilts.


Using the Hello World Sandcastle demo here are a few examples of the scene panning during tilt. This happens to some degree almost every time you tilt to both ends of the tilt range.

I’m holding down the Ctrl Key and right-clicking on the globe. Then moving the mouse forward and backward to tilt the scene… never letting up on the mouse button. Look at the San Francisco airport as a reference point. After tilting the scene the airport/scene has shifted/panned towards the north. The amount of shift varies potentially based on how fast the scene is tilted… but I’m not sure if the tilt speed is the offending variable.


Using the Hello World Sandcastle demo here’s an example of the globe being completely lost. This happens very regularly when zoomed around the distance shown in the video clip.

I’m holding down the Ctrl Key and right-clicking on the globe. Then moving the mouse forward and backward to tilt the scene… never letting up on the mouse button.

In this case after losing the globe when I tilt if I begin to zoom out I eventually have the globe come back into view.



You are welcome! I am happy to help you out with these issues. Thank you for sending over the screen recordings. After seeing your recordings, it was much easier for me to reproduce these bugs on my local machine. This information will help me pinpoint the key problem as I create a pull request that addresses limiting camera tilt. Please do not hesitate to reach out if you have any other questions or concerns. Also, if you find any more errors related to camera movement I would appreciate it if you shared a sandcastle demo and/or a screen recording of them with me.


1 Like