import { Component, OnInit } from '@angular/core';
import { ViewerService } from 'src/app/services';

@Component({
  selector: 'app-fly-manager',
  templateUrl: './fly-manager.component.html',
  styleUrls: ['./fly-manager.component.css']
})
export class FlyManagerComponent implements OnInit {

  private viewer;
  private flyManager;
  private flyMnaagerOptions;

  constructor(
    private viewerService: ViewerService,
  ) {
  }

  ngOnInit() {
    this.viewer = this.viewerService.viewer;
    this.flyMnaagerOptions = {
      perspective: smart3d.FlyPerspective.THIRD,
      duration: 100,
      infinite: false,
      // camera: { followX: 200, followZ: 100 }, // FlyPerspective.FIRST
      path: { width: 4, material: new Cesium.PolylineGlowMaterialProperty({ color: Cesium.Color.RED }) },
      point: { pixelSize: 0 },
      model: { uri: 'assets/models/boat.gltf' },
      // label
      // site
    };
    this.flyManager = new smart3d.FlyManager(this.viewer, this.flyMnaagerOptions);
  }

  handleDrawPath(options: {
    clampToGround?: boolean
  }) {
    this.flyManager.drawNewRoute({
      isGround: undefined !== options.clampToGround ? options.clampToGround : true,
    });
  }

  startFly() {
    this.flyManager.start();
  }

}
