How to Draw Shapes with Mouse Clicks in Cesium?

I’m working on a project using Cesium and I’d like to know how to draw shapes (like polygons or circles) by clicking the mouse on the map. I’m looking for guidance on the following:

  1. What functions or methods should I use to capture mouse clicks?
  2. How can I convert these clicks into coordinates for drawing shapes?
  3. Are there any examples or resources that demonstrate this functionality?

The question as it stands now is pretty generic. And there are many degrees of freedom (Which shapes? Where (in 3D!) should they be drawn? What should the interaction patterns be? What should happen with the shapes that are ‘finished’?). There is a reason why there are so many different applications with different focusses that all revolve around “editing things in 3D”.

But from the current description, the Drawing on Terrain sandcastle should bring some inspiration. It shows different “drawing modes”; the basic handling of mouse clicks and moves, and the basic process of “assembling” a shape based on the user interaction.