Rigidity of three-dimensional lattices and dimension reduction in heterogeneous nanowires