Optical manipulation of electronic dimensionality in a quantum material