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: 5,
      orientation: {
        heading: 6,
        pitch: -1.3,
        roll: -6,
      },
      complete: function () {
        viewer.clock.shouldAnimate = true;
        setTimeout(() => {
          camera.flyTo(area2Options);
        }, 5000);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const area2Options = {
      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(30, -40, 10000000),
      duration: 5,
      complete: function () {
        camera.flyTo(area4Options);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

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

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

export default CustomFlyTo;
