How can I show the current ViewPoint, ViewAngle, ViewCenter, etc. while I am rotating interactively a 3D object?

1

1

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.

jss

Posted 2017-03-14T15:16:04.310

Reputation: 405

Question was closed 2017-03-14T20:01:27.083

1

That and more: Extract values for ViewMatrix from a Graphics3D

– Kuba – 2017-03-14T16:00:23.120

@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. – b3m2a1 – 2017-03-14T16:31:06.430

1

@MB1965 here's more: 118646.

– Kuba – 2017-03-14T16:32:39.400

Answers

2

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.*)

b3m2a1

Posted 2017-03-14T15:16:04.310

Reputation: 42 610

This works but shows only ViewPoint. What is about ViewAngle, ViewCenter, ViewVector and ViewMatrix? Are they simply absent in the low-level box structure? – Alexey Popkov – 2017-03-14T16:37:56.087

1You only see ViewAngle and ViewCenter once you shift or scale. The others I just didn't check for. They might be there. – b3m2a1 – 2017-03-14T16:38:43.010

@AlexeyPopkov following up on that previous comment, it seems they are not. – b3m2a1 – 2017-03-14T16:40:34.757