简体   繁体   English

Forge Viewer 如何计算 globalOffset?

[英]How does Forge Viewer calculate globalOffset?

In our application, we draw rooms by reading information from an IFC file and then generate custom objects which are added to the model builder.在我们的应用程序中,我们通过从 IFC 文件中读取信息来绘制房间,然后生成自定义对象,这些对象被添加到 model 构建器中。 For each vertex, we substract the globalOffset, so that the rooms align nicely with the model.对于每个顶点,我们减去 globalOffset,以便房间与 model 很好地对齐。 This works perfectly for most models we have.这适用于我们拥有的大多数模型。 However, for one model, the globalOffset is huge and thus, the custom objects will be drawn far away from the model.但是,对于一个 model,globalOffset 很大,因此,自定义对象将被绘制远离 model。

globalOffset 太高了

The vertices we read from the IFC file are located in a reasonable space around {0, 0, 0}.我们从 IFC 文件中读取的顶点位于 {0,0,0} 周围的合理空间中。

顶点示例

My question now is: How is the globalOffset calculated?我现在的问题是:globalOffset 是如何计算的? What properties of the IFC file are taken into account?考虑到 IFC 文件的哪些属性?

As already stated, the other models work fine when we subtract the globalOffset from each vertex.如前所述,当我们从每个顶点中减去 globalOffset 时,其他模型工作正常。 Here is an example:这是一个例子:

在此处输入图像描述

Thanks in advance for any form of help!提前感谢任何形式的帮助!

EDIT: For everyone interested in the origin of the global offset in the IFC file: search for "ifcsite", there should be a reference to a local placement and this may contain a rather big translation (at least in my case).编辑:对于对 IFC 文件中全局偏移的来源感兴趣的每个人:搜索“ifcsite”,应该有对本地放置的引用,这可能包含相当大的翻译(至少在我的情况下)。

The global offset is the mid-point of the model bounding box by default like the below:默认情况下,全局偏移量是 model 边界框的中点,如下所示:

var bboxMeta = model.getData().metadata["world bounding box"];
var min = new THREE.Vector3(bbox.minXYZ[0], bbox.minXYZ[1], bbox.minXYZ[2]);
var max = new THREE.Vector3(bbox.maxXYZ[0], bbox.maxXYZ[1], bbox.maxXYZ[2]);

var bbox = new THREE.Box3(min, max);

var globalOffset = bbox.center();

It's used to avoid floating point precision issues for models that are far away from the viewer's origin.它用于避免远离查看者原点的模型的浮点精度问题。 By default, Forge Viewer will use this offset to move the whole model to the viewer's origin.默认情况下,Forge Viewer 将使用此偏移量将整个 model 移动到查看器的原点。

To get the global offset you can also use the following line of code with the same output:要获得全局偏移量,您还可以使用具有相同 output 的以下代码行:

let globalOffset = viewer.model.getData().globalOffset;

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

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