Ard*_*bet 2 c# wpf viewport3d helix-3d-toolkit
我使用HelixToolKit的ModelImporter函数向Viewport3d添加了一个模型(STL文件),但首先没有任何显示。要查看添加的3DModel,我必须进行缩小。我的问题是,有什么方法可以动态/以编程方式缩小或将相机旋转到新添加的模型,或需要立即显示它的任何方法。
我正在将带有C#WPF的helix工具包用于该项目。
更新:为此,有一个称为ZoomExtents的方法。问题已解决。更新#2:感谢@sideshowbarker的警告;
//in this case currModel= Model3D and mainViewport=HelixViewport3D
ModelVisual3D device3D = new ModelVisual3D();
device3D.Content = currModel;
mainViewport.Children.Add(device3D);
mainViewport.ZoomExtents();
//after loading 3D-Model into viewport you can just call the ZoomExtents() method in namespace of HelixToolkit.Wpf
//Then your 3D Models will automatically fits into viewport frame.
Run Code Online (Sandbox Code Playgroud)