I draw this cube, and dashed lines I have to draw by hand.
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{120}
\begin{tikzpicture}[tdplot_main_coords,declare function={a=3;
}]
\path
(a,-a,-a) coordinate (A)
(a,a,-a) coordinate (B)
(-a,a,-a) coordinate (C)
(-a,-a,-a) coordinate (D)
(a,-a,a) coordinate (E)
(a,a,a) coordinate (F)
(-a,a,a) coordinate (G)
(-a,-a,a) coordinate (H)
(0,0,0) coordinate (O)
;
\draw (E) -- (A) -- (B) --(C) -- (G) -- (H) -- (E) (E) -- (F) -- (G) (B) -- (F);
\draw[dashed] (A) -- (D) -- (C) (D) -- (H);
%\path foreach \p/\g in {A/-90,B/90,C/0,D/0,E/0,F/0,G/0,H/0}{(\p)node{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}
How to draw dashed lines automatically of a cube when I rotate the cube like this


