I used the following code from another tikz question to create a 3D lattice
\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=3dgrid}
settings.render=8;
settings.outformat='png';
size(200);
import graph3;
int L=4;
triple s;
currentprojection=perspective(27,19,11);
real r = 0.1;
surface site = scale3(r)*unitsphere;
real dist = 1.5;
for(int i=1;i<=L;++i)
{
for(int j=1;j<=L;++j)
{
for(int k=1;k<=L;++k)
{
s=dist(i,j,k);
draw(shift(s)site,red);
if (i < L) draw(shift(s) * (O -- (dist-r)X),
p=blue+0.7pt);
if (j < L) draw(shift(s) (O -- (dist-r)Y),
p=gray+0.7pt);
if (k < L) draw(shift(s) (O -- (dist-r)*Z),
p=green+0.7pt);
}
}
}
\end{asypicture}
\end{document}
But I also want to fill in colors inside the cubes in a checkerboard pattern. Is there an easy way to do that?
Edit: I realize I can use the draw(unitcube,blue)) but can one extend this to cuboids?
