import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { ViewerService } from './viewer.service';

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

  private viewer;
  @ViewChild('ref', { static: true }) divRef: ElementRef;

  constructor(
    private viewerService: ViewerService,
  ) {
    // this.viewer = undefined;
  }

  ngOnInit(): void {
    console.log(this.divRef.nativeElement);
    this.viewer = this.viewerService.initViewer('container', {
      sceneMode: smart3d.SceneMode.SCENE3D,
      scene3DOnly: true,
      terrainProvider: Cesium.createWorldTerrain()
    });
    // this.viewer = new Cesium.Viewer('container');
  }

  handleClick() {
    const distanceHandler = new smart3d.MeasureHandler(this.viewer, smart3d.MeasureMode.Distance);
    distanceHandler.activate();
  }
}
