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);