效果
可视域在三维中是比较常用的分析功能,很多领域中都能应用到。
代码
创建起终点,模拟相机的视锥绘制视锥体,创建点光源添加阴影效果。
可视域分析代码
class Viewshed {
/**
* 通视分析构造函数
* @method constructor
* @param viewer Cesium.Viewer 对象
*
*/
constructor(viewer) {
this._viewer = viewer;
this._scene = viewer.scene;
this._camera = this._scene.camera;
this.context = this._scene.context;
this._visibleColor = Cesium.Color.LIME;
this._inVisibleColor = Cesium.Color.RED;
this._offsetDist = 0.2;
this._viewPoint = null;
this.timeId;
//视点位置
this.cameraPosition = null;
//标识符
this.startAnalyze = false;
//阴影参数
this.shadowOptions;
this.handler;
//聚光灯光源
this.spotLightCamera;
//光源参数
this.radii;
this.heading;
this.roll;
this.pitch;
this.tempFrustum;
this.normalShaderFun = null;
this.normalShader;
this.lightSwitch = false;
this.testOn = false;
this.entities = [];
this.activeShapePoints = [];
this._showDistance = true;
this._s