Cesium: Some vertical polygons rendering incorrectly

Created on 30 Jul 2018  路  3Comments  路  Source: CesiumGS/cesium

Continuing from https://github.com/AnalyticalGraphicsInc/cesium/issues/6662 after the 1.47 update.

The vertical pentagon mentioned in the previous issue by @silky still does not render correctly after the PR and update, but many similar vertical pentagons do (the important relevant cases are the pink and orange polygons):

screen shot 2018-07-30 at 12 33 06 pm

  • The green example is our base case which works: A symmetrical, vertical pentagon.
  • The red example breaks as the vertices are listed 'out of order', i.e. they do not follow the route either clockwise or anti-clockwise.
  • The blue works, as an example of assymmetry.
  • The orange is broken - the only difference between this and blue is that the base is a little wider
  • The pink works - the only difference between this and orange is that the high mid-point is shifted a little.

Here is the relevant sandcastle demo, including inline comments: Demo

The pink polygon is followed by some comments specifying ranges of coordinates for that high mid-point. Some render the pentagon normally, some present it as two triangles, and some present it as one triangle.

Code from the demo, for quick reference:

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


// Sample, working vertical polygons
var greenPolygon = viewer.entities.add({
    name : 'Green polygon vertically',
    polygon : {
        perPositionHeight: true,        
        hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([
       110, 31, 200000,
       111, 31, 100000,
       111, 31, 0,
       109, 31, 0,
       109, 31, 100000,
       ]), 
        material : Cesium.Color.GREEN.withAlpha(0.6)
    }
});

// Note: the order of vertices matters 
//(must be continous either clockwise or anti-clockwise)
var redPolygon = viewer.entities.add({
    name : 'Red polygon vertically',
    polygon : {
        perPositionHeight: true,        
        hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([
       111, 32, 100000,
       111, 32, 0,
       110, 32, 200000,
       109, 32, 0,
       109, 32, 100000,
       ]), 
        material : Cesium.Color.RED.withAlpha(0.6)
    }
});

// Assymetry seems ok
var bluePolygon = viewer.entities.add({
    name : 'Blue polygon vertically',
    polygon : {
        perPositionHeight: true,        
        hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([
       110.5, 33, 200000,
       111, 33, 100000,
       111, 33, 0,
       109, 33, 0,
       109, 33, 100000,
       ]), 
        material : Cesium.Color.BLUE.withAlpha(0.6)
    }
});

// But some seemingly arbitrary differences are NOT OK
var orangePolygon = viewer.entities.add({
    name : 'Orange polygon vertically',
    polygon : {
        perPositionHeight: true,        
        hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([
       110, 34, 200000,
       111, 34, 100000,
       111, 34, 0,
       108, 34, 0,      // A little wider
       108, 34, 100000, // 
       ]), 
        material : Cesium.Color.ORANGE.withAlpha(0.6)
    }
});

// This is as above, but with the centre point shifted 0.5
var pinkPolygon = viewer.entities.add({
    name : 'Pink polygon vertically',
    polygon : {
        perPositionHeight: true,        
        hierarchy : Cesium.Cartesian3.fromDegreesArrayHeights([
       110.5, 35, 200000, // As wide, shift centre
       111, 35, 100000,
       111, 35, 0,
       108, 35, 0,
       108, 35, 100000,
       ]), 
        material : Cesium.Color.PINK.withAlpha(0.6)
    }
});

// If we shift that highest point by various amounts
// we get different behaviours:
// ?????-108.5  -> Intended pentagon
// 108.6-109    -> 2 triangles
// 109.1-109.9  -> 1 triangle
// 110.1-110.4  -> 2 triangles
// 110.5-?????  -> Intended pentagon

viewer.zoomTo(viewer.entities);

Most helpful comment

Actually, nevermind. It looks like you were using Cesium 1.47. Vertical polygon support is in master but hasn't been included in a release yet. It will be included in the 1.48 release available on August 1st. Here's preview:

image

All 3 comments

Thanks @JacksonBates! I'll look into this today. The positions of the polygon must be listed in order, so the red one not working is expected and isn't something we'll fix. But the issue with orange polygon seems to be a bug.

Actually, nevermind. It looks like you were using Cesium 1.47. Vertical polygon support is in master but hasn't been included in a release yet. It will be included in the 1.48 release available on August 1st. Here's preview:

image

This is great, thanks @hpinkos!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pjcozzi picture pjcozzi  路  4Comments

OmarShehata picture OmarShehata  路  4Comments

puckey picture puckey  路  4Comments

worlddai picture worlddai  路  3Comments

thw0rted picture thw0rted  路  4Comments