I have a WPF app where different Model3Ds are arranged in a Model3DGroup and displayed in a Viewport3D. I may pan, zoom in / out the displayed models. Everything is handled programmatically in the .Net app.
The only Xaml code is to define a UserControl containing a Grid, Viewport and Canvas, which is then hosted in the main Winforms app.
I want to be able to rotate the Model3DGroup about an arbitrary point - for example the center of the Viewport3D - but NOT about the center of Model3DGroup. The center of rotation is not necessarily at the Viewport3D origin (0, 0, 0).
In practice, the desired center of rotation could be obtained from a mouse click.
VisualTreeHelper HitTest works if and only if there is something behind the desired point (i.e. the desired center of rotation) in the Viewport3D: then with a mouse click, I get a Point3D about which to rotate the display.
The problem is when there is nothing behind the center of rotation of the Viewport3D as can happen with some geometry combinations where there can be nothing to obtain a VisualTreeHelper.HitTest.
I have been hunting around for ideas, including 3DTools - but this seems to require a Visual as input whereas my app uses a Viewport3D for 3D components and a Canvas for 2D components within a Grid.
Anyone would have a suggestion ?
Thanks in advance - just in case ;-))
What I have tried:
Tried several of the functions in 3DTools, but a Visual is required which I cannot provide. Also tried VisualTreeHelper.HitTest, but as said above, it does not work if there is no model behind the point about which I want to rotate the Model3DGroup.