在Forge Viewer中设置可见范围 [英] Setting Visible bounds in Forge Viewer

查看:77
本文介绍了在Forge Viewer中设置可见范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用在Viewer.impl.sceneAfter上添加自定义网格的系统,并且遇到了一些问题,如果添加大网格(大于加载的所有模型的可见边界的并集),例如大点云,这是一个裁剪问题,其中一部分网格被切掉了.

I am currently working on system where we add custom mesh on Viewer.impl.sceneAfter, and have encountered some issues where, if large meshes (larger than union of visible bounds of all models loaded) such as large point clouds are added, there is a clipping issue where portion of mesh are being cut out.

从源代码中,我注意到相机的Far值是根据世界场景的可见范围进行更新的,并且在计算可见范围时不考虑sceneAfter的情况(与viewer.impl.scene相比,被考虑在内).

From the source code, I've noticed that camera's Far value is updated based on visible bound of the world scene, and that sceneAfter is not taken into account for calculating visible bound (in contrast to viewer.impl.scene, which is taken into account).

我需要将此自定义网格放置在sceneAfter中,因为我想启用透明度.

I need this custom mesh to be placed in sceneAfter, since I want to enable transparency.

为此,我提出了两种解决方案:

I came up with two hacky solution for this:

首先,覆盖Viewer3D.js中提供的getVisibleBounds函数原型受到以下stackoverflow答案的启发:更改相机速度,但不满意,因为它会覆盖第三方代码,以后可能会改变.

Firstly, overwriting getVisibleBounds function prototype provided in Viewer3D.js Which is inspired by this stackoverflow answer: Changing Camera Speed, but was not satisfied since it overwrites third-party code that may change later.

其次,在viewer.impl.scene中具有自定义网格的不可见克隆(使用材料的可见属性而不是几何形状),从而更改了查看者的可见范围.我比第一个解决方案更好,但仍然认为效率低下,因为我需要跟踪两个网格实例以删除/操作几何.

Secondly, having an invisible clone (using material's visible property instead of geometry) of custom mesh in viewer.impl.scene, such that it changes visible bound of viewer. Which I like better than first solution, but still think is inefficient since I need to keep track of two mesh instances to remove / manipulate geometries.

我想知道是否有比这些更优雅的解决方案

I was wondering if there is more elegant solution than these

提前谢谢!

推荐答案

在将来的查看器API版本中,我记录了一个愿望请求,以考虑添加到sceneAfter中的网格.

I logged a wish request to take into account meshes added to sceneAfter in a future release of our viewer API.

同时,建议的解决方法与您的第二个建议有点类似,但是使用的是琐碎的网格,例如自定义网格的边界框的表示.在复杂的情况下,渲染比网格的克隆要快.

In the meantime, thet suggested workaround is a bit similar to your second proposition, but using a trivial mesh, like the representation of the bounding box of your custom mesh. It will be faster to render than a clone of the mesh in case it's complex.

希望有帮助

这篇关于在Forge Viewer中设置可见范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆