【问题标题】:`viewer.navigation.fitBounds` without margin`viewer.navigation.fitBounds` 没有边距
【发布时间】:2021-08-27 06:32:53
【问题描述】:
我想创建特定图像部分的高分辨率屏幕截图。我的方法是从我的部分的每个四分之一(左上、右上、左下、右下)创建多个屏幕截图。为此,我使用viewer.navigation.fitBounds。但是,似乎有一点我想摆脱的余量,因为我无法轻松地将四分之一屏幕截图拼接在一起。
viewer.navigation.fitBounds 是否应该完全符合界限,因此,这是我这边的使用错误吗?
示例
黑色标记代表我在调用Autodesk.Viewing.ScreenShot.getScreenShotWithBounds 时使用的右上角屏幕截图的边界框。但是,黑色标记与顶部和底部边框之间留有一些空间。
【问题讨论】:
标签:
autodesk-forge
autodesk-viewer
【解决方案1】:
函数Navigation.fitBounds 使用Navigation.computeFit,它使用以下边距设置,默认情况下每边增加5%:
// Change these constants to alter the margin ratios (think, percentages/100).
// The margins are how much to add above and below. For example, setting the
// margin to 25% (0.25) would give a margin of 25% above, 50% in the middle for
// content, and 25% below. This value should never be >= 0.50, as that would
// leave no area for the content to display.
// The offsets are how much to shift the view. For example, shifting 50% (0.50)
// vertically would move the displayed area such that only the bottom half of
// the drawing area would be seen.
this.FIT_TO_VIEW_VERTICAL_MARGIN = 0.05;
this.FIT_TO_VIEW_VERTICAL_OFFSET = 0.00;
this.FIT_TO_VIEW_HORIZONTAL_MARGIN = 0.05;
this.FIT_TO_VIEW_HORIZONTAL_OFFSET = 0.00;
你可以在调用viewer.navigation.fitBounds之前在任何地方设置这些变量:
const viewer = NOP_VIEWER; // your viewer instance
viewer.navigation.FIT_TO_VIEW_VERTICAL_MARGIN = 0.0;
viewer.navigation.FIT_TO_VIEW_HORIZONTAL_MARGIN = 0.0;