答案1
这确实很简单。更新:简化代码。
\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\definecolor{darkgreen}{rgb}{0.0, 0.8, 0.2}
\newcommand{\TranslucentPlane}[3][]{
\draw[fill=#3!70,opacity=0.6] (-3,-3,#2) -- (-3,3,#2) -- (3,3,#2) -- (3,-3,#2) -- cycle;
\draw[fill=#3!40,opacity=0.6] (-3,3,#2) -- (3,3,#2) -- (3,3,{#2+0.2}) -- (-3,3,{#2+0.2})
-- cycle;
\draw[fill=#3!40,opacity=0.6] (-3,3,#2) -- (-3,-3,#2) -- (-3,-3,{#2+0.2}) -- (-3,3,{#2+0.2})
-- cycle;
\draw[fill=#3!40,opacity=0.6] (-3,-3,{#2+0.2}) -- (-3,3,{#2+0.2}) -- (3,3,{#2+0.2}) --
(3,-3,{#2+0.2}) -- cycle;
\draw[fill=#3!40,opacity=0.6] (3,-3,#2) -- (3,3,#2) -- (3,3,{#2+0.2}) -- (3,-3,{#2+0.2})
-- cycle;
\draw[fill=#3!40,opacity=0.6] (3,-3,#2) -- (-3,-3,#2) -- (-3,-3,{#2+0.2}) --
(3,-3,{#2+0.2})
-- cycle;
}
\begin{document}
\tdplotsetmaincoords{70}{40}
\begin{tikzpicture}[tdplot_main_coords]
\tdplotsetrotatedcoords{0}{00}{0}
\begin{scope}[tdplot_rotated_coords]
\foreach \Z/\Col in {1/black,2/gray,3/blue,4/blue,5/darkgreen,6/darkgreen}
{
\TranslucentPlane{\Z}{\Col}
}
\end{scope}
\end{tikzpicture}
\end{document}
旧答案:
\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{40}
\begin{tikzpicture}[tdplot_main_coords]
\tdplotsetrotatedcoords{0}{00}{0}
\begin{scope}[tdplot_rotated_coords]
\foreach \Z in {1}
{
\draw[fill=black!70,opacity=0.6] (-3,-3,\Z) -- (-3,3,\Z) -- (3,3,\Z) -- (3,-3,\Z) -- cycle;
\draw[fill=black!40,opacity=0.6] (-3,3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=black!40,opacity=0.6] (-3,3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=black!70,opacity=0.6] (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2}) -- (3,3,{\Z+0.2}) --
(3,-3,{\Z+0.2}) -- cycle;
\draw[fill=black!40,opacity=0.6] (3,-3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (3,-3,{\Z+0.2})
-- cycle;
\draw[fill=black!40,opacity=0.6] (3,-3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) --
(3,-3,{\Z+0.2})
-- cycle;
}
\foreach \Z in {2}
{
\draw[fill=gray!70,opacity=0.6] (-3,-3,\Z) -- (-3,3,\Z) -- (3,3,\Z) -- (3,-3,\Z) -- cycle;
\draw[fill=gray!40,opacity=0.6] (-3,3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=gray!40,opacity=0.6] (-3,3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=gray!70,opacity=0.6] (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2}) -- (3,3,{\Z+0.2}) --
(3,-3,{\Z+0.2}) -- cycle;
\draw[fill=gray!40,opacity=0.6] (3,-3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (3,-3,{\Z+0.2})
-- cycle;
\draw[fill=gray!40,opacity=0.6] (3,-3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) --
(3,-3,{\Z+0.2})
-- cycle;
}
\foreach \Z in {3,4}
{
\draw[fill=blue!70,opacity=0.6] (-3,-3,\Z) -- (-3,3,\Z) -- (3,3,\Z) -- (3,-3,\Z) -- cycle;
\draw[fill=blue!40,opacity=0.6] (-3,3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=blue!40,opacity=0.6] (-3,3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=blue!70,opacity=0.6] (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2}) -- (3,3,{\Z+0.2}) --
(3,-3,{\Z+0.2}) -- cycle;
\draw[fill=blue!40,opacity=0.6] (3,-3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (3,-3,{\Z+0.2})
-- cycle;
\draw[fill=blue!40,opacity=0.6] (3,-3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) --
(3,-3,{\Z+0.2})
-- cycle;
}
\foreach \Z in {5,6}
{
\draw[fill=green!70,opacity=0.6] (-3,-3,\Z) -- (-3,3,\Z) -- (3,3,\Z) -- (3,-3,\Z) -- cycle;
\draw[fill=green!40,opacity=0.6] (-3,3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=green!40,opacity=0.6] (-3,3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2})
-- cycle;
\draw[fill=green!70,opacity=0.6] (-3,-3,{\Z+0.2}) -- (-3,3,{\Z+0.2}) -- (3,3,{\Z+0.2}) --
(3,-3,{\Z+0.2}) -- cycle;
\draw[fill=green!40,opacity=0.6] (3,-3,\Z) -- (3,3,\Z) -- (3,3,{\Z+0.2}) -- (3,-3,{\Z+0.2})
-- cycle;
\draw[fill=green!40,opacity=0.6] (3,-3,\Z) -- (-3,-3,\Z) -- (-3,-3,{\Z+0.2}) --
(3,-3,{\Z+0.2})
-- cycle;
}
\end{scope}
\end{tikzpicture}
\end{document}