Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a hidden polygon with defined height causes other hidden polygons with defined height to be shown #7132

Closed
pjaustin opened this issue Oct 10, 2018 · 3 comments

Comments

@pjaustin
Copy link

Updating a hidden polygon can cause other hidden polygons to be shown. It appears this only affects polygons that have a defined height (either zero or non-zero).

Sandcastle example:

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

var greenPolygon = viewer.entities.add({
    id : 'GreenPolygon',
    name : 'Green polygon',
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-108.0, 42.0,
                                                        -100.0, 42.0,
                                                        -104.0, 40.0]),
        material : Cesium.Color.GREEN,
        height: 0
    }
});

var bluePolygon = viewer.entities.add({
    id : 'BluePolygon',
    name : 'Blue polygon',
    polygon : {
        hierarchy : {
            positions : Cesium.Cartesian3.fromDegreesArray([-99.0, 30.0,
                                                            -85.0, 30.0,
                                                            -85.0, 40.0,
                                                            -99.0, 40.0]),
        },
        material : Cesium.Color.BLUE,
        height: 0
    }
});

viewer.entities.add({
    id : 'RedPolygon',
    polygon : {
        hierarchy : {
            positions : Cesium.Cartesian3.fromDegreesArray([-108.0, 30.0,
                                                            -100.0, 30.0,
                                                            -104.0, 32.0]),
        },
        material : Cesium.Color.RED,
        //height: 0
    }
});

Sandcastle.addToolbarButton('Hide', function(){
    viewer.entities.values.forEach(function (entity) {
        entity.show = false;
    });
});

Sandcastle.addToolbarButton('Update green polygon', function(){
    var entity = viewer.entities.getById('GreenPolygon');

    entity.polygon = new Cesium.PolygonGraphics({
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-108.0, 42.0,
                                                        -100.0, 42.0,
                                                        -104.0, 40.0]),
        material : Cesium.Color.GREEN,
        height: 0
    });
});

viewer.zoomTo(viewer.entities);

• Click Hide button to hide all the polygons
• Click Update green polygon button
• The blue polygon (which has a defined height) is incorrectly shown. The red polygon (which does not have a defined height) is correctly not shown. The green polygon correctly remains hidden.

#2909 appears related, but it's not clear whether this is the same issue.

@hpinkos
Copy link
Contributor

hpinkos commented Oct 10, 2018

Thanks for reporting this @pjaustin! It looks like I might have broken this with other fixes I made regarding polygon show in the 1.48 release. I'll try to get a fix in for the next release.

Meanwhile, if you use entity.polygon.show = false instead of entity.show = false it should work as expected. You'll just need to pass show: false to the new PolygonGraphics in your update function.

@hpinkos
Copy link
Contributor

hpinkos commented Oct 22, 2018

Thanks again for reporting this @pjaustin! The fix in #7156 has been merged into master and will be included in the 1.51 release available November 1st.

@pjaustin
Copy link
Author

Thanks for the workaround and quick fix @hpinkos. We'll update to the new release at some point soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants