Graphics3D: Cube の試作(3) Polygon + Texture

面に Texture で文字を書く。

vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};(*VertexTextureCoordinates*);
(*  front  *)
front = {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}};
ffc = # + {0, 0, 0} & /@ front;
fF = {Texture[
    Graphics[{Red, 
      Text[Style["F", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> Green, ImageSize -> 250]],
   {Glow[Green], Green, Polygon[ffc, VertexTextureCoordinates -> vtc]}};
(*  up  *)    
up = {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}};
fuc = # + {0, 0, 0} & /@ up;
fUp = {Texture[
    Graphics[{Blue, 
      Text[Style["U", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> Orange, ImageSize -> 250]], 
     {Glow[Darker[Orange, 0.5]], Darker[Orange, 0.7], Polygon[fuc, VertexTextureCoordinates -> vtc]}};
(*  left  *)    
left = {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}};
flc = # + {0, 0, 0} & /@ left;
fL = {Texture[
    Graphics[{Red, 
      Text[Style["L", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> LightBlue, ImageSize -> 250]],
   {Glow[Lighter[Blue, 0.5]], Blue, Polygon[flc, VertexTextureCoordinates -> vtc]}};
(*  right  *)    
right = {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}};
frc = # + {0, 0, 0} & /@ right;
fR = {Texture[
    Graphics[{Red, 
      Text[Style["R", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> White, ImageSize -> 250]],
   {Glow[Lighter[Blue, 0.5]], Blue, Polygon[frc, VertexTextureCoordinates -> vtc]}};
(*  back  *)    
back = {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}};
fbc = # + {0, 0, 0} & /@ back;
fB = {Texture[
    Graphics[{Red, 
      Text[Style["B", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> Yellow, ImageSize -> 250]],
   {Glow[Yellow], Yellow, Polygon[fbc, VertexTextureCoordinates -> vtc]}};
(*  down  *)    
down = {{0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}};
fdc = # + {0, 0, 0} & /@ down;
fD = {Texture[
    Graphics[{Blue, 
      Text[Style["D", 30, Bold, FontFamily -> "Courier"]]}, 
     Background -> Red, ImageSize -> 250]],
   {Glow[Lighter[Red, 0.5]], Lighter[Red, 0.5], Polygon[fdc, VertexTextureCoordinates -> vtc]}};
(*  *)    
edge = EdgeForm[Directive[Thickness[0.010], Darker[Blue, 0.5]]];

Graphics3D[{edge, Opacity[0.95], fF, fUp, fL, fR, fB, fD}, 
 AxesLabel -> {"x", "y", "z"}, 
 Lighting -> {{"Directional", White, {{1, -1, 1}, {0, 0, 0}}}}, 
 ViewPoint -> {1.375, -2.896, 1.080}, 
 ViewVertical -> {0.13920, -0.26893, 0.9530}, PlotRangePadding -> 0.1,
  Axes -> False, Boxed -> False, ImageSize -> 250]

主目次へ