Invariant imbedding for the wave equation in three dimensions and the applications to the direct and inverse problems