The neuromechanical control of Caenorhabditis elegans head motor behaviour in 3D environments