cesium实现动态圆效果之——图片雷达

Cesium实战系列文章总目录传送门

1.实现效果

在这里插入图片描述

2.实现方法

通过entity方式创建圆形,并使用回调函数旋转材质即可实现图片雷达效果。

具体代码如下,包含了旋转材质的函数和设创建图片雷达的函数。有关旋转材质的详细介绍可参考之前的博客:旋转圆效果。

// 图片雷达
let rader = this.viewer.entities.add({
    position: Cesium.Cartesian3.fromDegrees(113.9236839, 22.528061),
    name: '图片雷达',
    ellipse: {
        semiMajorAxis: 1000.0,
        semiMinorAxis: 1000.0,
        material: new Cesium.ImageMaterialProperty({
            image: './icons/radar.png',
            color: new Cesium.Color(1.0, 1.0, 0.0, 0.7),
        }),
        // 不设置高度则无法渲染外框线
        height: 20.0,
        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
        outline: true,
        outlineColor: new Cesium.Color(1.0, 1.0, 0.0, 1.0)
    }
})

rotateMaterial(rader.ellipse, 0, -3);

/**
 * @description: 旋转材质
 * @param {*} instance :实体
 * @param {*} _stRotation : 初始材质旋转角度
 * @param {*} _amount :旋转角度变化量
 * @return {*}
 */
function rotateMaterial(instance, _stRotation, _amount) {
    instance.stRotation = new Cesium.CallbackProperty(function() {
        _stRotation += _amount;
        if (_stRotation >= 360 || _stRotation <= -360) {
            _stRotation = 0;
        }
        return Cesium.Math.toRadians(_stRotation);
    }, false)
}
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

右弦GISer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值