import { Cartesian3, EasingFunction } from "cesium";
import { useCesium } from "resium";

function CustomFlyTo() {
  const { viewer, camera } = useCesium();

  function cameraFlyToLine() {
    const area1Options = {
      destination: Cartesian3.fromDegrees(-110, -86, 10000000),
      duration: 2,
      orientation: {
        heading: 6,
        pitch: -1.3,
        roll: -6,
      },
      complete: function () {
        viewer.clock.shouldAnimate = true;
        setTimeout(() => {
          camera.flyTo(area2Options);
        }, 2000);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const area2Options = {
      destination: Cartesian3.fromDegrees(-30, -85, 10000000),
      // destination: Cartesian3.fromDegrees(-30, -65, 10000000),
      duration: 5,
      complete: function () {
        camera.flyTo(area3Options);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
      orientation: {
        heading: 6,
        pitch: -1.3,
        roll: -6,
      },
    };

    const area3Options = {
      destination: Cartesian3.fromDegrees(40, -75, 10000000),
      duration: 5,
      complete: function () {
        camera.flyTo(area4Options);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
      orientation: {
        heading: 5.8,
        pitch: -1.3,
        roll: -6,
      },
    };

    const area4Options = {
      destination: Cartesian3.fromDegrees(65, -65, 10000000),
      duration: 4,
      orientation: {
        heading: 6,
        pitch: -1.3,
        roll: -6,
      },
      complete: function () {
        camera.flyTo(area5Options);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const area5Options = {
      destination: Cartesian3.fromDegrees(95, -35, 10000000),
      duration: 4,
      complete: function () {
        setTimeout(() => {
          camera.flyTo(IndiaOceanOptions);
        }, 2000);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const IndiaOceanOptions = {
      destination: Cartesian3.fromDegrees(80, 0, 14000000),
      duration: 3,
      complete: function () {
        setTimeout(() => {
          camera.flyTo(QTPlateauOption);
        }, 3000);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const QTPlateauOption = {
      destination: Cartesian3.fromDegrees(88, 18, 5000000),
      duration: 2,
      orientation: {
        heading: 6,
        pitch: -1.3,
        roll: -6,
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const xx = {
      destination: Cartesian3.fromDegrees(95, -35, 10000000),
      duration: 4,

      easingFunction: EasingFunction.LINEAR_NONE,
    };

    // camera.flyTo(xx);
    camera.flyTo(area1Options);
  }
  cameraFlyToLine();
  return <></>;
}

export default CustomFlyTo;
