Best practice to prevent camera going below terrain in Cesium for Unity (without physics meshes)?

Hi everyone,

We are building a mobile application using Cesium for Unity where users navigate the globe using touch controls (pan, zoom, tilt).

We observed that when the camera moves downward, it can go inside the terrain unless constrained.

We experimented with enabling “Create Physics Meshes” on the Cesium 3D Tileset, and noticed that it appears to prevent the camera from entering the terrain because MeshColliders are generated. However, we are concerned about:

• Performance and memory impact on mobile
• Streaming / LOD transitions causing unreliable collision behavior
• Whether this is an unintended side effect rather than a supported approach

Instead, we are considering a terrain-aware camera height clamp, where:

• The camera’s latitude / longitude / height are read via CesiumGlobeAnchor
• Terrain height is sampled using CesiumTerrainProvider.SampleHeightMostDetailed()
• A minimum height buffer (e.g., 50–100 meters) is enforced
• The correction is applied smoothly in LateUpdate()

This avoids physics entirely and keeps camera behavior deterministic and mobile-friendly.

Questions for the community:

  1. Is terrain-based height clamping the recommended approach for camera safety in Cesium for Unity?

  2. Are physics meshes intended to be used for camera collision, or only for gameplay / character interaction?

  3. Are there any Cesium-native camera constraints or best practices we should follow for globe navigation?

Any guidance or confirmation from the Cesium team or community would be appreciated.

Thanks in advance

Hi @akashc,
Physics is the best way to handle collisions between the camera and the terrain. SampleHeightMostDetailed requires downloading the most detailed tiles and then sampling a height from them, without the benefit of the line trace acceleration data structures used by the physics engine. In other words, it’s much slower, and probably not suitable for live, interactive use as you describe.

It’s true that LOD shifts can sometimes cause problems. If you find this to be a problem in your application, it may help to do some additional, manual Physics.Raycast calls to check if the camera has gone below terrain and pop it back up if so.