Two cameras, one scene. The shift between the two views — disparity — is inversely proportional to depth. Drag the object closer and watch disparity grow. Squint at the canvases and see in 3D yourself.
Where f is focal length (in pixels), B is the baseline (distance between cameras), and d is the disparity (how far the same point shifts between left and right images).
Move the object slider to bring it closer/farther. The two camera views show the same scene from slightly different angles. The disparity map (right) shows the per-pixel shift — bright = close, dark = far.
A wider baseline (cameras spread further apart) gives you more disparity per unit depth — better for far objects. But it also shrinks the overlap region between left and right views. Stereo rigs are a compromise:
Active stereo (Intel RealSense, Microsoft Kinect) projects an IR speckle pattern so even blank walls become matchable. ToF (time-of-flight) skips the matching problem entirely by measuring how long the light takes to come back — but it's noisier and lower resolution.