How can I stop the blinking when rotating a Graphics3D?

The issue has nothing to do with Texture. It is because the polygon you define in add is at the same plane where the front wall is: if you only use e.g. a red polygon instead of a textured one, you still would see the blinking feature, as Mathematica fails to decide which polygon to draw before the other: the wall or the red one (known as z-fighting). So you can simply move the smaller one a bit out of the wall, like this:

Polygon[
     Inner[Plus, {{30, 0, 10}, {100, 0, 10}, {100, 0, 70}, {30, 0, 70}}, {-5, -5, 0}, List], 
     VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
]

@Subbu,

I specifically tested your code on two computers. One with a proper graphics card and other without one. There is no blinking when the code is run on the computer with a graphics card. However, the problems returns when there code is run on the computer without graphics card.

Hope this helps,

Regards, Anu


Your code, with István's fix, works fine (v9.0.0, Mac OS 10.6). Here's another way: punch a hole in the wall where the textured rectangle appears.

The following definition puts a rectangular hole in a rectangular polygon. It divides the polygon into 9 rectangles (3 x 3) and drops the middle one. The code messes up EdgeForm so an optional argument to rectWithHole3D can specify the edge style; beware, it will inherit from the current Line style, too. I suspect there may be more efficient and general ways of doing this.

rectToPoly[{LL_, UR_}] := Tuples[Transpose@{LL, UR}][[{1, 3, 4, 2}]];
insertFixed[poly2d_, fixedCoord_, fixedPart_] := Insert[#, fixedCoord, fixedPart] & /@ poly2d;
rectWithHole3D[pts_List, hole_List, edgeForm_: None] := 
  With[{fixedPart = Position[SameQ @@@ Transpose[pts], True][[1, 1]]},
    With[{fixedCoord = pts[[1, fixedPart]],
     corners = Drop[Flatten[Table[{{i, j}, {i + 1, j + 1}}, {i, 3}, {j, 3}], 1], {5}], (* Drop {5} = center *)
     newvertices = 
      Outer[List, Sequence @@ Transpose@Drop[(pts~Join~hole)[[{1, 5, 7, 3}]], None, {fixedPart}]]}, 
    {{EdgeForm[], Polygon@insertFixed[#, fixedCoord, fixedPart] &@
         rectToPoly@Extract[newvertices, #] & /@ corners}, 
     If[edgeForm =!= None, {edgeForm, Line[pts], Line[hole]}, {}]}
    ]
   ];

Then here are the changes to your code that need to be made.

addVertices = {{30, 0, 10}, {100, 0, 10}, {100, 0, 70}, {30, 0, 70}};
frontEnd1 = 
 Graphics3D[{outerColors, 
   rectWithHole3D[{{0, 0, 0}, {0, 0, wallsHeight}, {N[width/4], 0, wallsHeight}, {N[width/4], 0, 0}},
    addVertices, Black]},
  Boxed -> False, Lighting -> {{"Ambient", outerColors}}, RotationAction -> "Clip", 
  ViewPoint -> viewPoint];

add = {Graphics3D[{EdgeForm[Gray], Gray, 
    Texture[Style["Subbu", Bold, 25]], Opacity[1], 
    Polygon[addVertices, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
   Boxed -> False, Lighting -> {Gray}, RotationAction -> "Clip"]};

Subbu's house

You may not like that it changes your function interactiveDesign, so that it depends on the external size and position of add (managed here through the variable addVertices). But it should solve the flickering problem and put the "Subbu" rectangle right where you want it. (You can also add windows.)

Tags:

Graphics3D