在一些场景下,需要实现基于三维场景中的指定位置做绕点旋转的效果,其实质还是在控制相机的orientation参数。沿这个方向,所实现的基本效果如下,
完整示例代码如下,
(1)核心类:CameraRevolve.js
//相机-绕点旋转
class CameraRevolve {
//properties
_viewer
_amount
_position
_height
constructor(viewer, amount, position,height=5000.0) {
this._viewer = viewer
this._amount = amount
this._position = position
this._height = height;
}
_bindEvent() {
this._viewer.clock.onTick.addEventListener(this._aroundPoint, this)
}
_unbindEvent() {
this._viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)
this._viewer.clock.onTick.removeEventListener(this._aroundPoint, this)
}
//相机指北
pointNorth(){
this._viewer.camera.setView({
orientation: {
headin