Problem with Camera.flyTo near the ground

My application performs an animated flight with a series of flyTo calls and sometimes when the camera position comes quite close to the ground it starts to suddenly jump up like a ball hitting the ground. At the same time, if I perform a series of calls of setView with the same sequence of camera positions it works fine and the camera is visually always above the ground. Is there any way to disable this annoying behaviour of the flyTo call?

Do you use a flat ellipsoid, or do you have terrain as well? There’s also two flyTo()'s; viewer.flyTo() and Which one are you using?

Using any flyTo() with a terrain is tricky, you may have to write your own path flier if your terrain is especially tricky (lots of contrast), but you might start with adding some height to your flight paths. Even better would be to try to create a Sandcastle that replicates what you’re seeing.



I have terrain which I create with a call to the function createWorldTerrain(). I use
I don’t understand what you mean by lots of contrast. The terrain, in a particular example, where I experienced the problems is very simple. What do you mean by “adding some height to your flight paths”? I have a full camera position including the height as the target position for every flight.
I’m sure the problem is not related to the flight path. I perform camera animation as a series of short flights (like one second each) and even making it a fraction of second (so that camera moves just a little in every flyTo call) does not help. Apparently, some code inside the Cesium engine interrupts the direct flight and makes the camera jump up. I guess it has something to do with terrain avoidance. Is there a way to completely disable this code? I don’t need it.

Hi there,

By contrast, I simply mean a terrain that has a lot of ups and downs in it (in this case, along the flightpath).

So, reading this again, is it that it only jumps between those flights, when you go from one to the other? Or is it more like a height above the terrain as you fly along?

I think the camera is trying to work out a good compromise between the height of the path, and where the camera is located. For example, at height 0 (sea level) it has to figure out where to place the camera which is at the horizon +/- Y depending on the distance to some object (and / or terrain), and probably does all sorts of compromises depending on height, angle, pitch, yaw, etc. My suggestion was to add some height to your flightpath so that the camera doesn’t crash into the terrain while flying low, but you could also possibly change the angle of the camera, depending on what you’re trying to do.

I don’t know the ins and outs of this part of the code, so someone smarter than me needs to chirp up. But like you said, if you don’t need this part of the code, you have to make your own flyTo() I suspect., although I seem to remember from memory that you could possibly play with;

viewer.scene.screenSpaceCameraController.enableCollisionDetection = false

You can turn it off and on after each flight, for example. Hope any of that helps.



Alex, to give you a better impression of what’s going on, I recorded two screencasts. One is made by a series of Camera.setView() calls to adjust camera position ten times per second. The second one is made by calls of Camera.flyTo() with the very same target positions for the camera and each animation’s duration is only 0.1 second.
Unfortunately, the forum did not allow me to attach video files directly so I made links to my dropbox. setView: Dropbox - - Simplify your life
flyTo: Dropbox - - Simplify your life

I tried it before and it did not change anything.

And I can’t change the flight path due to the nature of my application. The camera has to fly the exact flight path which is specified with its heading/pitch/roll also coming from my input data.

Hi @Valentin_Kipyatkov

Did you already solve the iisue?

Maybe this will solve the collision between camera and terrain.

this.viewer.scene.globe.depthTestAgainstTerrain = false;

I made a workaround by setting maximumHeight property of FlyToOptions.

1 Like