Cesium雷达遮罩扫描效果

Cesium雷达遮罩扫描效果

  • 实现效果
  • 关键代码

实现效果

关键代码

 //计算扇形点串
    calcPoints(x1, y1, radius, heading) {
        var m = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(x1, y1));
        var rx = radius * Math.cos(heading * Math.PI / 180.0);
        var ry = radius * Math.sin(heading * Math.PI / 180.0);
        var translation = Cesium.Cartesian3.fromElements(rx, ry, 0);
        var d = Cesium.Matrix4.multiplyByPoint(m, translation, new Cesium.Cartesian3());
        var c = Cesium.Cartographic.fromCartesian(d);
        var x2 = Cesium.Math.toDegrees(c.longitude);
        var y2 = Cesium.Math.toDegrees(c.latitude);
        return this.computeCirclularFlight(x1, y1, x2, y2, 0, 90);
    }

    //根据两个点  开始角度、夹角度 求取立面的扇形
    computeCirclularFlight(x1, y1, x2, y2, fx, angle) {
        let dArr = [];
        dArr.push(x1);
        dArr.push(y1);
        dArr.push(this.degrees.z);
        var radius = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(x1, y1), Cesium.Cartesian3.fromDegrees(x2, y2));
        for (let i = fx; i <= fx + angle; i++) {
            let h = radius * Math.sin(i * Math.PI / 180.0);
            let r = Math.cos(i * Math.PI / 180.0);
            let x = (x2 - x1) * r + x1;
            let y = (y2 - y1) * r + y1;
            dArr.push(x);
            dArr.push(y);
            dArr.push(h + this.degrees.z);
        }
        return dArr;
    }

详情参见 Cesium实战专栏

你可能感兴趣的:(Cesium,gis,js,webgl)