9
$\begingroup$

I was looking at this question, which asks to keep the orientation of some 3D graphics objects constant (relative to the viewer) while rotating the rest with the mouse. I thought that maybe the coordinates can be given in terms of the ViewPoint and ViewVertical, which do keep unchanged relative to the viewer. I came up with this:

DynamicModule[{vv = {0, 0, 1}, vp = {1.3`, -2.4`, 2.`}}, 
 Graphics3D[{
   Cuboid[], 
   Line[{{0, 0, 0}, Dynamic[vv]}]
   (*,Line[{{0,0,0}, Dynamic@vp}]*)
  }, 
  ViewPoint -> Dynamic[vp], 
  ViewVertical -> Dynamic[vv], 
  Boxed -> False, SphericalRegion -> True]
 ]

The problem is that the updating of the Line and the rotation of the graphics are not synchronized. The former happens with a short delay after the latter, leading to some flickering while rotating the graphics with the mouse.

How can we lock together just the display of the Line and the rest of the graphics, to avoid this flickering?

$\endgroup$

1 Answer 1

4
$\begingroup$

Specifying an explicit PlotRange and moving the Dynamic outside the list in Graphics3D seems to create a smoother experience:

DynamicModule[{vv = {0, 0, 1}, vp = {1.3`, -2.4`, 2.`}}, 
  Graphics3D[
    Dynamic[{Cuboid[], Line[{{0, 0, 0}, vv}]}],
    ViewPoint -> Dynamic[vp], 
    ViewVertical -> Dynamic[vv],
    Boxed -> False, 
    SphericalRegion -> True,
    PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]
]
$\endgroup$
2
  • 1
    $\begingroup$ It is enough if the Dynamic is moved to wrap the Line, no need to make the full content dynamical as well. I assume, SpehericalRegion cannot pre-determine the full region because of the dynamical content and that is why the explicit plot range is required. $\endgroup$ Apr 17, 2015 at 16:29
  • 1
    $\begingroup$ Moving the Dynamic outside does indeed work. I really wonder why this makes such a difference. $\endgroup$
    – Szabolcs
    Apr 17, 2015 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.