how to caculate and render viewshad area ?

hi,how to caculate and overlay viewshad area on 3D model? look this Demo ,http://www.supermapol.com/webgl/examples/viewshed3D.html ,it use Cesium to realize