cesium实现动态圆效果之——旋转圆

该博客介绍了如何在Cesium中通过设置实体材质的stRotation属性来实现圆的动态旋转效果。作者详细讲解了官方文档中的相关属性,并提供了一个核心函数`rotateMaterial`,该函数接收实体、初始旋转角度和角度变化量作为参数,实现材质的动态更新。通过代码调用,创建并旋转了一个使用SVG图像作为材质的圆。
摘要由CSDN通过智能技术生成


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

1.实现效果

在这里插入图片描述

2.实现方法

旋转圆效果不能直接旋转圆实体,而是旋转其材质,才能实现效果。

2.1官方文档

首先看一下官方文档,发现有设置实体纹理材质逆时针旋转调度的属性stRotation传送门
在这里插入图片描述

2.2具体实现

使用回调函数设置其材质动态旋转,再调用即可。

2.2.1核心函数
/**
* @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)
}
2.2.2代码调用
// 旋转圆
let circleRotate = this.viewer.entities.add({
    position: Cesium.Cartesian3.fromDegrees(113.9236839, 22.528061),
    id: 'circleRotateTest',
    ellipse: {
        semiMinorAxis: 1000.0,
        semiMajorAxis: 1000.0,
        material: new Cesium.ImageMaterialProperty({
            image: './icons/circle_rotate.svg'
        })
    }
})
rotateMaterial(circleRotate.ellipse, 0, 1);
  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

右弦GISer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值