private void FitViewButton_Click(object sender, RoutedEventArgs e) { if (ObjectsVisual.Children.Count == 0) { ResetCamera(); } else { Camera1.FitIntoView(visuals: ObjectsVisual.Children, fitIntoViewType: FitIntoViewType.CheckAllPositions, adjustTargetPosition: true, adjustmentFactor: 1.05); // have some margin (5%) around the objects before the edge } }
private void FitIntoView() { double selectedAdjustmentFactor = GetSelectedAdjustmentFactor(); bool adjustTargetPosition = CenterCameraCheckBox.IsChecked ?? false; _isAdjustingDistance = true; // Prevent infinite recursion Camera1.FitIntoView(visuals: ObjectsRootVisual3D.Children, // Do not use WireGrid for FitIntoView calculations (this parameter can be skipped if all shown objects should be checked) fitIntoViewType: Ab3d.Common.FitIntoViewType.CheckAllPositions, // CheckAllPositions can take some time bigger scenes. In this case you can use the CheckBounds adjustTargetPosition: adjustTargetPosition, // Adjust TargetPosition to better fit into view; set to false to preserve the current TargetPosition adjustmentFactor: selectedAdjustmentFactor); // adjustmentFactor can be used to specify the margin // See help for more information about FitIntoView (defined in Ab3d.Cameras.BaseTargetPositionCamera) // NOTE: // If you want to call FitIntoView to show some manually specified area of the scene (not the actually shown objects) // you can create a BoxVisual3D and pass it to the FitIntoView call. // // For example the following code will make sure that the area defined by a 3D box with center at (0, 0, 0) and size (200, 50, 50) will be shown: //var dummyVisual3D = new Ab3d.Visuals.BoxVisual3D() //{ // CenterPosition = new Point3D(0, 0, 0), // Size = new Size3D(200, 50, 50) //}; //var dummyModelVisual3D = new ModelVisual3D(); //dummyModelVisual3D.Children.Add(dummyVisual3D); // Then you can call // Camera1.FitIntoView(visual3DCollection: dummyVisual3D.Children, ... _isAdjustingDistance = false; }
private void FitIntoViewButton_OnClick(object sender, RoutedEventArgs e) { Camera1.FitIntoView(); }