simen-andresen
simen-andresen

Reputation: 2327

Find elements with opacity==0 elements and make them visible with Forge

We're trying to visualize an IFC model with forge that contains a lot of invisible elements. One problem we're facing is that the elements that is invisible does not fall under the normal category of hidden elements. E.g. model.setAllVisibility(true) does not make them appear. Also, model.visibilityManager.hiddenNodes is empty and model.visibilityManager.setVisibilityOnNode(dbId, true) does nothing to make them appear.

What seems to be the case with these elements is that their material.opacity is 0. We tried setting the opacity to 1, and also tried using a different material, with no luck. The only thing we have managed to do so far is to highlight the element's corresponding fragment:

model.setHighlighted(fragId, true)

however, this does not really cut it (unless it's possible to highlight many elements, and make them transparent?).

It's also worth mentioning that:

So, my questions:

Upvotes: 0

Views: 54

Answers (1)

Petr Broz
Petr Broz

Reputation: 9934

The viewer doesn't provide any solution for this out-of-the-box but it should be quite straightforward by putting together some of the viewer's features:

To check the opacity of all objects, you can just get the list of all fragments, and check the opacity of each material:

const frags = viewer.model.getFragmentList();
for (let i = 0; i < frags.getCount(); i++) {
    const mat = frags.getMaterial(i);
    console.log(mat.opacity);
}

And then, when you find materials you would like to change, you can do that, too. Here's some resources that might help:

Upvotes: 1

Related Questions