PolylineGeometry goes under ground when followSurface set to true and depthTestAgainstTerrain = fals

The attached code demonstrates an issue that I see when a polyGeometry has followSurface set to true and depthTestAgainstTerrain set to false.

The following snippet can be place into sandcastle to replicate the issue.

var viewer = new Cesium.Viewer('cesiumContainer');

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
    url : ‘https://assets.agi.com/stk-terrain/world’,
    requestWaterMask : true,
    requestVertexNormals : true
viewer.terrainProvider = cesiumTerrainProviderMeshes;


var appearance = null;
var feature = null;
var linePoints = null;

appearance = new Cesium.PolylineColorAppearance();
linePoints = ;
linePoints.push(Cesium.Cartesian3.fromDegrees(71.6, 37.02, 0));
linePoints.push(Cesium.Cartesian3.fromDegrees(80.2, 30.06, 0));

var primitive = new Cesium.GeometryInstance({
  geometry: new Cesium.PolylineGeometry({
    positions: linePoints,
    width: 2,
    vertexFormat: Cesium.PolylineColorAppearance.VERTEX_FORMAT,
    followSurface: true
  attributes: {
    color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE)

feature = new Cesium.Primitive({
    geometryInstances: primitive,
    allowPicking: false,
    interleave: true,
    appearance: appearance


Does anybody know how to get around this issue?

Thanks in advance

J. Stoy

The line: viewer.scene.globe.depthTestAgainstTerrain=false;
should be

Sorry about that


We don’t currently have support for polylines on terrain. However, it’s one of the most frequently requested features and we hope to have support soon.

In the meantime, you can try subsampling your line and give it a height at each point. You can use the function sampleTerrainMostDetailed to find the height of the terrain at different positions.

Alternatively, you can try using a CorridorGeometry: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Corridor.html&label=Geometries

This won’t stay the same size as you zoom in and out, but it will conform to terrain.