cesium常见特效之:从上角度,绕地面旋转漫游
一、实现思路:
绕着地面旋转漫游,实际上就是相机角度绕着地面旋转,只需要动态更改相机的heading属性,用camera类的setView方法更改这个属性值即可。
二、主要实现代码:
vue页面中使用:引入xuanzhuan.js文件:
import Xuanzhuan from './component/Xuanzhuan';
开始旋转的入口处,调用该类:
let xuanzhuan= new Xuanzhuan(viewer, 0.2);
xuanzhuan.start();
vue工程中建立xuanzhuan.js文件:
/*
* @Description: 相机绕地旋转
*/
class Xuanzhuan{
constructor(viewer, amount) {
this._viewer = viewer;
this._amount = amount;
}
// 绑定事件
_bindEvent() {
this._viewer.clock.onTick.addEventListener(this._aroundView, this);
}
// 解除绑定
_unbindEvent() {
this._viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
this._vie