1. A concise explanation of the problem you’re experiencing.
I need to hide(show) all primitives in a collection so I thought that the collection#show property was the way to go but it looks like it has no effect.
Enumerating the collections’ primitives and hiding(showing) them one by one works as expected (via the primitive’s show property).
I tried with a callback property but no luck too (I might be doing something wrong though).
Is the collection#show property meant to show/hide all the items at once and if so how to properly use it?
Furthermore is it supposed to be operated with a callback property too?
A Sandcastle-ready code example with all my three attempts follows.
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 scene = viewer.scene;
var polyline;
var material = Cesium.Material.fromType(‘PolylineArrow’);
material.uniforms.color = new Cesium.Color(0,1.0,0,1.0);
var polylines = scene.primitives.add(new Cesium.PolylineCollection());
polyline = polylines.add({
positions : Cesium.PolylinePipeline.generateCartesianArc({
positions : Cesium.Cartesian3.fromDegreesArray([-110.0, 42.0,
-77.0, 12.0])
}),
width : 10.0,
show : true,
material: material
});
polylines.add({
positions : Cesium.PolylinePipeline.generateCartesianArc({
positions : Cesium.Cartesian3.fromDegreesArray([-120.0, 42.0,
-77.0, 12.0])
}),
width : 10.0,
show : true,
material: material
});
// This works
//setTimeout( ()=> { for(var i=0;i<polylines.length;++i) polylines.get(i).show = false; },2000 );
// This doesn’t
setTimeout( ()=> { polylines.show = false; },2000 );
// This doesn’t either
/*
var visible = true;
var isConstant = false;
polylines.show = new Cesium.CallbackProperty( ()=> { return visible; }, isConstant );
setTimeout( ()=> { visible = false; }, 2000);
*/
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to let the user selectively choose which set of primitives are visible.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.59, Win 10 64Bit, Chrome 75.0.3770.100 64 bitt official build
TIA