iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
606 stars 210 forks source link

Mask is showing reality mesh that was not in selection #3860

Open ovaisa opened 2 years ago

ovaisa commented 2 years ago

We are using inverted mask capability in iTwin to isolate and display specific pipe runs in our reality model. We have an underlying iModel that is used as classifier to select the pipe run in the reality model.

ElementSelection-2

This the associated classifier model. showing the selected elements in the pic above

ClassifierMask

When we use the mask capability (with invert=true), it seems that the portions of reality mesh directly above and below the selected elements is also included in the display. Pls see resulting display below:

MaskedElement-2

Another example, in this case there is no mesh above the selected element, so only mesh below the selection is displayed

Element Selection

IMJS_ITWIN_ID=d20678d8-ad8c-4732-a32f-5ec62e2befc0 IMJS_IMODEL_ID=f78835ef-ff39-40e5-87fa-ccc55b0016b6 (contains multiple iModels, the classifier model is called $Classifier-$Elements)

Reality model is in PW ContextShare named 'Central_2', Project name: BSY_UK_COSURV -> Link below: (https://api.bentley.com/realitydata/624511f7-fa19-4ba3-b25e-63345cf7919c?projectId=d20678d8-ad8c-4732-a32f-5ec62e2befc0')

Can you please guide how I can resolve this issue.

Thank you,

Ovais

pmconne commented 2 years ago

Masks are 2d - they are produced by projecting the 3d geometry onto a plane. The result is basically the shadows you would see on the ground below your model from a light placed directly overhead. Whether a portion of the 3d model is masked is dependent entirely upon whether its x and y coordinates intersect the mask - its z coordinates are irrelevant because the mask has no z.

It may seem like the volume classifier ought to be able to make unclassified portions of the mesh invisible, but that's only possible with planar classifiers - volume classifiers are applied using the stencil buffer after the model has already been rendered.

If you want to isolate 3d volumes within your mesh you will need to clip the view using a 3d ClipVector, presumably produced from the geometry of the design element(s) that you're currently trying to use as a mask. Such clips can be arbitrarily complex but the more complex your geometry, the more performance intensive it becomes to apply the clip - ideally you will obtain a rough envelope around the element (e.g., perhaps an elongated box in the case of the single pipe highlighted in your screenshot).