Label primitives not being cleaned up after delete

Hello, the code snippet is being tested in Cesium v1.19 Sandcastle. The results are different if it was moved over to run on Cesium v.1.29 Sandcastle.

The code adds a point and associated label to the scene by pushing ‘Process Point’ and then removes the point and label when pressing ‘Delete Point’ button. The console outputs the promise after each process call and confirms that no entities exists in the CzmlDataSource.

Then, if you modify logPreRender to true, after adding the point back on, the console logs the primitives, specifically looking for the label. When you remove the point, I am expecting that the label is also removed; however, the scene is still rendering the the label with the show flag set to false. Our application can potentially adds hundreds of points with associated labels and the user can remove them. What v1.19 suggests is that the labels are never cleaned up… is this a correct observation? Did a later version fix this?

var czmlDocument = [{

“id” : “document”,

“name” : “CZML Point”,

“version” : “1.0”

}];

var czml = [

{

“id” : “point1”,

“name”: “point”,

“position” : {

“cartesian” : [1864828.93,3364932.93,5070208.06]

},

“label” : {

“fillColor” : {

“rgba” : [255, 255, 255, 255]

},

“font” : “12pt Lucida Console”,

“horizontalOrigin” : “LEFT”,

“pixelOffset” : {

“cartesian2” : [8, 0]

},

“style” : “FILL”,

“text” : “point1”,

“showBackground” : true,

“backgroundColor” : {

“rgba” : [112, 89, 57, 200]

}

},

“point”: {

“color”: {

“rgba”: [255, 255, 255, 255]

},

“outlineColor”: {

“rgba”: [255, 0, 0, 255]

},

“outlineWidth” : 4,

“pixelSize”: 20

}

}

];

var czmlDelete = [

{

“id”:“point1”,

“delete”:true

}

];

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var dataSource = new Cesium.CzmlDataSource(‘test’);

viewer.dataSources.add(dataSource);

dataSource.load(czmlDocument);

Sandcastle.addToolbarButton(‘Process Point’, function() {

dataSource.process(czml).then(function(ds) {

console.log('Entities (after processed): ’ + ds.entities.values.length);

});

});

Sandcastle.addToolbarButton(‘Delete Point’, function() {

dataSource.process(czmlDelete).then(function(ds) {

console.log('Entities (after deleted): ’ + ds.entities.values.length);

});

});

// Change this value to ignore prerender routine

var logPreRender = false;

viewer.scene.preRender.addEventListener(function(scene,t) {

if(logPreRender === true) {

var primitives = scene.primitives;

for(var i = 0; i < primitives.length; i++) {

var collection = primitives.get(i);

if(collection.length && collection.length > 0) {

for(var j = 0; j < collection.length; j++) {

var p = collection.get(j);

if(p instanceof Cesium.Label) {

console.log(‘PreRender: ’ + t + ’ (’ + p.text + ') ’ + p.show);

}

}

}

}

}

});

``

Thank you.

Hello,

We did have a bug where toggling show/hide on labels wasn’t working. We fixed this in the 1.27 release that came out in November. Are you able to upgrade to a newer version of Cesium?

Best,

Hannah

I will look into an upgrade. Thanks, Hannah!