This function generates an approximation to that legend using the 3d capabilities of the rgl
package:
library(rgl)
key3d <- function(){
s = seq(0, 1, len=5)
xyz = expand.grid(x=s, y=s, z=s)
## this order replicates the example
col = rgb(xyz[,2], xyz[,1], xyz[,3])
bg3d(col="black")
spheres3d(xyz, col=col, radius=0.075, lit=FALSE)
## m can be got from the plot with par3d()$userMatrix
m = structure(c(-0.692, -0.426, 0.582, 0,
0.722, -0.395, 0.569, 0,
0, 0.814, 0.581, 0,
0, 0, 0, 1), .Dim = c(4L, 4L))
view3d(userMatrix=m)
}

Note that it uses spheres instead of cubes (cubes could be done but are a bit more work because each cube can have its own rotation). The matrix m
constructed in the code sets the view point and rotation, and is near enough to looking straight down that axis - the exact values probably need some trigonometry to work out but this is close enough.
Adding text to a rgl
plot can be done using text3d
. Its a bit fiddly to get right so here's one corner for starters. You might need to play with alignments and position to get it perfect:
key_labels <- function(){
text3d(1.1,-0.1,1.1,"pop -", col="white",adj=c(1,1))
text3d(1.1,-0.1,1.1,"built +", col="white",adj=c(1,0))
text3d(1.1,-0.1,1.1,"light +", col="white",adj=c(1,-1))
}

Note this is all done to a different graphics window than R's usual plots, so you may not be able to integrate this with another graphic. You can however save it as an image file and use that.