Evolution of singularities of potential flows in collision-free media and the metamorphosis of caustics in three-dimensional space