我正在尝试根据BCF文件中的BIM主题可视化数据正确初始化Autodesk Forge 3D查看器。
我已将3D模型(IFC)上传到Autodesk API,它已经过处理,可以使用Autodesk Forge 3D查看器成功地可视化/导航模型。
我在Nemetschek SOLIBRI中使用了相同的3D模型(IFC)创建主题,并使用BIM BCF 2.1标准将其导出(请参见https://github.com/buildingSMART/BCF-XML)。
VisualizationInfo的XML数据:
<PerspectiveCamera>
<CameraViewPoint>
<X>2.803843040759871</X>
<Y>14.568845808384443</Y>
<Z>0.8249055320631105</Z>
</CameraViewPoint>
<CameraDirection>
<X>0.4898262677194313</X>
<Y>-0.8652456579090667</Y>
<Z>0.1068652371988122</Z>
</CameraDirection>
<CameraUpVector>
<X>-0.05264688190667085</X>
<Y>0.09299722978166312</Y>
<Z>0.9942735142195238</Z>
</CameraUpVector>
<FieldOfView>60.0</FieldOfView>
</PerspectiveCamera>
我试图在Autodesk Forge 3D查看器中设置相同的摄像机/视图:
viewer.restoreState(JSON.parse(`{
"viewport": {
"eye": [2.803843040759871, 14.568845808384443, 0.8249055320631105],
"target": [0.4898262677194313, -0.8652456579090667, 0.1068652371988122],
"up": [-0.05264688190667085, 0.09299722978166312, 0.9942735142195238],
"projection": "perspective",
"isOrthographic": false,
"fieldOfView": 60.0
}
}`));
结果: 一种Forge 3D查看器相机视图,它与SOLIBRI中看到的视图不匹配,也与BCF文件中另存为snapshot-png的视图不匹配。
也许SOLIBRI中的IFC模型和Autodesk处理的IFC模型具有不同的坐标系,或者可能是什么错误?
答案 0 :(得分:0)
CameraDirection
值不是Forge查看器的目标参数。您必须使用以下公式自己计算。
{Target} = {CameraViewPoint} + {CameraDirection} * {CurrentFocalLength}
问题视图的完整摄像机映射为:
var lengthScale = 1000; //! Use viwer.model.getUnitString(), the model I loaded is in `mm`, and BCF camera definition is in `m`
var eye = new THREE.Vector3( 2.803843040759871 * lengthScale, 14.568845808384443 * lengthScale, 0.8249055320631105 * lengthScale );
var sightVec = new THREE.Vector3( 0.4898262677194313, -0.8652456579090667, 0.1068652371988122 ).multiplyScalar( viewer.navigation.getFocalLength() );
var target = eye.clone().add( sightVec )
var up = new THREE.Vector3( -0.05264688190667085, 0.09299722978166312, 0.9942735142195238 );
//Since Forge Viewer will apply a global offset to the whole model
var offsetMatrix = viewer.model.getData().placementWithOffset;
var offsetEye = eye.applyMatrix4(offsetMatrix);
var offsetTarget = target.applyMatrix4(offsetMatrix);
var fov = 60;
var cameraView = {
aspect: viewer.getCamera().aspect,
isPerspective: true,
fov: fov,
position: offsetEye,
target: offsetTarget,
up: up,
orthoScale: 1
};
viwer.impl.setViewFromCamera( cameraView );
享受吧!