Face ID projects 30k infrared dots in a users face and captures the resulting image with an infrared camera. This allows the device to calculate a three dimensional representation of the face. The technology is similar to Microsoft’s Kinect .
Apple has an amazing demo app to visualize the capabilities of this technology. My mug in 3D with a computed panned angle of the front camera: