We shall use a projected plane for illustration. The intersection of the plane with the scene surface is a planar curve called the strip, which is observed by the camera. By using triangulation we get the depth map of the surface points under the strip. Distance is obtained as a function of the time taken by the wave to hit a surface and come back. Other phase difference sensors measure the phase shift of the observed return beam.
Distance is a function of the phase difference.
Once the best focused image is determined, a model linking focus values and distance yields the distance.