autodesk-forge - `viewer.navigation.fitBounds` 没有边距
问题描述
我想创建特定图像部分的高分辨率屏幕截图。我的方法是从我的部分的每个四分之一(左上、右上、左下、右下)创建多个屏幕截图。为此,我正在使用viewer.navigation.fitBounds
. 但是,似乎有一点我想摆脱的余量,因为我无法轻松地将四分之一屏幕截图拼接在一起。
viewer.navigation.fitBounds
应该完全符合界限,因此,这是我这边的使用错误吗?
例子
黑色标记代表我在调用时使用的右上角屏幕截图的边界框Autodesk.Viewing.ScreenShot.getScreenShotWithBounds
。但是,黑色标记与顶部和底部边框之间留有一些空间。
解决方案
该函数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;
推荐阅读
- c++ - 避免 C++ 中 XML 解析器的链式 if 语句
- list - 在 Prolog 中改变列表的元素
- python - PysimpleGUI 在窗口中为 gif 设置动画
- c++ - 基类未定义,但包含其标头
- google-cloud-platform - 在 GCP 中将谷歌云功能从一个项目迁移到另一个项目?
- google-sheets - 如何在单个单元格中做一个数字范围?
- vb.net - 如何将文本框内容保存到应用程序本身?
- c# - 从 C# 表单上的用户输入更改文件的路径
- flutter - 在颤动中弹回包含 CarouselSlider 的页面
- c# - 根据具有不同值的最近可用时间从 SQL 中检索项目