贴个群号
WebGIS学习交流群461555818,欢迎大家
效果
原理与源码
获取角度,然后一直更改角度,角度到达180度后赋值成-180度,然后转到开始获取的角度的角度的时候就停止旋转
function rotateModel(layerID){
let bearing = map.getPaintProperty(layerID,"model-rotation")
let afterBearing = [0,0,bearing[2]+1]
let interval =setInterval(()=>{
if(afterBearing[2] ==bearing[2]){
clearInterval(interval)
}else{
if(afterBearing[2]==180){
afterBearing[2] = -180
map.setPaintProperty(layerID,"model-rotation",afterBearing,)
}else{
afterBearing=[0,0,afterBearing[2]+1]
map.setPaintProperty(layerID,"model-rotation",afterBearing,)
}
}
},0)
}