Phase separation during the formation of three-dimensional polymers