interface IFlyTo {
  lon: number
  lat: number
  alt?: number
  heading?: number
  pitch?: number
  roll?: number
  duration?: number
}
export const useEarth = () => {
  return { flyTo }
}

function flyTo({
  lon,
  lat,
  alt = 1000000,
  heading,
  pitch,
  roll,
  duration = 2,
}: IFlyTo) {
  viewer.camera.flyTo({
    // 从以度为单位的经度和纬度值返回笛卡尔3位置。
    destination: Cesium.Cartesian3.fromDegrees(lon, lat, alt),
    orientation: {
      heading: Cesium.Math.toRadians(heading ?? 0.0),
      pitch: Cesium.Math.toRadians(pitch ?? -90),
      roll: Cesium.Math.toRadians(roll ?? 0.0),
    },
    duration,
  })
}
