import { useFrame } from '@react-three/fiber';
import { getScreenArea } from '@game/utils/game/screen-point';
import { world } from '@game/struct/world';
import { isClient } from '@game/const';
import { previewMap } from '@map/lib/utils/preview-map';

if (isClient) {
  // @ts-ignore
  window.world = world;
  // @ts-ignore
  window.previewMap = previewMap;
}

export function useCameraVisibleArea() {
  useFrame((state, delta) => {
    const screenArea = getScreenArea(state.camera);

    world.updateVisibleArea(screenArea);
  });
}
