Graphics3D: Cube の試作(2) Polygon + Text

小キューブに 文字をText で書き込む。 L, B, D の文字が透けて見える。

(*  front  *)
front = {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}};
ffc = # + {0, 0, 0} & /@ front;
textF = {Red, 
   Text[Style["F", 18, Bold, FontFamily -> "Courier"], Plus @@ ffc[[{1, 3}]]/2.0]};
fF = {{Glow[Green], Green, Polygon[ffc]}, textF};
up = {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}};
(*  up  *)
fuc = # + {0, 0, 0} & /@ up;
textU = {Red, 
   Text[Style["U", 18, Bold, FontFamily -> "Courier"], Plus @@ fuc[[{1, 3}]]/2.0]};
fUp = {{Glow[Orange], Darker[Orange, 0.7], Polygon[fuc]}, textU};
(*  left  *)
left = {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}};
flc = # + {0, 0, 0} & /@ left;
textL = {Lighter[Blue, 0.5], 
   Text[Style["L", 18, Bold, FontFamily -> "Courier"], Plus @@ flc[[{1, 3}]]/2.0]};
fL = {{Glow[Blue], Lighter[Blue, 0.5], Polygon[flc]}, textL};
(*  right  *)
right = {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}};
frc = # + {0, 0, 0} & /@ right;
textR = {Lighter[Red, 0.1], 
   Text[Style["R", 18, Bold, FontFamily -> "Courier"], Plus @@ frc[[{1, 3}]]/2.0]};
fR = {{Glow[White], White, Polygon[frc]}, textR};
(*  back  *)
back = {{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}};
fbc = # + {0, 0, 0} & /@ back;
textB = {Lighter[Blue, 0.5], 
   Text[Style["B", 18, Bold, FontFamily -> "Courier"], Plus @@ fbc[[{1, 3}]]/2.0]};
fB = {{Glow[Yellow], Yellow, Polygon[fbc]}, textB};
(*  down  *)
down = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
fdc = # + {0, 0, 0} & /@ down;
textD = {Lighter[Blue, 0.5], 
   Text[Style["D", 18, Bold, FontFamily -> "Courier"], Plus @@ fdc[[{1, 3}]]/2.0]};
fD = {{Glow[Red], Red, Polygon[fdc]}, textD};
(*  *)
edge = EdgeForm[Directive[Thickness[0.010], Darker[Blue, 0.5]]]; grf = Graphics3D[{edge, Opacity[0.9], fF, fUp, fL, fR, fB, fD}, AxesLabel -> {"x", "y", "z"}, Lighting -> {{"Directional", White, {{1, -1, 1}, {0, 0, 0}}}}, ImageSize -> 300, ViewPoint -> {1.375, -2.896, 1.080}, ViewVertical -> {0.13920, -0.26893, 0.9530}, PlotRangePadding -> 0.2, Axes -> False, Boxed -> False]

主目次へ