12

Is there a possibility in Mathematica to allow for manual rotation of 3D graphics when (auto)playing either using Manipulate or ListAnimate? (When one plays a sequence of 3D graphics using ListAnimate it is not possible to rotate manually the graph as when it is static.)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
mmal
  • 3,508
  • 2
  • 18
  • 38

1 Answers1

12

As there seem no easy way to hack ListAnimate or Manipulate, we'll try to construct a custom "animator", using the method I mentioned in an earlier post with some generalization.

First we generate all frames of the animation:

frameLst =
        Module[{range},
            range = Range[0, 2, .1];
            Plot3D[
                   Im[ArcSin[(.5 Abs[# - 1])^3 (x + I y)^4 Exp[2 # π I]]],
                   {x, -2, 2}, {y, -2, 2},
                   (* quality too high will crash the Dynamic system: *)
                   PlotPoints -> 10, MaxRecursion -> 1,
                   ExclusionsStyle -> {None, Red},
                   PlotRange -> {{-2, 2}, {-2, 2}, 4 {-1, 1}}, 
                   SphericalRegion -> True
            ] & /@ range
        ];

Then we make it move automatically using a Clock:

With[{n = Length@frameLst, opts = glst[[1, 2]]},
    DynamicModule[
        { k,
          frameDataLst = Cases[frameLst, _GraphicsComplex, ∞]
        },
        DynamicWrapper[
           Graphics3D[
              Dynamic[frameDataLst[[k]]],
              opts
           ],
           k = Clock[{1, n, 1}, 3]
        ]
    ]
]

rotatable auto-animation

The key point of the trick is keeping a persistent Graphics3D object across frames. So instead of writing Dynamic[Graphics3D[...]], we should use Graphics3D[{...,Dynamic[...],...}, options] to prevent the Graphics3DBox being destroyed at each frame, which will leave it no time to respond to the dragging operations from mouse.

Silvia
  • 27,556
  • 3
  • 84
  • 164