CesiumGS / CesiumGS/cesium

Polygon hierarchy attribute CallbackProperty bug

Open
#12,474 4 comments 0 reactions 0 assignees View on GitHub
category - entity type - bug
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

### What happened?

After CallbackProperty is used in the hierarchy value of polygon, two polygons will be rendered if the hightreference attribute value of Polygon is modified again.

`
const viewer = new Cesium.Viewer("cesiumContainer");

const redPolygon = viewer.entities.add({
name: "Red polygon on surface",
polygon: {
hierarchy: new Cesium.CallbackProperty(() => {
const hierarchy = new Cesium.PolygonHierarchy();
hierarchy.positions = [
Cesium.Cartesian3.fromDegrees(-115.0, 37.0, 50000),
Cesium.Cartesian3.fromDegrees(-115.0, 32.0, 50000),
Cesium.Cartesian3.fromDegrees(-107.0, 33.0, 50000),
Cesium.Cartesian3.fromDegrees(-102.0, 31.0, 50000),
Cesium.Cartesian3.fromDegrees(-102.0, 35.0, 50000),
];
hierarchy.holes = [];
return hierarchy;
}, false),
heightReference: Cesium.HeightReference.NONE,
perPositionHeight:true,
material: Cesium.Color.RED,
},
});

setTimeout(()=>{
redPolygon.polygon.material=Cesium.Color.BLUE;
redPolygon.polygon.heightReference=Cesium.HeightReference.CLAMP_TO_GROUND;
redPolygon.polygon.perPositionHeight=false;
},3000);

viewer.zoomTo(viewer.entities);
`

![Image](https://github.com/user-attachments/assets/38904e97-f7e9-4927-bd5b-902f1bbfbbfe)

### Reproduction steps

### Sandcastle example

_No response_

### Environment

Browser:
CesiumJS Version:
Operating System:

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Cesium Viewer example and inspect how polygon hierarchy updates interact with heightReference and perPositionHeight changes. No source file or test is named; done means reproducing the duplicate rendering and confirming that changing those attributes leaves only the intended polygon.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.