Heat engine in the three-dimensional spacetime