import { Epsilon } from "../../Maths/math.constants.js";
/**
 * Limits for geospatial camera
 */
export class GeospatialLimits {
    /**
     * @param planetRadius The radius of the planet
     */
    constructor(planetRadius) {
        this._radiusMin = 10;
        this._radiusMax = Infinity;
        /** Gets the minimum pitch angle (angle from horizon) -- 0 means looking straight down at planet */
        this.pitchMin = Epsilon;
        /**  Gets the maximum pitch angle (angle from horizon) -- Pi/2 means looking at horizon */
        this.pitchMax = Math.PI / 2 - Epsilon;
        /** Gets the minimum yaw angle (rotation around up axis) */
        this.yawMin = -Infinity;
        /** Gets the maximum yaw angle (rotation around up axis) */
        this.yawMax = Infinity;
        /**
         * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
         * Basically if your fingers moves away from more than this distance you will be considered
         * in pinch mode.
         */
        this.pinchToPanMax = 20;
        this._planetRadius = planetRadius;
        this.radiusMax = planetRadius * 4;
    }
    get radiusMin() {
        return this._radiusMin;
    }
    /**
     * Sets the minimum radius
     */
    set radiusMin(value) {
        this._radiusMin = value;
    }
    get radiusMax() {
        return this._radiusMax;
    }
    /**
     * Sets the maximum radius
     */
    set radiusMax(value) {
        this._radiusMax = value;
    }
    /**
     * Gets the planet radius used for altitude/radius conversions
     */
    get planetRadius() {
        return this._planetRadius;
    }
    /** Sets the planet radius and updates the radius limits to maintain current altitude */
    set planetRadius(value) {
        this._planetRadius = value;
    }
    /**
     * Clamps a zoom distance to respect the radius limits.
     * @param zoomDistance The requested zoom distance (positive = zoom in, negative = zoom out)
     * @param currentRadius The current camera radius
     * @param distanceToTarget Optional distance to the zoom target point (used for zoom-in clamping)
     * @returns The clamped zoom distance
     */
    clampZoomDistance(zoomDistance, currentRadius, distanceToTarget) {
        if (zoomDistance > 0) {
            // Zooming IN - don't zoom past the surface or below radiusMin
            const maxZoomIn = (distanceToTarget ?? currentRadius) - this._radiusMin;
            return Math.min(zoomDistance, Math.max(0, maxZoomIn));
        }
        else {
            // Zooming OUT - don't exceed radiusMax
            const maxZoomOut = this._radiusMax - currentRadius;
            return Math.max(zoomDistance, -Math.max(0, maxZoomOut));
        }
    }
}
//# sourceMappingURL=geospatialLimits.js.map