Prevent the selection of ghosted objects while isolating in Speckle Viewer

Hi! I’m currently working on isolating objects in the Speckle Viewer, and I’m facing an issue where ghosted objects remain selectable. My goal is to isolate a set of objects while making all others transparent (ghosted), but these ghosted objects must not be selectable.

I want to be able to select isolated objects even if ghosted objects are in front of them. This means that if an isolated object is behind a ghosted object, I should still be able to click through the ghosted object and select the isolated one. This is the same behavior that can be seen in app.speckle.systems when isolating objects (shown below).

Currently, I’m using the following code to isolate objects:

const filteringExtension = instance.getExtension(FilteringExtension);
filteringExtension.isolateObjects(selectedObjectIds, ISOLATION_STATE_KEY, true, true);

This correctly makes all non-isolated objects transparent, but the problem is that these ghosted objects are still selectable. This prevents me from easily interacting with the isolated objects behind them. Probably it can be managed on selection event, but not really sure how to implement this.

Thanks in advance!

1 Like

Hi @Vitalii

Indeed, the viewer library does not skip neither ghosted nor hidden objects when building the selection argument for the ObjectClicked event.

There are several ways to achieve what you are after, and here is a live example showing one of them inspired by our speckle web app. It’s using the filtering state to determine which objects are isolated. You can also extend it for hidden objects if you need to

Cheers

1 Like

Thanks! Works as expected.

In addition to this, I previously came across this stackblitz, which enables a hover effect on materials. However, as I noticed, the onPointerMove(e: Vector2 & { event: Event; }) method in SelectionExtension doesn’t provide any “hits” to identify which object is being hovered over. Is it possible to combine these two features (hovering over materials of isolated objects only)?

Hi @Vitalii

There are probably multiple ways of achieving the combination. Here is the previous live example updated to hover on ghosted objects only.

All viewer extensions are meant to be customizable by extension. Even parts of the viewer-core are.

Cheers