function compareTiles(prevBestTile, tile, interestingPoint) {
        if (!prevBestTile) {
            return tile;
        }
        if (tile.visibility > prevBestTile.visibility) {
            return tile;
        } else if (tile.visibility === prevBestTile.visibility) {
            if (interestingPoint instanceof Malakh.Point) {
                var tileDistance = interestingPoint.distanceTo(tile.targetCenter);
                var prevBestTileDistance = interestingPoint.distanceTo(prevBestTile.targetCenter);
                if (tileDistance < prevBestTileDistance) {
                    return tile;
                }
            }
        }
        return prevBestTile;
    }
/**
     * <p>Figures out if this tile is "better" than the previous best tile and returns the result.
     * Note that if there is no <code>prevBestTile</code>, the given one is automatically chosen.
     *
     * <p>Choosing algorithm relies on comparing level visibility and - if it's the same - distance
     * to the <code>interestingPoint</code>, if one exists (if it doesn't and visibility is the same,
     * <code>prevBestTile</code> is returned).
     *
     * @param {Malakh.Tile} prevBestTile The best tile so far.
     * @param {Malakh.Tile} tile A tile that "tries" to be better than <code>prevBestTile</code>.
     * @param {Malakh.Point} [interestingPoint] The point near which we prefer to draw tiles. Usually
     *                                             either the middle of the viewport or current mouse position.
     * @return {Malakh.Tile} The "better" tile.
     * @private
     */
Figures out if this tile is "better" than the previous best tile and returns the result.
Note that if there is no prevBestTile, the given one is automatically chosen.

Choosing algorithm relies on comparing level visibility and - if it's the same - distance
to the interestingPoint, if one exists (if it doesn't and visibility is the same,
prevBestTile is returned).

@param {Malakh.Tile} prevBestTile The best tile so far.
@param {Malakh.Tile} tile A tile that "tries" to be better than prevBestTile.
@param {Malakh.Point} [interestingPoint] The point near which we prefer to draw tiles. Usually
either the middle of the viewport or current mouse position.
@return {Malakh.Tile} The "better" tile.
@private
Figures out if this tile is " better " than the previous best tile and returns the result . Note that if there is no prevBestTile the given one is automatically chosen . Choosing algorithm relies on comparing level visibility and - if it ' s the same - distance to the interestingPoint if one exists ( if it doesn ' t and visibility is the same prevBestTile is returned ) . @param { Malakh . Tile } prevBestTile The best tile so far . @param { Malakh . Tile } tile A tile that " tries " to be better than prevBestTile . @param { Malakh . Point } [ interestingPoint ] The point near which we prefer to draw tiles . Usually either the middle of the viewport or current mouse position . @return { Malakh . Tile } The " better " tile . @private
function compareTiles(prevBestTile, tile, interestingPoint) {
        if (!prevBestTile) {
            return tile;
        }
        if (tile.visibility > prevBestTile.visibility) {
            return tile;
        } else if (tile.visibility === prevBestTile.visibility) {
            if (interestingPoint instanceof Malakh.Point) {
                var tileDistance = interestingPoint.distanceTo(tile.targetCenter);
                var prevBestTileDistance = interestingPoint.distanceTo(prevBestTile.targetCenter);
                if (tileDistance < prevBestTileDistance) {
                    return tile;
                }
            }
        }
        return prevBestTile;
    }
function compareTiles ( prevBestTile , tile , interestingPoint ) { if ( ! prevBestTile ) { return tile ; } if ( tile . visibility > prevBestTile . visibility ) { return tile ; } else if ( tile . visibility === prevBestTile . visibility ) { if ( interestingPoint instanceof Malakh . Point ) { var tileDistance = interestingPoint . distanceTo ( tile . targetCenter ) ; var prevBestTileDistance = interestingPoint . distanceTo ( prevBestTile . targetCenter ) ; if ( tileDistance < prevBestTileDistance ) { return tile ; } } } return prevBestTile ; }
<p>Figures out if this tile is "better" than the previous best tile and returns the result.
<p > Figures out if this tile is " better " than the previous best tile and returns the result .