I have a simple animation of a 6-sided die that works as expected except that it runs too slow. I have created 60 frames that I would like for it to show all frames at 30 frames per second. I do not want to create a gif or other static representation as the spin of the die should be random even for the same die face.
dsDice = With[{faces = PolyhedronData["Cube", "Faces"]},
With[{vertices = faces[[1, faces[[2, 1, #]]]]},
<|
"Face" -> {
Texture[Image@
Graphics[
Text[Style[ToString[#], 200, Underlined, FontFamily -> "Verdana"]]]],
Polygon[vertices,
VertexTextureCoordinates ->
RotateLeft[{{0, 0}, {1, 0}, {1, 1}, {0, 1}},
Switch[#, 1 | 2, 2, 5, 1, _, 3]]]
},
"NormalVector" ->
Subtract @@ vertices[[{1, 2}]]\[Cross]Subtract @@
vertices[[{1, 3}]]
|>
] & /@ Range[6]
] // Dataset;
roll[] :=
With[{event = RandomInteger[{1, 6}]},
{
DynamicModule[{t = 1, spin = RandomChoice[{-1, 1}, 3]},
Dynamic[
t = Max[0, t - 1/60];
Deploy@
Graphics3D[{EdgeForm[Gray],
Rotate[Normal@dsDice[All, "Face"], t (5 \[Pi])/3, spin]},
ViewPoint -> Normal@dsDice[event, "NormalVector"],
Background -> LightGray,
Lighting -> {{"Ambient", White}},
Boxed -> False,
ImageSize -> Medium,
RotationAction -> "Clip"]
]]
,
event
}
]
When roll[]
is run the all the frames display but is refreshed too slow. I need a solution that just has the animation without any controls. I tried to return an Animate
with AppearanceElements->None
but the controls were still visible. Any ideas? Currently on version 11.0.1