Three-dimensional background field gravity: a Hamilton--Jacobi analysis