How to add contours to cesium tiles?

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

By going through an example in sandcastle, I’ve isolated code to add a material to terrain that adds contours. However, when using it locally with my cesium tiles, the controus come up to the tiles and stop. Basically, everything has contour lines except the thing that needs them, the tile set. I don’t imagine anything’s wrong with Cesium, I just can’t figure the right configuration. Been working on this for a week.

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

On my local machine:

var Cesium = require(‘cesium/Cesium’);

require(‘cesium/Widgets/widgets.css’);

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

terrainProvider: Cesium.createWorldTerrain({

requestVertexNormals: true //Needed to visualize slope

})

});

var tileset = new Cesium.Cesium3DTileset({

url: “http://localhost:8080/src/data/cesium

});

viewer.scene.primitives.add(tileset);

viewer.zoomTo(tileset);

var contourColor = Cesium.Color.RED.clone();

var contourUniforms = {};

var globe = viewer.scene.globe;

var material;

material = Cesium.Material.fromType(‘ElevationContour’);

contourUniforms = material.uniforms;

contourUniforms.width = 2.0;

contourUniforms.spacing = 5.0;

contourUniforms.color = contourColor;

globe.material = material;

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

Working on displaying 3d products for our customers in browser with cesium. We’re a photogrammetry company.

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

Cesium 1.43

Ubuntu 16.04

Hi George,

I don’t think what you are trying to do is possible, at least at the moment. While terrain can use custom materials (in this case to draw the contour lines), 3D Tiles do not. You can use 3D Tiles Declarative styling (like in this tutorial), but that is more intended for styling individual features.

More customization and more analytically powerful styling is something we are certainly trying to achieve in the future, as well as more closely aligning terrain with the 3D Tiles format.

Thanks,

Gabby

Can the tiles be treated as terrain? Basically there would be nothing but the tiles in the model, no background terrain.

If not, I'll look into Declarative stylings in a few weeks, see what I can find out. Do you know of anyone in the cesium community who works on applying cesium to aerial mapping products who I could reach out to for advice?

The globe’s terrain and 3D Tiles are treated differently in the engine, so I don’t think currently that approach will work.

I’ve reached out for a contact that could advise you, hopefully I can get back to you soon with that!

Thanks!

Hey Gabby, did you ever find out anything more about contour lines on tile sets?

1 Like