2
$\begingroup$

I would like to be able to dynamically change the rotation pivot point location of a 3D graphics (in Mathematica terminology ViewCenter).

In 3D CAD software, this is typically done by mouse dragging a locator that represents the pivot point.

Each software works in a different way, but here follows a very common behaviour description:

  • the locator is displaced by mouse dragging

  • the locator has a snapping capability (like a magnet) when it approaches key points of interest (lines: endpoints, midpoint; circles: centres and quadrants; etc). Some softwares allow for the choice of what is considered a point of interest, and the distance of detection. It is typical for the locator to gain a different representation/colour, when getting attracted to a snapping point

  • some softwares detect positions over surfaces, others only detect positions over feature lines and curves (the choice is probably related to the rendering engine vs performance limitations)
  • when the locator is dropped at a position where its screen projection depth is undetermined, it keeps the same depth position as the one from its previous location.
  • the locator only appears in the scene when the mouse is over the scene. If there's no mouse activity for a couple of seconds, the locator also gets hidden.

Here's an example (Bentley View):

enter image description here

This GREAT post can serve as a good starting point: How can locators be added to the points on a 3D grid?

The best would be to have this available in a Graphics Assistant toolbar, that would also allow for the direct enter of the current viewing vector, angle, etc (or simple select copy of values). But until then, I'm imagining some wrapping (pivot[Graphics3D[ ... ]]), or option addition solution.

(I'm asking for help without posting my trials, since I'm not very expert on working with the internals of Graphics3D "objects", and I imagine that the way this will work is by making heavy use of patterns applied to the Graphics3D "object")

$\endgroup$
2
$\begingroup$

Maybe this will get you started. What's left is to use a 3D "locator" from the OP's linked question to connect a mouse click to setting the target of ViewVector.

g = Graphics3D[
   Table[{EdgeForm[Opacity[.3]], Opacity[.5], Hue[RandomReal[]], 
     Cylinder[RandomReal[10, {2, 3}]]}, {5}]];
Manipulate[
 Show[g, Graphics3D[{Sphere[target, 0.3]}], 
  ViewVector -> Dynamic[{camera, target}], 
  ViewVertical -> Dynamic[vert], SphericalRegion -> True],
 {{camera, 15 {1.3, -2.4, 2}}, InputField},
 {{target, {5, 5, 5}}, InputField},
 {{vert, {0, 0, 1}}, InputField}
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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