Autodesk forge `Autodesk.Viewing.ScreenShot.getScreenShotWithBounds`使用查看器';s默认相机尺寸,而不是边界

Autodesk forge `Autodesk.Viewing.ScreenShot.getScreenShotWithBounds`使用查看器';s默认相机尺寸,而不是边界,autodesk-forge,autodesk-viewer,Autodesk Forge,Autodesk Viewer,接下来,我尝试用调用Autodesk.Viewing.ScreenShot.getScreenShotWithBounds的Autodesk.Viewing.ScreenShot.getScreenshot来替换我们对viewer::getScreenshot的使用,以支持更大的屏幕截图。但是,边界将被忽略。其行为似乎是,它对观看者的默认相机进行屏幕截图或与其尺寸相对应。然后它拉伸图像以适合给定的宽度和高度。我希望函数返回给定边界框内元素的屏幕截图 函数getScreenShotWithBoun

接下来,我尝试用调用
Autodesk.Viewing.ScreenShot.getScreenShotWithBounds
Autodesk.Viewing.ScreenShot.getScreenshot
来替换我们对
viewer::getScreenshot
的使用,以支持更大的屏幕截图。但是,边界将被忽略。其行为似乎是,它对观看者的默认相机进行屏幕截图或与其尺寸相对应。然后它拉伸图像以适合给定的宽度和高度。我希望函数返回给定边界框内元素的屏幕截图

函数
getScreenShotWithBounds
是否应该执行与我假设的不同的操作

示例代码(LMV 7.40.0):

const bbounds:THREE.Bbox3;//计算了一些我想截图的元素
Autodesk.Viewing.ScreenShot.getScreenShotWithBounds(NOP_查看器,Math.ceil(bbounds.size().x*4),Math.ceil(bbounds.size().y*4),(blob)=>window.open(blob),{bounds:bbounds,margin:0});
查看器的手动屏幕截图

返回getScreenShotWithBounds的图像

更新:
我误解了功能<代码>Autodesk.Viewing.ScreenShot.getScreenShotWithBounds仅将边界适配到摄影机视图中。边界不用于任何裁剪。请参阅。

您得到的压缩图像暗示了这一点,但从中的注释中不清楚,您应该保留
宽度
高度
输入参数的查看器的比率。因此,您应该根据您的需要只缩放它们:
getScreenShotWithBounds(NOP\u VIEWER、VIEWER\u width*x、VIEWER\u height*x等


然后,
选项中的
边界
应负责裁剪。

Autodesk.Viewing.ScreenShot.getScreenShotWithBounds的给定宽度和高度必须与查看器具有相同的纵横比(请参见),即:

getScreenShotWithBounds(NOP_查看器,NOP_查看器.getDimensions().宽度*4,NOP_查看器.getDimensions().高度*4,选项);

getScreenShotWithBounds
只将边界适配到相机视图中(内部调用
viewer.navigation.fitbunds(true,bounds,false);
)。边界不用于任何类型的裁剪/像素计算或其他

要通过裁剪获得特定的纵横比,必须在
options
参数中提供
getCropBounds

例如,要通过裁剪强制形成纵横比,请执行以下操作:

getCropBounds:function(查看器:Autodesk.Viewing.Viewer3D,相机:Autodesk.Viewing.UnifiedCamera,边界:THREE.Box3):THREE.Box2{
//以像素为单位计算裁剪边界
//如果裁剪边界较大,则截图的宽度/高度将被截取
const aspectRatio=新的三个向量2(4,3);
const viewerBoundsWidthRatio=宽度/aspectRatio.x;
const viewerBoundsHeightRatio=高度/纵横比y;
常数cropToHeight=viewerBoundsWidthRatio>viewerBoundsHeightRatio;
const smallerScaleRatio=cropToHeight?viewerBoundsHeightRatio:viewerBoundsWidthRatio;
const cropboundassize=aspectRatio.clone().multilyscalar(smallerscaleraratio);
const cropBounds=new THREE.Box2(new THREE.Vector2(0,0),new THREE.Vector2(cropBoundsSize.x,cropBoundsSize.y));
const offset=cropToHeight?新的三个.Vector2((width-cropboundassize.x)/2,0):新的三个.Vector2(0,(height-cropboundassize.y)/2);
cropBounds.min.add(偏移量);
cropBounds.max.add(偏移量);
返回cropBounds;
}

啊,我真的误解了这个函数。截图的摄像头将边界放入摄像头,然后拍摄截图。为了获得正确的纵横比,我必须在
选项中生成
getCropBounds