Issue with Cesium Terrain Provider

Issue with Cesium Terrain Provider

Polygon seems to be shifting after adding terrain effect in Cesium
I add a Polygon through geojson. In which i had added a terrain effect using the standard cesium terrain provider as below

I would like to know how to Lock the Polygon after adding the terrain and The Polygon will be fastened to the terrain when i move or turn the earth.

      var viewer = new Cesium.Viewer('cesiumContainer');
      
            //add cesiumTerrainProvider
            var cesiumTerrainProvider = new Cesium.CesiumTerrainProvider({
                url: '//assets.agi.com/stk-terrain/world'
            });
            viewer.terrainProvider = cesiumTerrainProvider;
            
            // This array will hold our cartographic height queries, one per building, and will
            // also be populated with the answers.
            var terrainSamplePositions = ;

            var dataSource2 = new Cesium.GeoJsonDataSource();
            var promise = dataSource2.load('geojson/t112.geojson');
            promise.then(function(dataSource2) {
                viewer.dataSources.add(dataSource2);
                viewer.zoomTo(dataSource2);
                //Get the array of entities
                var entities2 = dataSource2.entities.values;

                var colorHash = {};
                for (var i = 0; i < entities2.length; i++) {

                    var entity = entities2[i];
                    var name = entity.Area;
                    var color = colorHash[name];
                    if (!color) {
                        color = Cesium.Color.BROWN;
                        colorHash[name] = color;
                    }
                   
                    entity.polygon.material = color;
        
                    entity.polygon.outline = false;

                    // TODO: More sanity checking for undefined values etc.
                    var position = entity.polygon.hierarchy.getValue().positions[0];
                    
                    terrainSamplePositions.push(Cesium.Cartographic.fromCartesian(position));

                    var TopHeight=entity.properties.TopHeight;
                    var BaseHeight=entity.properties.BaseHeight
                    var modelHeight=TopHeight - BaseHeight;

// entity.polygon.extrudedHeight = modelHeight;
// entity.polygon.height = BaseHeight;
                }

                // Asking for terrain heights is asynchronous, because the answer may
                // reside on the terrain server.
                Cesium.when(Cesium.sampleTerrain(viewer.terrainProvider, 11, terrainSamplePositions), function() {
                    // Update all building heights to sit on top of the terrain.
                    for (var i = 0; i < entities2.length; i++) {
                        var entity = entities2[i];
                        var terrainHeight = terrainSamplePositions[i].height;
                        
                        var TopHeight=entity.properties.TopHeight;
                        var BaseHeight=entity.properties.BaseHeight
                        var modelHeight=TopHeight - BaseHeight;
                        
                        // The bottom of the building sits on the terrain.
                        entity.polygon.height = BaseHeight;

                        entity.polygon.extrudedHeight = modelHeight;
                    }
                });

            }).otherwise(function(error){
                //Display any errrors encountered while loading.
                console.error(error);
            });

Hello,

Cesium does not currently have support for polygons on terrain. Tom has opened a pull request to add it here: https://github.com/AnalyticalGraphicsInc/cesium/pull/3903

I think that is just waiting for a final review before it is ready to be merged in, so it should be available soon.

Best,

Hannah