By manually adjusting the coefficients inside TextureCoordinateFunction
I can get the numbers on each ball to sort of face the camera:
Graphics3D[{
[email protected], Blue, Cuboid[{-2, -2, -2}, {2, 2, 0}],
Opacity@1, Sequence @@ MapThread[
Translate[
SphericalPlot3D[#3, {theta, 0, Pi}, {phi, 0, 2 Pi},
Mesh -> None,
TextureCoordinateFunction -> ({#1, 0.3*#2 + 0.7*#3} &),
PlotStyle ->
Texture[Show@
Graphics@Text@Style[ToString@#1, 100]]][[1]], #2] &, {{8,
5, 13, 3},
{{-1, -1, 0}, {-1, 1, 0}, {1, -1, 0}, {1, 1, 0}}, {0.2, 0.4, 0.4,
0.2}}]
}, Boxed -> False, ViewPoint -> {-5, -9, 3},
ViewVertical -> {0, 0, 1}, PreserveImageOptions -> False]
How can I script the coordinates inside TextureCoordinateFunction
so the numbers are facing the ViewPoint
, while preserving the orientation of the cube?
The solution from Viewing a city's coordinates from above doesn't take into account that I also want to see the cube from a particular perspective.
Update: this almost works: (But how to preserve the shape of the letter? I can't get it to work with slots 1-3 of the TextureCoordinateFunction
.)
With[{viewpoint = {-5, -9, 3}}, Graphics3D[{
[email protected], Blue, Cuboid[{-2, -2, -2}, {2, 2, 0}],
Opacity@1, Sequence @@ MapThread[
With[{textpos =
CoordinateTransform[ "Cartesian" -> "Spherical",
Normalize[#2 - viewpoint]][[2 ;; 3]]/\[Pi]},
Translate[
SphericalPlot3D[#3, {theta, 0, Pi}, {phi, 0, 2 Pi},
Mesh -> None,
TextureCoordinateFunction -> ({(#4 - textpos[[1]] -
0.2), (#5 - textpos[[2]] + 0.15)} &),
PlotStyle ->
Texture[
Rotate[Show@Graphics@Text@Style[ToString@#1, 100],
90 Degree]]][[1]], #2]] &, {
{8, 5, 13, 3},
{{-1, -1, 0}, {-1, 1, 0}, {1, -1, 0}, {1, 1, 0}},
{0.2, 0.4, 0.4, 0.2}
}]
}, Boxed -> False, ViewPoint -> viewpoint,
ViewVertical -> {0, 0, 1}, PreserveImageOptions -> False]]