0

I am trying to draw circles around an icon that is selected via clicking. My current code is:

this.handler.setInputAction(function(click) {
  var pickedObjects = viewer.scene.drillPick(click.Position);
  if(Cesium.defined(pickedObjects)) {
     if(pickedObjects.length >=1)
     {
      var cartesian = thisRef.viewer.camera.pickEllipsoid(click.position, thisRef.viewer.scene.globe.ellipsoid);
      thisRef.drawCircle(cartesian);
     }
    }
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK;
};

If the user is zoomed out quite far, the position won't be accurate. It needs to be based on the selected object, not the users click. However I can't figure out how to do this. I have pickedObjects, but I can't figure out how to get their position from those objects. It doesn't seem to be an entity (even though I think the icon was an entity when it was being created) and so I can't use entity.position. Thank you for your help.

user8402764
  • 143
  • 2
  • 14

1 Answers1

0

To be able to access the standard Cesium entity, it turns out, you must go in the drillPick objects id. So I modified my code to get the first object in the list of objects and get the id from that, and now I can call the member position of a standard entity.

 this.handler.setInputAction(function(click) {
      var pickedObjects = viewer.scene.drillPick(click.Position);
      if(Cesium.defined(pickedObjects)) {
         if(pickedObjects.length >=1)
         {
          var entity = pickedObjects[0].id;
          thisRef.drawCircle(entity.position);
         }
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK;
    };
user8402764
  • 143
  • 2
  • 14