I think it uses a variant of Iterated Closest Point* for that. It's cool to watch it do its thing.
*https://en.wikipedia.org/wiki/Iterative_closest_point