import Viewport from '../viewports/viewport';
import { getMeterZoom } from '@math.gl/web-mercator';
import { Matrix4, _SphericalCoordinates as SphericalCoordinates } from '@math.gl/core';
export default class FirstPersonViewport extends Viewport {
  constructor(props) {
    const {
      longitude,
      latitude,
      modelMatrix,
      bearing = 0,
      pitch = 0,
      up = [0, 0, 1]
    } = props;
    const spherical = new SphericalCoordinates({
      bearing,
      pitch: pitch === -90 ? 0.0001 : 90 + pitch
    });
    const dir = spherical.toVector3().normalize();
    const center = modelMatrix ? new Matrix4(modelMatrix).transformAsVector(dir) : dir;
    const zoom = Number.isFinite(latitude) ? getMeterZoom({
      latitude: latitude
    }) : 0;
    const scale = Math.pow(2, zoom);
    const viewMatrix = new Matrix4().lookAt({
      eye: [0, 0, 0],
      center,
      up
    }).scale(scale);
    super({ ...props,
      zoom,
      viewMatrix
    });
    this.longitude = void 0;
    this.latitude = void 0;
    this.latitude = latitude;
    this.longitude = longitude;
  }

}
//# sourceMappingURL=first-person-viewport.js.map