简体   繁体   English

Forge Viewer-无法正确查看多个不同的模型

[英]Forge Viewer - Cannot view multiple different models properly

I'm having trouble loading different models in the viewer. 我无法在查看器中加载不同的模型。 I suspect the problem comes from mixing up different units (meters and millimeters) in the models. 我怀疑问题来自于将模型中的不同单位(米和毫米)混合在一起。

So I have 3 Models: 所以我有3个模型:

  • IFC 1 , is using millimeters as unit. IFC 1以毫米为单位。

    • When loading the SVF derrivative into the viewer, doing 将SVF衍生物加载到查看器中时,

      console.log(model.getUnitScale(), model.getUnitString());

      outputs: 输出:

      0.001, mm

  • IFC 2 , using millimeters as unit. IFC 2 ,以毫米为单位。 Getting the same output as IFC 1 获得与IFC 1相同的输出

  • Obj . 对象 Model of a simple cube with center of cube at origin [0, 0, 0]. 以原点[0,0,0]为中心的简单立方体的模型。 This does not seem to have any inherent unit. 这似乎没有任何固有的单位。

    • When loading the SVF derrivative into the viewer, doing 将SVF衍生物加载到查看器中时,

      console.log(model.getUnitScale(), model.getUnitString());

      outputs: 输出:

      1, null

In order to load the models with the right coordinates I use the following options: 为了使用正确的坐标加载模型,我使用以下选项:

IFC 1 and 2: IFC 1和2:

{
    globalOffset: {x: 1000000, y: 100000, z: 7000},
    sharedPropertyDbPath: doc.getPropertyDbPath(),
}

Obj: OBJ:

let mat = new THREE.Matrix4();
mat.makeTranslation(1000000, 100000,7000);

{
    placementTransform: mat,
    sharedPropertyDbPath: doc.getPropertyDbPath(),
}

The rationale here is that the IFC models are located far away from the origin, while the Obj model is located at origin. 这里的理由是,IFC模型位于远离原点的位置,而Obj模型位于原始位置。 Using globalOffset for the IFCs seems necessary to get them to align in the viewer, using placementTransform is necessary to put the Obj close to the IFC models. 为IFC使用globalOffset似乎是必要的,以使其在查看器中对齐,必须使用placementTransform来使Obj靠近IFC模型。

I'm struggling with the following problems here: 我在这里遇到以下问题:

  • Navigating the models is hard, when highlighting the Obj model, it seems like it is set to using y-up or something, making it hard to do orientation navigation for the other models. 导航模型很困难,当突出显示Obj模型时,似乎设置为使用y-up或其他方法,因此很难对其他模型进行方向导航。
  • When trying to change zoom, only the Obj seems to be affected. 尝试更改缩放时,似乎只有Obj受到影响。 Could this be due to different scale settings? 这可能是由于比例尺设置不同导致的吗?

EDIT 1 : 编辑1

Looks like making the Obj cube the same size as the other models fixes the zooming problem. 看起来使Obj多维数据集与其他模型的大小相同可以解决缩放问题。 Also, if loading the IFC files first, the orientation navigation is right. 另外,如果先加载IFC文件,则方向导航正确。 It's only when loading the OBJ file first that we get the "y-up orientation" problem 只有首先加载OBJ文件时,我们才会遇到“ y向上”问题

Edit 2 : 编辑2

The orientation navigation problem can be fixed with viewer.navigation.setWorldUpVector(new THREE.Vector3(0,0,1), false); 方向导航问题可以通过viewer.navigation.setWorldUpVector(new THREE.Vector3(0,0,1), false); . Is it possible to also control behavior like this globally instead always letting the different models set the behavior? 是否也可以全局控制这样的行为,而不是总是让不同的模型来设置行为?

I think the last loaded model will always have precedence over any previously set world-up vector. 我认为最后加载的模型将始终优先于任何先前设置的世界化矢量。 So if you want to control the world-up globally, you'll need to use the viewer.navigation.setWorldUpVector method manually after all the models have been loaded. 因此,如果要全局控制世界地图,则在加载所有模型之后,需要手动使用viewer.navigation.setWorldUpVector方法。

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

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