A three-dimensional scanner for obtaining shape information of an object body includes a light source unit, a varifocal unit, a reference unit, a light path length adjustment unit, an optical sensor, and a control unit. The varifocal unit is able to change a focal position, and both of light from the light source unit to the optical sensor via an object body and light from the light source unit to the optical sensor via the reference unit travel at least once. The control unit determines a condition of varifocal unit based on light has been reflected on reference unit and detected by a part of optical sensor, and calculates the shape information of the object body from light detected by the optical sensor using information of the condition of the varifocal unit that has been determined.