Hi
I have this method to zoom to a BoundingBox:
It works pretty well when in perspective projection, but it does not work for ortographic
I know I must set ViewWidth and AspectRatio to handle that, so, could you please point me in the right direction to calculate the ViewWidth?
I have this method to zoom to a BoundingBox:
Code:
private void Zoom(bool isZoomSelection, BoundingBox? bBox = null)
{
if (this.BimScene is null)
{
return;
}
Threads.ExecuteOnUIThread(() =>
{
// BoundingBox can be NaN when there are no models -> Get RootNode BoundingBox instead with the grid
bBox ??= !isZoomSelection
? this.BimScene.GetSceneBoundingBox()
: this.BimScene.GetSelectionBoundingBox();
if (bBox.Value.SizeX is float.NaN
|| bBox.Value.SizeY is float.NaN
|| bBox.Value.SizeZ is float.NaN)
{
bBox = this.BimScene.RootNode.GetLocalBoundingBox();
}
if (Settings.SingleInstance.CameraAnimationDuration > 0)
{
var corn = bBox.Value.GetCorners();
var dist = this.targetPositionCamera.GetFitIntoViewDistanceOrViewWidth(corn, FitIntoViewType.CheckBounds, true, out var targ);
var cameraAnimation = AnimationBuilder.CreateCameraAnimation(this.targetPositionCamera);
cameraAnimation.EasingFunction = EasingFunctions.QuadraticEaseInOutFunction;
cameraAnimation.Set(CameraAnimatedProperties.TargetPosition, targ, Settings.SingleInstance.CameraAnimationDuration);
cameraAnimation.Set(CameraAnimatedProperties.Distance, dist, Settings.SingleInstance.CameraAnimationDuration);
if (this.currentCameraAnimation is not null)
{
this.currentCameraAnimation.Completed -= this.CameraAnimation_Completed;
this.currentCameraAnimation.Stop();
}
cameraAnimation.Start();
this.currentCameraAnimation = cameraAnimation;
this.currentCameraAnimation.Completed += this.CameraAnimation_Completed;
}
else
{
this.targetPositionCamera.TargetPosition = bBox.Value.GetCenterPosition();
this.targetPositionCamera.FitIntoView(bBox.Value, false, 1.1f);
this.UpdateCameraPosition();
}
}, true);
}It works pretty well when in perspective projection, but it does not work for ortographic
I know I must set ViewWidth and AspectRatio to handle that, so, could you please point me in the right direction to calculate the ViewWidth?

