0

In Forge Viewer, the near and far calculation is done in an internal updateCameraMatrices method. In that method, there's a final heuristic to fine-tune the near value better near line 31320:

// One more attempt to improve the near plane: make it 1/100,000 of the distance of the
// far plane, if that's higher.
// See https://wiki.autodesk.com/display/LMVCORE/Z-Buffer+Fighting for reasoning.
// 1e-4 is generally good below, but inside Silver Cross we get a lot of near clipping. So, 1e-5.
dMin = Math.max(dMin, dMax * 1e-5);

In some BIM models I load in the viewer I can see Z-fighting for some viewing angles. If I change the value from 1e-5 (1/100,000) to 1e-4 (1/10,000) as noted in the comments, the z-fighting is gone. This also seems like a much more appropriate value for large models (like buildings). It's maybe less suited for small-scale models like 3D CAD models.

Can I safely change this value to 1e-4 if all I intend to render is models in the scale of buildings (from Revit, Navisworks etc)?

Will the Forge Viewer allow to configure the near/far calculation in its API?

bartzy
  • 328
  • 5
  • 14

1 Answers1

0

I'm afraid that you shouldn't modify this value directly in the viewer3D.js file. It's not recommended to do so. There also is no such API to modify this value as I know.

However, have you tried to change the bounds of the viewer? Here might be a similar case you can refer: Adding a skybox

If this doesn't match what you need, could you provide some snapshots and more detail information demonstrating this issue to me? If you do so, I 'm glad to pass it to our engineering team for further investigating. You can send those materials to forge.help@autodesk.com if it cannot be posted publicly.

P.S. Please remove confidential information from anything you sent to us.

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • How do I change the bounds of the viewer? I did check the world bounding box (drawed it via THREE.js) and it seemed very accurate. Can you perhaps explain what does "Silver Cross" mean in the comment in my question? – bartzy Jan 02 '18 at 19:16
  • In this blog, the answerer of the Adding a skybox, Philippe, has explained how to change the viewer bounds via `viewer.navigation.fitBounds()`, please take a look: https://forge.autodesk.com/blog/forge-viewer-skybox-and-camera-animation – Eason Kang Jan 03 '18 at 02:48