utils/geometry/plane.js
function distanceAAShapeAndPoint(shape, point) {
    const dx = Math.max(Math.abs(shape.pos.x - point.x) - (shape.w / 2), 0);
    const dy = Math.max(Math.abs(shape.pos.y - point.y) - (shape.h / 2), 0);
    return Math.sqrt(dx * dx + dy * dy);
}
function distanceAAShapeAndPoint(shape, point) {
    const dx = Math.max(Math.abs(shape.pos.x - point.x) - (shape.w / 2), 0);
    const dy = Math.max(Math.abs(shape.pos.y - point.y) - (shape.h / 2), 0);
    return Math.sqrt(dx * dx + dy * dy);
}
function distanceAAShapeAndPoint ( shape , point ) { const dx = Math . max ( Math . abs ( shape . pos . x - point . x ) - ( shape . w / 2 ) , 0 ) ; const dy = Math . max ( Math . abs ( shape . pos . y - point . y ) - ( shape . h / 2 ) , 0 ) ; return Math . sqrt ( dx * dx + dy * dy ) ; }
AA = Axis Aligned, distance from point to AA shape
@param {{ pos: Point2D, w, h }} shape AA Shape
@param {Point2D} point map position
AA = Axis Aligned distance from point to AA shape