help to understand CallbackProperty "isConstant"

1. A concise explanation of the problem you’re experiencing.

I’m using CallbackProperty to update the opacity and the width of some polylines on the basis of camera range.

I’m quite happy about the result, but the continuos width update is very expensive for the cpu (the material color update doesn’t seem to be too expensive)

I’m wondering how to swap from a constant value to a returned function value with CallbackProperty.

I’ve tried to change “isConstant” from false to true, but it doesn’t seem to change.

P.S. DistanceDisplayCondition doesnt seem to work on mobile with polylines, from some test I did time ago

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

map.onReady.push(function () {

update();

map.camera.changed.addEventListener(() => {

update();

});

});

function update() {

let r = Maf.clamp(map.range, minRange, maxRange);

globalOpacity = Maf.inverseLerp(maxRange, minRange, r);

globalWidth = Maf.inverseLerp(maxRange * 2, minRange, r);

};

export function drawPolyline(positions, category, collection = null) {

let properties = getPropertiesFromCategory(category);

let entity = map.viewer.entities.add({

opacity: properties.opacity, /// change this value to set the opacity individually

color: properties.color,

outlineColor: properties.outlineColor,

width: properties.width,

category: category,

polyline: {

positions: positions,

clampToGround: properties.clampToGround,

// width: 5,

width: new Cesium.CallbackProperty(function () {

return entity.width * globalWidth;

}, false),

material: new Cesium.PolylineOutlineMaterialProperty({

color: new Cesium.CallbackProperty(function () {

return new Cesium.Color(entity.color.x, entity.color.y, entity.color.z, entity.opacity * globalOpacity)

}),

outlineWidth: properties.outlineWidth,

outlineColor: new Cesium.CallbackProperty(function () {

return new Cesium.Color(entity.outlineColor.x, entity.outlineColor.y, entity.outlineColor.z, entity.opacity * globalOpacity)

}),

}),

show: properties.show,

}

});

if (collection) collection.push(entity);

return entity;

};

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

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

1.66

I’ll try to explain better the “problem”

I should change the {opacity}, {width}, {semiminorAxis}, etc of several different entities (labels, ellipses, polygons,…) on the basis of the camera {range}, {pitch}, {height} and others parameters.

If I just change their properties when some conditions are meet them would “flash”, so I’m massively using “CallbackProperty” to have a “smooth” visual experience.

This is nice, but the downside is that each “CallbackProperty” seem to be called every single frame

(and some properties, like polylines width take a soo much longer time to update)

So, more battery used, less devices availables, etc.

Is there a way to manage this “CallbackProperty” to (maybe) change it’s update rate, or to set it at costant at some point ?