A photon is emitted from a source and reflected off an object (or objects) until it hits the human eye. The color of the object we see depends on the photon wavelength. If photon travels with constant speed how does the human eye know how far the object from which the photon was reflected?
To have depth perception two eyes are needed. Our two eyes are some distance apart which causes the photons from an object to arrive at slightly different angles. The brain then reconstructs the depth field from these differences.
Similarly, we can figure out how far nearby stars are by using images made by a telescope at two different times of the year, since when the earth is (for example) at two opposite positions of its orbit around the sun, it acts like two "eyes" that are a large distance apart.
Binocular vision has already been discussed, but it left out an important aspect.
A single eye is sensitive to distance. The shape of the lens changes to focus on near/far objects.
The reason this is needed is that our pupil has finite size and cannot be modeled as a pinhole. The same physics is going on here as in a lens of a camera focusing on an object. The rays coming from objects will be focused at different points depending on their distance to the eye; only those objects whose rays are focused on the retina are in focus.
So, in principle, one could use the shape of the lens to determine distance to an object.