MazaYong
MazaYong

Reputation: 307

Setting Visible bounds in Forge Viewer

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.

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).

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:

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.

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

Thanks in advance!

Upvotes: 0

Views: 332

Answers (1)

Felipe
Felipe

Reputation: 4375

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.

Hope that helps

Upvotes: 1

Related Questions