1
$\begingroup$

I want to find the more looking view of my 3D object. But I want to do it interactively, and then fix that view as default. I want to show dynamically the values of ViewPoint, ViewAngle, ViewCenter, etc. while I am rotating the object with the mouse.

$\endgroup$
  • 1
    $\begingroup$ That and more: Extract values for ViewMatrix from a Graphics3D $\endgroup$ – Kuba Mar 14 '17 at 16:00
  • $\begingroup$ @Kuba that's really clever. I would never have realized the FE would respect those Dynamics in the options settings. Another FE trick I'll have to keep in mind. $\endgroup$ – b3m2a1 Mar 14 '17 at 16:31
  • 1
    $\begingroup$ @MB1965 here's more: 118646. $\endgroup$ – Kuba Mar 14 '17 at 16:32
2
$\begingroup$

Edit

Kuba provided a link to this answer which is the right way to go about this, as well as this further discussion on using Dynamic in box options.

I'll leave this here as a curiosity for those who want to mess about with boxes and make their lives more difficult.

Original

So these operations change the box form of the expression, and with anything typeset like this we'll have to do a bit of gymnastics to the the proper result (I think).

Here's a way to do it. I make no promises this is the best way, but it is a way:

DynamicModule[{
  g = PolyhedronData@"Spikey",
  update
  },
 Column@{
   Dynamic[
    update;
    With[{b = EvaluationBox[]},
     Cases[
      NotebookRead@
       DeleteCases[
        FrontEndExecute@
         FrontEnd`ObjectChildren@
          ParentBox@b,
        b
        ],
      r : ((ViewPoint | ViewAngle | ViewCenter) -> _) :> r,
      \[Infinity]
      ]
     ],
    TrackedSymbols :> {update}
    ],
   EventHandler[
    g, {
     "MouseDragged" :> (update = RandomReal[])
     }
    ]
   }
 ]

You'll see that I'm using the front end packet FrontEnd`ObjectChildren to get the all of the child boxes in this DynamicModuleBox then deleting the dynamic box that started the call. I did this because I was originally pulling in the Graphics3DBox. I think it's worth leaving here because it gives a way to select a box other than the ParentBox or EvaluationBox.

I also use an EventHandler that forces an update in that expression whenever the mouse is dragged on the Graphics3DBox. I think there's no way around that one, outside of a clumsy pairing of TrackedSymbols:>{} and UpdateInterval->.05(*e.g.*)

| improve this answer | |
$\endgroup$
  • $\begingroup$ This works but shows only ViewPoint. What is about ViewAngle, ViewCenter, ViewVector and ViewMatrix? Are they simply absent in the low-level box structure? $\endgroup$ – Alexey Popkov Mar 14 '17 at 16:37
  • 1
    $\begingroup$ You only see ViewAngle and ViewCenter once you shift or scale. The others I just didn't check for. They might be there. $\endgroup$ – b3m2a1 Mar 14 '17 at 16:38
  • $\begingroup$ @AlexeyPopkov following up on that previous comment, it seems they are not. $\endgroup$ – b3m2a1 Mar 14 '17 at 16:40

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