『Cesium 基础』绕点旋转(十五)

实现效果

    ----> 

 

实现原理

实际是通过修改 camera 对象 heading 属性值来实现对指定位置的绕点旋转

代码实现

 1startRotate(viewer, options) {
2        let { heading, pitch, roll } = viewer.camera;
3        let position =
4              Cesium.Cartesian3.fromDegrees(options.lng, options.lat, options.height || 0);
5        this.timer = () => {
6            heading += Cesium.Math.toRadians(options.speed || 0.05);
7            viewer.scene.camera.setView({
8                destination: position, // 点的坐标
9                orientation: {
10                    heading: heading,
11                    pitch: pitch,
12                },
13            });
14        };
15        viewer.clock.onTick.addEventListener(this.timer);
16    },
17    stopRotate() {
18        if (this.timer) this.viewer.clock.onTick.removeEventListener(this.timer);
19    },
posted @ 2022-10-24 09:30  A影子放風箏  阅读(727)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css