how to apply ElevationContour Material to the polygon entity?

Skip to first unread message


Dec 21, 2018, 3:03:34 AM12/21/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.

how to apply ElevationContour  Material  to the  polygon entity?

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

var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProvider: Cesium.createWorldTerrain({
        requestVertexNormals: true //Needed to visualize slope

 var  material = Cesium.Material.fromType('ElevationContour');
 var contourUniforms = material.uniforms;
contourUniforms.width = 2.0;
contourUniforms.spacing = 5.0;
 contourUniforms.color = Cesium.Color.RED;

var scene = viewer.scene;

var instance = new Cesium.GeometryInstance({
  geometry : new Cesium.RectangleGeometry({
    rectangle : Cesium.Rectangle.fromDegrees(-100.0, 20.0, -90.0, 30.0),
    vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT

scene.primitives.add(new Cesium.Primitive({
  geometryInstances : [instance],
  appearance : new Cesium.EllipsoidSurfaceAppearance({
    material : material

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

 i want to apply ElevationContour or ElevationRamp  or SlopeRamp to  the  fixed region(picture1)  instead of whole globe (picture2).



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

CE V 1.50
Chrome V 60

Omar Shehata

Dec 21, 2018, 12:08:28 PM12/21/18
to cesium-dev
I think the problem is that the required vertex attributes (which are present in the terrain geometry) are not present on the rectangle geometry, so that's why nothing is shown when applying to the rectangle. 

To do that you'd have to write a custom Appearance (the best resources on that are this tutorial and this guide ) that would mix the default GlobeFS.glsl with the slope/elevation materials, for a given area. Although it might not be a trivial change if you're not comfortable with graphics shaders.
Reply all
Reply to author
0 new messages