For layer 1 you will have 4 IO pins connected to current limit resistors and then to the 4 LED anodes.
All 4 cathodes will connect to the collector of an NPN transistor, emitter to Gnd.
5th IO pin to 270 ohm resistor to NPN Gate.
For layer 2 you will have the same 4 LED anodes connected to the 4 anodes from layer 2.
All 4 cathodes will connect to the collector of a 2nd NPN transistor, emitter to Gnd.
6th IO pin to 270 ohm resistor to NPN Gate.
Drive the anodes, turn on transistor 1 for 5 mS. Turn off transistor 1.
Drive the anodes, turn on transistor 2 for 5 mS. Turn off transistor 2.
Repeat.
Occasionally, change what you drive out on the anodes.
Exand the number of anodes, layers, transistors to make a bigger cube.