Solution:
For n=2, the answer is 36; for n=3, the answer is 30 and for n≥4, the answer is 6n.
Lemma 1. Given a regular 2n-gon in the plane and a sequence of n consecutive sides s1,s2,…,sn there is an external point Q in the plane, such that the color of each si can be seen from Q, for i=1,2,…,n.
Proof. It is obvious that for a semi-circle S, there is a point R in the plane far enough on the bisector of its diameter such that almost the entire semi-circle can be seen from R.
Now, it is clear that looking at the circumscribed circle around the 2n-gon, there is a semi-circle S such that each si either has both endpoints on it, or has an endpoint that's on the semi-circle, and is not on the semi-circle's end. So, take Q to be a point in the plane from which almost all of S can be seen, clearly, the color of each si can be seen from Q.
Lemma 2. Given a regular 2n-gon in the plane, and a sequence of n+1 consecutive sides s1,s2,…,sn+1 there is no external point Q in the plane, such that the color of each si can be seen from Q, for i=1,2,…,n+1.
Proof. Since s1 and sn+1 are parallel opposite sides of the 2n-gon, they cannot be seen at the same time from an external point.
For n=2, we have a square, so all we have to do is make sure each color is used. Two sides will be of the same color, and we have to choose which are these 2 sides, and then assign colors according to this choice, so the answer is (24)⋅3⋅2=36.
For n=3, we have a hexagon. Denote the sides as a1,a2,…,a6, in that order. There must be 2 consecutive sides of different colors, say a1 is red, a2 is blue. We must have a green side, and only a4 and a5 can be green. We have 3 possibilities:
1) a4 is green, a5 is not. So, a3 must be blue and a5 must be blue (by elimination) and a6 must be blue, so we get a valid coloring.
2) Both a4 and a5 are green, thus a6 must be red and a5 must be blue, and we get the coloring rbbggr.
3) a5 is green, a4 is not. Then a6 must be red. Subsequently, a4 must be red (we assume it is not green). It remains that a3 must be red, and the coloring is rbrrgr.
Thus, we have 2 kinds of configurations:
i) 2 opposite sides have 2 opposite colors and all other sides are of the third color. This can happen in 3⋅(3⋅2⋅1)=18 ways (first choosing the pair of opposite sides, then assigning colors),
ii) 3 pairs of consecutive sides, each pair in one of the 3 colors. This can happen in 2⋅6=12 ways (2 partitioning into pairs of consecutive sides, for each partitioning, 6 ways to assign the colors).
Thus, for n=3, the answer is 18+12=30.
Finally, let's address the case n≥4. The important thing now is that any 4 consecutive sides can be seen from an external point, by Lemma 1.
Denote the sides as a1,a2,…,a2n. Again, there must be 2 adjacent sides that are of different colors, say a1 is blue and a2 is red. We must have a green side, and by Lemma 1, that can only be an+1 or an+2. So, we have 2 cases:
Case 1: an+1 is green, so an must be red (cannot be green due to Lemma 1 applied to a1,a2,…,an, cannot be blue for the sake of a2,…,an+1). If an+2 is red, so are an+3,…,a2n, and we get a valid coloring: a1 is blue, an+1 is green, and all the others are red.
If an+2 is green:
a) an+3 cannot be green, because of a2,a1,a2n,…,an+3.
b) an+3 cannot be blue, because the 4 adjacent sides an,…,an+3 can be seen (this is the case that makes the separate treatment of n≥4 necessary)
c) an+3 cannot be red, because of a1,a2n,…,an+2.
So, in the case that an+2 is also green, we cannot get a valid coloring.
Case 2: an+2 is green is treated the same way as Case 1.
This means that the only valid configuration for n≥4 is having 2 opposite sides colored in 2 different colors, and all other sides colored in the third color. This can be done in n⋅3⋅2=6n ways.