iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
583 stars 211 forks source link

DrawingViewState has issues when "viewing" empty DrawingModels #5822

Open karolis-zukauskas opened 11 months ago

karolis-zukauskas commented 11 months ago

Describe the bug Opening IModelViewportControl with a DrawingViewState whose "base model" is an empty DrawingModel results in semi-broken view port. In this case, the camera cannot be zoomed in/out and other view manipulation tools (like rotate view) no longer work.

You can spot the troublesome code in DrawingViewState constructor where it assigns _modelLimits (its used for defaultExtentLimits implementation):

// extents.maxLength() returns 0 as there are no Elements in the DrawingModel
this._modelLimits = { min: Constant.oneMillimeter, max: 10 * extents.maxLength() };

To Reproduce Can't suggest a good option for reproduction - create an empty DrawingModel and open a viewport to it (IModelViewportControl).

Expected behavior Viewport should be usable when viewing an empty DrawingModel (e.g. view manipulation tools should work).

Screenshots Getting spammed with errors while trying to zoom in or out. image

Desktop (please complete the applicable information):

ben-polinsky commented 10 months ago

@raplemie

raplemie commented 10 months ago

@ben-polinsky This would be an issue fixed within core-frontend DrawingViewState which would need to hanle it correctly (Ensure that Min is at least equal to Max I guess).

For the "Maximum Window" error, throttling/debouncing of the error messages should be implemented either in the toolAdmin, or in the ViewState.adjustViewDelta which are also in core-frontend.