1

As a known issue, Mathematica always keeps Text on top of everything in Graphics3D. There are some ways to avoid this, and one of them is wonderful function text3D: Placing text in 3D (not facing viewer), nevertheless, this approach rotate the text. Is there any option to keep it facing always the ViewPoint ? I also simplified a litte bit text3D function because I don't need so many opitions.

text3D[str_, location_, scaling_, tilt_] := 
 Module[{mesh = 
    DiscretizeGraphics[
     Text[Style[str, FontFamily -> "Times", FontSize -> 12]], _Text, 
     MaxCellMeasure -> 0.04], 
   rotmatrx = RotationMatrix[tilt, {1, 0, 0}]}, 
  Join[{EdgeForm[]}, 
   MeshPrimitives[mesh, 
     2] /. {x_?NumberQ, 
      y_?NumberQ} :> (rotmatrx.(scaling~Join~{1} {x, y, 0}) + location)
    ]]

Another thing is, when I wrap this function in Manipulate it keeps reevaluating it even without moving the sliders. Why?

Manipulate[

Graphics3D[{Yellow, Polygon[{{0, 0, z}, {0, 10, z}, {10, 10, z}, {10, 0, z}}],

Blue, text3D["sphere", {5, 5, 7.6}, {0.2, 0.2},1.5],

Red, Sphere[{5, 5, 5}, 1]}, Boxed -> True, Axes -> True, AxesLabel -> {"X", "Y", "Z"}, PlotRange -> {{0, 10}, {0, 10}, {0, 10}}], {z, 0, 10},TrackedSymbols :> {z}]

enter image description here

Lechuu
  • 534
  • 2
  • 9
  • You have too many arguments in your text3D in the Manipulate. I do not see the Manipulate reevaluating. Try adding TrackedSymbols :> {z} to the Manipulate – Bob Hanlon Mar 23 '23 at 13:58

1 Answers1

0

So I think to ensure that the text in your text3D function always faces the ViewPoint in Graphics3D, use the ViewPoint option in conjunction with the ScalingTransform function to scale the text by the inverse of the scaling factor, so that it appears at the same size regardless of scaling.

jimmy90
  • 1
  • 1
  • 2
    Welcome to Mathematica StackExchange! Generally, we are looking for more self-sufficient answer with corresponding code. Please, edit your question to include the relevant Mathematica code which achieves what you describe. Otherwise, your answer would be more appropriate as a comment. – Domen Mar 24 '23 at 21:15