Hi Cesium Dev Team,
I have upgraded my application from cesium 1.16 to 1.22.1 recently.
For me have to hide picked objects and show them on other click event, for example the following kind of code is giving error in newer version.
var mouseHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
mouseHandler.setInputAction(function(evt){
var pickedObjects = viewer.scene.drillPick(evt.position);
pickedObjects[0].id.show = false;
setTimeout(function(){
pickedObjects[0].id.show = true; // giving error as picked object id is undefined.
}, 1000);
Could you please help me on this.
Thanks.
Hello,
I was unable to reproduce your error in the latest version of Cesium. Here is the example I tested with:
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
selectionIndicator : false,
infoBox : false
});
var red = viewer.entities.add({
polygon : {
hierarchy : Cesium.Cartesian3.fromDegreesArray([-70.0, 30.0,
-60.0, 30.0,
-60.0, 40.0,
-70.0, 40.0]),
material: Cesium.Color.RED
}
});
var mouseHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
mouseHandler.setInputAction(function(evt){
var pickedObjects = viewer.scene.drillPick(evt.position);
pickedObjects[0].id.show = false;
setTimeout(function(){
pickedObjects[0].id.show = true;
}, 1000);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
``
What error message are you seeing?
Best,
Hannah
Hi Hannah,
For billboard i am getting the issue, with the following.
var viewer = new Cesium.Viewer('cesiumContainer', {
selectionIndicator : false,
infoBox : false
});
var red = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
billboard :{
image : '../images/Cesium_Logo_overlay.png'
}
});
var mouseHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
mouseHandler.setInputAction(function(evt){
var pickedObjects = viewer.scene.drillPick(evt.position);
pickedObjects[0].id.show = false;
setTimeout(function(){
pickedObjects[0].id.show = true;
}, 1000);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Thanks.
Hello,
I think this may just be a javascript variable scope issue. Changing your click handler slightly fixed the problem for me:
mouseHandler.setInputAction(function(evt){
var pickedObjects = viewer.scene.drillPick(evt.position);
var entity = pickedObjects[0].id;
entity.show = false;
setTimeout(function(){
entity.show = true;
}, 1000);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
``
Best,
Hannah
Hi Hannah,
I have stored all entities into another array and did the same, working fine now.
But still i didnt understand the issue as we just storing them into the array to resolve it.
Thanks,
Raghu.