simen-andresen
simen-andresen

Reputation: 2337

Cannot see custom mesh through Forge's .svf mesh

I'm having trouble with custom geometry and transparent .svf meshes. I'm doing the following to add a custom mesh:

const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const geom = new THREE.SphereGeometry(10, 8, 8);
const sphereMesh = new THREE.Mesh(geom, material);
sphereMesh.position.set(10, 10, 3);

if (!viewer.overlays.hasScene('custom-scene')) {
    viewer.overlays.addScene('custom-scene');
}
viewer.overlays.addMesh(sphereMesh, 'custom-scene');

The custom geometry is loaded in a scene together with geometry from my IFC-derived .svf model. The problem is that I cannot see the custom mesh through any transparent parts of the .svf mesh (e.g. a window). One can see other .svf meshes through the transparent mesh but not the custom geometry.

The problem can be reproduced with the following:

  1. Open http://lmv.ninja.autodesk.com/
  2. Select 4: Models > Forge > Office.nwc
  3. Click "Launch Viewer"
  4. Paste the code above into the console (replace viewer with NOP_VIEWER)

One should then see a big red sphere. However, when looking at it from a perspective where a window is in front of the sphere, the custom geometry is not visible.

Upvotes: 0

Views: 135

Answers (1)

Petr Broz
Petr Broz

Reputation: 9942

This is a known limitation. Rendering opaque vs transparent objects is a common problem that must be handled carefully (for example, Forge Viewer first renders opaque objects, from front to back, and then it renders transparent objects, from back to front), and introducing additional scenes that get rendered separately makes things even more difficult.

I'd suggest that you try and embed the custom geometry using the SceneBuilder. That way the geometry will be part of the standard rendering pipeline (instead of being "an overlay"), and the transparency should work properly in that case.

Upvotes: 1

Related Questions