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

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

  function cameraFlyToLine() {
    const step1 = {
      destination: Cartesian3.fromDegrees(-10, 50, 6000000),
      duration: 5,
      complete: () => {
        camera.flyTo(step2);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    const step2 = {
      destination: Cartesian3.fromDegrees(35, 49, 10000000),
      duration: 8,
      complete: () => {
        camera.flyTo(barotorpic);
      },
      easingFunction: EasingFunction.LINEAR_NONE,
    };

    // barotorpic
    const barotorpic = {
      destination: Cartesian3.fromDegrees(75, 48, 15000000),
      duration: 7,
      complete: () => {},
      easingFunction: EasingFunction.LINEAR_NONE,
      orientation: {
        heading: 6.283,
        pitch: -1.569,
        roll: 0.45,
      },
    };

    // 俯视看箭头上升
    const sideViewOptions = {
      destination: Cartesian3.fromDegrees(-50, 46, 2000000),
      duration: 5,
      orientation: {
        heading: Math.toRadians(-15.0),
        pitch: -Math.PI_OVER_FOUR,
        roll: 0.0,
      },
      complete: () => {
        viewer.clock.shouldAnimate = true;
        setTimeout(function () {
          camera.flyTo(step1);
        }, 5000);
      },
    };

    camera.flyTo(sideViewOptions);
  }
  cameraFlyToLine();

  return <></>;
}

export default CustomFlyTo;
