# How to get complete control of ViewVector?

I need to rotate a 3D object with the mouse, get the new ViewPoint, and scale that by dist to get a new ViewPoint and use that in ViewVector. And do this while preserving the orientation. (In the code, I also get the orientation jumping with the size slider. I don’t want this either.)

This is extending Matt's solution in this question Changing the Actions in EventHandler.

Manipulate[
vp = ViewPoint /. Options[Graphics3D, ViewPoint];
uvp = Normalize[vp];
vp = dist*uvp;

Show[
{
Graphics3D[{Red, Opacity[0.5],
Cylinder[size {{0, 0, -1}, {0, 0, 1}}]}],
Graphics3D[{Black, Opacity[0.5], Sphere[]}],
Graphics3D[{Black, Sphere[{0, 0, 0}, .2]}]
},

PlotRange -> 10 {{-1, +1}, {-1, +1}, {-1, +1}},

ViewAngle -> Dynamic[vAngle \[Degree]],
ViewVector -> {Dynamic[vp], Dynamic[Flatten@{center, 0}]}
],

{{vAngle, 30, "Zoom"}, 90, 10, 1},
{{center, {0, 0}, "Pan"}, 2 {-1, -1}, 2 {1, 1}},
{{size, 1, "size"}, 0, 5, .1},
{{dist, 10, "dist"}, 0, 20, .1},

TrackedSymbols :> {vAngle, center, size, dist},
ControlPlacement -> Left
]
• You need to keep track of ViewVertical with ViewVertical -> Dynamic[vert]. See mathematica.stackexchange.com/questions/28600/… or any of these Jan 22, 2017 at 2:22
• Or you might need to go for the whole ViewMatrix approach. Jan 22, 2017 at 2:26