I am currently using terrain view in Cesium Sandcastle and have loaded roads data in GeoJSON format as lines. I would like to clamp them on the terrain, similar to this example (select "Sample line positions and draw with depth test disabled" from drop-down menu) -> In the provided example, the line is defined within the code, but I have my data (roads) on my PC which is already loaded in the app. However, the roads are currently flat (below the terrain) and I need assistance in clamping them onto the terrain.
I attempted to use the existing code from the example without success.
Here is my current code snippet:
// Adding terrain
var viewer = new Cesium.Viewer('cesiumContainer');
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestWaterMask : true,
requestVertexNormals : true
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
viewer.scene.globe.depthTestAgainstTerrain = true;
// Loading data (roads)
var dataSource = Cesium.GeoJsonDataSource.load('../../SampleData/ceste_rab_okvir.geojson');
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);
I am aware of Cesium.GeoJsonDataSource.clampToGround, but due to my lack of coding experience, I struggle to implement it in my code. Could someone provide guidance on how to achieve this? Alternatively, if there are other methods to clamp roads to the terrain, I would appreciate any suggestions.
Thank you in advance.