# Camera behavior when at or below terrain height

**URL:** <https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554>\
**Category:** CesiumJS\
**Created:** [October 12, 2018, 3:24am UTC](https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554 "2018-10-12T03:24:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Chapman](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/andrew_chapman/32/4219_2.png) [@Andrew\_Chapman](https://community.cesium.com/u/Andrew_Chapman)\
**Post date:** [October 12, 2018, 3:24am UTC](https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554/1 "2018-10-12T03:24:40Z")

</div>

**1. A concise explanation of the problem you’re experiencing.**

We have some 3D tile datasets which extend below the surrounding default (Ion) terrain. For example a mining pit which has been dug deeper than at the time the default terrain data was captured.

We also have some 3D tile datasets which sit on top of the surrounding default terrain, but which show a negative camera height, e.g. -32.239458 (south), 115.77787 (east) shows a terrain height as -27m

In both these cases, if the camera is well above the ground height it operates as expected, but as you zoom in on the details it either reaches a point where it stops (i.e. you can’t descend any lower/closer, even though still well above the 3D tile data) and/or the rotation changes so instead of rotating around the mouse pointer location it changes to be an angular rotation around the camera’s own location.

I think this is a collision with the behaviour to prevent the cesium camera from descending below the terrian, but is there a workaround for these cases where it is valid to do that?

**2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.**

I might be able to extract a minimal example, but currently entrenched in a lot of surrounding code and data, but hoping this is a known issue to discuss?

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

It is valid for some datasets to be below what Cesium considers to be the terrain surface, while still being above ground, e.g. open-cut mines

**4. The Cesium version you’re using, your operating system and browser.**

Cesium v1.50, Chrome on windows+osx

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [October 12, 2018, 6:26pm UTC](https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554/2 "2018-10-12T18:26:16Z")

</div>

I did some digging for this, and I found a PR that disables collision with terrain while the camera is flying to a destination:

> <https://github.com/CesiumGS/cesium/pull/4105>

Which subsequently led me to [ScreenSpaceCameraController.html#minimumCollisionTerrainHeight](https://cesiumjs.org/Cesium/Build/Documentation/ScreenSpaceCameraController.html#minimumCollisionTerrainHeight). Changing that to 0 (or possibly negative?) I think should allow the camera to move without constraint under terrain.

Let me know if that works. This sounds like a pretty interesting project, what kind of application is it for? And does it look good to view 3D tiles under terrain [or are you clipping the terrain](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Terrain%20Clipping%20Planes.html) in that area or something like that?

---

<div class="post-metadata">

**Author:** ![Andrew\_Chapman](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/andrew_chapman/32/4219_2.png) [@Andrew\_Chapman](https://community.cesium.com/u/Andrew_Chapman)\
**Post date:** [October 13, 2018, 1:59pm UTC](https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554/3 "2018-10-13T13:59:37Z")

</div>

Hi Omar,

Thanks for the idea, I did give it a try but get rendering crashes when the camera is underground:

 ![cesium_crash.jpg](https://global.discourse-cdn.com/cesium/original/2X/8/8e288b1bdabcc55c679c26608cdbf316048db0bb.jpeg)

It does help to allow zooming closer to the target object, but the camera rotation still goes strange as soon as you are below the height that cesium thinks is the ground.

Regards,

Andrew

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [October 15, 2018, 8:06pm UTC](https://community.cesium.com/t/camera-behavior-when-at-or-below-terrain-height/7554/4 "2018-10-15T20:06:29Z")

</div>

This might be related to this error:

> <https://github.com/CesiumGS/cesium/issues/7143#issuecomment-429937133>
>
> Since Cesium 1.45 BingMapsGeocoderService is no longer the default geocoding service. In changelog following changes are recommend in case you want...

Can you try Cesium 1.48 and let me know if that crashes in the same way?
