import { useCesium } from "resium";

function AntarcticaFlytoQTP() {
  const { viewer } = useCesium();
  const { camera } = viewer;

  function cameraFlyToLine(adjustPitch) {
    // 南极
    const antarcticalOptions = {
      destination: Cesium.Cartesian3.fromDegrees(88, -89, 1600000),
      orientation: {
        heading: Cesium.Math.toRadians(15.0),
        pitch: Cesium.Math.toRadians(-60),
        roll: 0.0,
      },
      duration: 10,
      complete: function () {
        setTimeout(() => {
          camera.flyTo(area1Options);
        }, 1000);
      },
    };

    const area1Options = {
      destination: Cesium.Cartesian3.fromDegrees(-110, -60, 6000000),
      duration: 5,
      complete: function () {
        setTimeout(function () {
          camera.flyTo(area2Options);
        }, 1000);
      },
    };

    const area2Options = {
      destination: Cesium.Cartesian3.fromDegrees(-30, -55, 6000000),
      duration: 5,
      complete: function () {
        setTimeout(function () {
          camera.flyTo(area3Options);
        }, 1000);
      },
    };

    const area3Options = {
      destination: Cesium.Cartesian3.fromDegrees(30, -40, 6000000),
      duration: 5,
      complete: function () {
        setTimeout(function () {
          camera.flyTo(area4Options);
        }, 1000);
      },
    };

    const area4Options = {
      destination: Cesium.Cartesian3.fromDegrees(65, -35, 6000000),
      duration: 5,
      complete: function () {
        setTimeout(function () {
          camera.flyTo(sideViewOptions);
        }, 1000);
      },
    };

    // 青藏高原
    const plateauOptions = {
      destination: Cesium.Cartesian3.fromDegrees(95, -30, 6000000),
      duration: 10,
      orientation: {
        heading: Cesium.Math.toRadians(-15.0),
        pitch: -Cesium.Math.PI_OVER_FOUR,
        roll: 0.0,
      },
      complete: function () {
        setTimeout(function () {
          camera.flyTo(sideViewOptions);
        }, 1000);
      },
    };

    // 侧边
    const sideViewOptions = {
      destination: Cesium.Cartesian3.fromDegrees(70, -60, 14000000),
      // destination: Cesium.Cartesian3.fromDegrees(130, -10.5, 20000000),
      duration: 5,
      orientation: {
        heading: Cesium.Math.toRadians(-10.0),
        pitch: Cesium.Math.toRadians(-90),
        roll: 6.0,
      },
      complete: () => {
        viewer.clock.shouldAnimate = true;
      },
    };

    if (adjustPitch) {
      antarcticalOptions.pitchAdjustHeight = 1000;
      plateauOptions.pitchAdjustHeight = 1000;
      sideViewOptions.pitchAdjustHeight = 1000;
    }
    camera.flyTo(antarcticalOptions);
  }
  cameraFlyToLine();
  return <></>;
}

export default AntarcticaFlytoQTP;
