Building a 3x3x3 LED cube?
You say you did this successfully with 27 LEDs all in "one layer".  As starblue said in a comment, 27 LEDs is 27 LEDs, regardless of how they are arranged mechanically.  As a thought experiment, imagine the same 27 LEDs you already have working in one layer arranged in a line.  Now fold them up to be a rectangle of 3 x 9 LEDs.  Now imagine each group of 3 x 3 to be a separate "group".  Note that none of the connections were changed so far, only how you thought of them being arranged.  Now stack the groups of 3 x 3 above each other, and you have a 3 x 3 x 3 cube.

Addressing individual LEDs with X,Y,Z positions will take a little masking and shifting and the like, but that's only firmware.  Since you have so few, one way to get the various output signals to address individual LEDs is with a lookup table.  You only need 2 bits for each of X, Y, and Z, so a 64 entry table will do this.