1. Mapping apparatus, comprising: a transmitter, which is configured to emit a beam comprising pulses of light; a scanner, which is configured to scan the beam, within a predefined scan range, over a scene, wherein the scanner is a micro-electro-mechanical systems (MEMS) device and comprises: a substrate, which comprises a micromirror and a support, along with spindles connecting the micromirror to the support along a first axis, while the support is configured to rotate about a second axis; and an electromagnetic drive, which causes the micromirror and the support to rotate about the first and second axes, wherein the electromagnetic drive causes the micromirror to rotate about the first axis at a first frequency, which is a resonant frequency of rotation, while causing the support to rotate about the second axis at a second frequency, which is lower than the first frequency, wherein the transmitter is configured to direct the beam to reflect from the micromirror toward the scene; a receiver, which is configured to receive the light reflected from the scene and to generate an output indicative of a time of flight of the pulses to and from points in the scene; and a processor, which is coupled to control the scanner so as to cause the beam to scan over a selected window within the scan range and to process the output of the receiver so as to generate a 3D map of a part of the scene that is within the selected window.