简体   繁体   English

Autodesk Forge Viewer 如何获取模型部分的屏幕截图

[英]Autodesk Forge Viewer how to get a screenshot of the part of a model

I have for example 20 element Ids and I want to make screenshot of them (like a detail).例如,我有 20 个元素 Id,我想对它们进行截图(如细节)。 For that screenshot I would like to have specific dimensions (for example 400x400).对于该屏幕截图,我想要特定尺寸(例如 400x400)。 My current viewer has different dimensions.我当前的查看器有不同的维度。 Is there some way how to achieve it and return current viewer in original view?有什么方法可以实现它并在原始视图中返回当前查看器吗?

I was trying to do these steps:我试图执行以下步骤:

  1. store current view存储当前视图
  2. set viewer dimensions设置查看器尺寸
  3. do fitToView(elementIds) - I have tried to manipulate camera, but I am not much familiar with it. do fitToView(elementIds) - 我曾尝试操纵相机,但我对它不太熟悉。 Also, I have tried to use fitToView but passed elements are sometimes out of the view.另外,我尝试使用fitToView但传递的元素有时不在视图中。
  4. getScreenshot(400, 400) getScreenshot(400, 400)
  5. restore view恢复视图

struggling with it so any help would be great努力解决它,所以任何帮助都会很棒

There's a nice blog post providing more details around the dimensions of screenshots taken from Forge Viewer: https://forge.autodesk.com/blog/more-screenshots .有一篇不错的博客文章提供了有关从 Forge Viewer 截取的屏幕截图尺寸的更多详细信息: https : //forge.autodesk.com/blog/more-screenshots

If that does not help with your use cases, you could also consider having an additional instance of the viewer on your page, sized exactly as the screenshots you'd like to generate, and only load the IDs of elements you need.如果这对您的用例没有帮助,您还可以考虑在您的页面上添加一个查看器的额外实例,其大小与您要生成的屏幕截图完全相同,并且只加载您需要的元素的 ID。 Here's a simple code that demonstrates the idea: https://github.com/petrbroz/forge-basic-app/commit/f95cb67944830b842955c9599f2e1e4683ff13f0 .这是一个演示该想法的简单代码: https : //github.com/petrbroz/forge-basic-app/commit/f95cb67944830b842955c9599f2e1e4683ff13f0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM