Three-dimensional approach to scanning tunneling spectroscopy and application to Shockley states