1. A concise explanation of the problem you’re experiencing.
I need to switch from a graphic to another in the same entity. For example, if entity has an ellipsoid representation (EllipsoidGraphics) a user should be able to convert it to a ellipse (EllipseGraphics) .
I have found a way to do it by setting the first graphic to undefined and create a different graphic in the same entity.
But by doing so, when I use a CallbackProperty on the first graphic , I have an error when I set the graphic to undefined because the graphic does not exists anymore.
Is there a way to switch between graphics in the same entity and/or unregister a graphic from a CallbackProperty ?
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var position = new Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0);
var blueBox = viewer.entities.add({
name : 'Blue box',
position: Cesium.Cartesian3.fromDegrees(-114, 40.0, 300000.0),
ellipsoid : {
radii : new Cesium.CallbackProperty(getRadii, false),
material : Cesium.Color.RED
}
});
function changeEntityType(){
blueBox.ellipsoid = undefined;
blueBox.ellipse = {
"semiMinorAxis" : 300000.0,
"semiMajorAxis" : 300000.0,
"height" : 200000.0,
material : Cesium.Color.BLUE
};
}
var count = 1000;
function getRadii() {
count+=5000;
return new Cesium.Cartesian3(count, count, count);
}
function setRadiiCallback() {
if(blueBox.ellipsoid) {
blueBox.ellipsoid.radii.setCallback(getRadii, true);
}
}
setInterval(changeEntityType, 10000);
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
A user should be able to switch between different graphics in the same entity. For example a user can switch between the representations of a circle in 3D (as a circle in 2D could be in 3D a circle, a sphere, a cylinder or a cone) .
4. The Cesium version you’re using, your operating system and browser.
1.56.1