我想绘制堆叠在一起的立方体。有帮助吗?

我想绘制堆叠在一起的立方体。有帮助吗?

我知道我为 2 x 2 x 2 立方体编写的代码是正确的。但是其余的立方体与 2 x 2 x 2 立方体位于同一平面上。有人能建议如何让 1.8 x 1.8 x 1.8 立方体堆叠在 2 x 2 x 2 立方体之上吗?

\begin{tikzpicture}

    \pgfmathsetmacro{\cubex}{0.4}
    \pgfmathsetmacro{\cubey}{0.4}
    \pgfmathsetmacro{\cubez}{0.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.6}
    \pgfmathsetmacro{\cubey}{0.6}
    \pgfmathsetmacro{\cubez}{0.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.8}
    \pgfmathsetmacro{\cubey}{0.8}
    \pgfmathsetmacro{\cubez}{0.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.0}
    \pgfmathsetmacro{\cubey}{1.0}
    \pgfmathsetmacro{\cubez}{1.0}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.2}
    \pgfmathsetmacro{\cubey}{1.2}
    \pgfmathsetmacro{\cubez}{1.2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.4}
    \pgfmathsetmacro{\cubey}{1.4}
    \pgfmathsetmacro{\cubez}{1.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.6}
    \pgfmathsetmacro{\cubey}{1.6}
    \pgfmathsetmacro{\cubez}{1.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.8}
    \pgfmathsetmacro{\cubey}{1.8}
    \pgfmathsetmacro{\cubez}{1.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

\end{tikzpicture}

答案1

您还可以声明一个新命令(或pic),并附带一些参数来节省输入。

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning}

%#1: optional. Default: fill=white
%#2: origin
%#3: size: cubex=cubey=cubez (it's a cube)
\newcommand{\cube}[3][fill=white]{
    \draw[black, #1] (#2) -- ++(-#3,0,0) -- ++(0,#3,0) -- ++(0,0,-#3) -- ++(#3,0,0) -- ++(0,-#3,0)-- cycle;
    \draw[black,line join=bevel, #1] (#2) -- ++(0,#3,0) -- ++(0,0,-#3) (#2)++(0,#3,0)--++(-#3,0,0);
}

\begin{document}
\begin{tikzpicture}
    \cube[fill=red!30]{0,0,0}{2}
    \cube[fill=green!30]{0,2,0}{1.8}
    \cube[fill=blue!30]{0,3.8,0}{1.6}
    \cube[fill=pink!30]{0,5.4,0}{1.4}
    \cube[fill=orange!30]{0,6.8,0}{1.2}
    \cube[fill=violet!30]{0,8,0}{1}
    \cube[fill=brown!30]{0,9,0}{.8}
    \cube[fill=purple!30]{0,9.8,0}{.6}
    \cube[fill=cyan!30]{0,10.4,0}{.4}


\begin{scope}[xshift=3cm]
    \cube[fill=red!30]{0,0,0}{2}
    \cube[fill=green!30]{-.2,2,-.2}{1.8}
    \cube[fill=blue!30]{-.4,3.8,-.4}{1.6}
    \cube[fill=pink!30]{-.6,5.4,-.6}{1.4}
    \cube[fill=orange!30]{-.8,6.8,-.8}{1.2}
    \cube[fill=violet!30]{-1,8,-1}{1}
    \cube[fill=brown!30]{-1.2,9,-1.2}{.8}
    \cube[fill=purple!30]{-1.4,9.8,-1.4}{.6}
    \cube[fill=cyan!30]{-1.6,10.4,-1.6}{.4}
\end{scope}

\begin{scope}[xshift=6cm]
    \cube[fill=red!30]{0,0,0}{2}
    \cube[fill=green!30]{-.1,2,-.1}{1.8}
    \cube[fill=blue!30]{-.2,3.8,-.2}{1.6}
    \cube[fill=pink!30]{-.3,5.4,-.3}{1.4}
    \cube[fill=orange!30]{-.4,6.8,-.4}{1.2}
    \cube[fill=violet!30]{-.5,8,-.5}{1}
    \cube[fill=brown!30]{-.6,9,-.6}{.8}
    \cube[fill=purple!30]{-.7,9.8,-.7}{.6}
    \cube[fill=cyan!30]{-.8,10.4,-.8}{.4}
\end{scope}
\end{tikzpicture}\end{document}

在此处输入图片描述

答案2

使用针对立方体每一面定义的命令进行编辑

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand\DrawXY[5][white]{\draw[black,fill=#1,shift={#2}] ({-#3/2},{-#4/2},{#5/2}) --({#3/2},{-#4/2},{#5/2}) --({#3/2},{#4/2},{#5/2}) --({-#3/2},{#4/2},{#5/2})-- cycle;}
\newcommand\DrawYZ[5][white]{\draw[black,fill=#1,shift={#2}] ({#3/2},{-#4/2},{#5/2}) --({#3/2},{-#4/2},{-#5/2}) --({#3/2},{#4/2},{-#5/2}) --({#3/2},{#4/2},{#5/2})-- cycle;}
\newcommand\DrawXZ[5][white]{\draw[black,fill=#1,shift={#2}] ({-#3/2},{#4/2},{#5/2}) --({#3/2},{#4/2},{#5/2}) --({#3/2},{#4/2},{-#5/2}) --({-#3/2},{#4/2},{-#5/2}) -- cycle;}
\begin{document}
\begin{tikzpicture}
\xdef\myX{2}
\xdef\myY{2}
\xdef\myZ{2}
\xdef\prevY{0}
\xdef\pscale{1}
\foreach \scale[count=\j from 0] in {1.,0.9,...,0.1}{%
\pgfmathsetmacro\myYY{\prevY+(\pscale*\myY)}
\DrawXY[red]{(0,{\myYY},0)}{\scale*\myX}{\scale*\myY}{\scale*\myZ}
\DrawYZ[red!90]{(0,{\myYY},0)}{\scale*\myX}{\scale*\myY}{\scale*\myZ}
\DrawXZ[red!80]{(0,{\myYY},0)}{\scale*\myX}{\scale*\myY}{\scale*\myZ}
\xdef\prevY{\myYY}%
\xdef\pscale{\scale}
}
\end{tikzpicture}
\end{document}

输出:

在此处输入图片描述

scope只需在s内添加代码和一个shift加号scale

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
    \pgfmathsetmacro{\cubex}{0.4}
    \pgfmathsetmacro{\cubey}{0.4}
    \pgfmathsetmacro{\cubez}{0.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.6}
    \pgfmathsetmacro{\cubey}{0.6}
    \pgfmathsetmacro{\cubez}{0.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.8}
    \pgfmathsetmacro{\cubey}{0.8}
    \pgfmathsetmacro{\cubez}{0.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.0}
    \pgfmathsetmacro{\cubey}{1.0}
    \pgfmathsetmacro{\cubez}{1.0}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.2}
    \pgfmathsetmacro{\cubey}{1.2}
    \pgfmathsetmacro{\cubez}{1.2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.4}
    \pgfmathsetmacro{\cubey}{1.4}
    \pgfmathsetmacro{\cubez}{1.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.6}
    \pgfmathsetmacro{\cubey}{1.6}
    \pgfmathsetmacro{\cubez}{1.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.8}
    \pgfmathsetmacro{\cubey}{1.8}
    \pgfmathsetmacro{\cubez}{1.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{scope}
\begin{scope}[shift={(0,2)},scale=0.9]
    \pgfmathsetmacro{\cubex}{0.4}
    \pgfmathsetmacro{\cubey}{0.4}
    \pgfmathsetmacro{\cubez}{0.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.6}
    \pgfmathsetmacro{\cubey}{0.6}
    \pgfmathsetmacro{\cubez}{0.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.8}
    \pgfmathsetmacro{\cubey}{0.8}
    \pgfmathsetmacro{\cubez}{0.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.0}
    \pgfmathsetmacro{\cubey}{1.0}
    \pgfmathsetmacro{\cubez}{1.0}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.2}
    \pgfmathsetmacro{\cubey}{1.2}
    \pgfmathsetmacro{\cubez}{1.2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.4}
    \pgfmathsetmacro{\cubey}{1.4}
    \pgfmathsetmacro{\cubez}{1.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.6}
    \pgfmathsetmacro{\cubey}{1.6}
    \pgfmathsetmacro{\cubez}{1.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.8}
    \pgfmathsetmacro{\cubey}{1.8}
    \pgfmathsetmacro{\cubez}{1.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{scope}
\begin{scope}[shift={(0,3.8)},scale=0.8]
    \pgfmathsetmacro{\cubex}{0.4}
    \pgfmathsetmacro{\cubey}{0.4}
    \pgfmathsetmacro{\cubez}{0.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.6}
    \pgfmathsetmacro{\cubey}{0.6}
    \pgfmathsetmacro{\cubez}{0.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{0.8}
    \pgfmathsetmacro{\cubey}{0.8}
    \pgfmathsetmacro{\cubez}{0.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.0}
    \pgfmathsetmacro{\cubey}{1.0}
    \pgfmathsetmacro{\cubez}{1.0}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.2}
    \pgfmathsetmacro{\cubey}{1.2}
    \pgfmathsetmacro{\cubez}{1.2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.4}
    \pgfmathsetmacro{\cubey}{1.4}
    \pgfmathsetmacro{\cubez}{1.4}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.6}
    \pgfmathsetmacro{\cubey}{1.6}
    \pgfmathsetmacro{\cubez}{1.6}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{1.8}
    \pgfmathsetmacro{\cubey}{1.8}
    \pgfmathsetmacro{\cubez}{1.8}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;

    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[black,fill=white] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

输出:

在此处输入图片描述

相关内容