Dynamic
has a second argument that gives the behaviour I'm looking for. Since the left-hand plot is too slow to move with the right-hand one, it can be disabled until the right-hand plot is in the desired position. When the mouse button is released, the Dynamic
variable is broadcast and the left-hand plot is updated.
The second argument can also disable interaction, so that the left-hand plot cannot be moved by the mouse. It shouldn't be moved anyway, because that generates and error.
So here is the finished code:
stereo[expr_] :=
DynamicModule[{vp = {1.3, -2.4, 2.0}, vv = {0., 0., 2.0}, plot},
plot = expr;
GraphicsRow[{Show[plot, ViewPoint -> Dynamic[vp + {.2, 0, 0}, None],
ViewVertical -> Dynamic[vv, None]],
Show[plot, ViewPoint -> Dynamic[vp, Temporary],
ViewVertical -> Dynamic[vv, Temporary]]},
ImageSize -> Large]]
You might want to play around with the 0.2 offset.
Note that this can turn any 3D graphic into a stereoscopic image. Just append //stereo
to the 3D graphic expression.
Edit:
That annoying jump when you release the mouse button can be fixed by adding the Option
RotationAction -> "Clip"
. It only applies to functions that recognize this option, but that includes most of the Plot3D functions:
stereo[expr_] :=
DynamicModule[{vp = {1.3, -2.4, 2.0}, vv = {0., 0., 2.0}, plot},
plot = expr;
GraphicsRow[{Show[plot, ViewPoint -> Dynamic[vp + {.3, 0, 0}, None],
ViewVertical -> Dynamic[vv, None], RotationAction -> "Clip"],
Show[plot, ViewPoint -> Dynamic[vp, Temporary],
ViewVertical -> Dynamic[vv, Temporary],
RotationAction -> "Clip"]}, ImageSize -> 600]]
The ImageSize can be set to your liking, too.
Eric