import { Globe } from './globe';
import { Renderer } from './renderer';
import { DirectionalLight } from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import './style.css';

const main = new Renderer();

const dirLight = new DirectionalLight(0xffffff, 1);
dirLight.position.set(10, 10, 10);
main.scene.add(dirLight);

const globe = new Globe();
main.resize();
globe.initialize(dirLight).catch(console.error);
main.scene.add(globe);

main.camera.position.set(0, 0, 2);

const control = new OrbitControls(main.camera, main.canvas);

function tick() {
  requestAnimationFrame(tick);
  control.update();
  // globe.rotateY(Math.PI * 0.0005);
  main.render();
  globe.tick();
}

window.addEventListener('resize', () => main.resize());
document.querySelector('#app')?.appendChild(main.canvas);
tick();
