Is there an app reference related to the highlight function when clicking on the object?

Hi i have a question about API REFERENCES

[my code]
hwv.view.fitNodes([nodeid], 500);
hwv.model.setNodesFaceColor([nodeid], Communicator.Color.red());

Like the picture above,
in basically the yellow highlight function that comes out when i click on a node
I want to use it instead of setNodesFaceColor.

If I give nodeid as a parameter,
Is there an API REFERENCES that can be used like a click function?

thank you.

Hello @jhbae.

As part of the Communicator package via quickstart, we have an example of changing the color, transparency and visibility for selected parts of a model.

Here are the steps to launch the example:

Once the example launches, you can just follow the instructions provided on the page.

With respect to your comment:

If I give nodeid as a parameter,
Is there an API REFERENCES that can be used like a click function?

If you just want to quickly change the color “on-the-fly” of a selected node, you can use a callback to do that. Here’s some JavaScript that you can paste in the web browser console:

function mySelectionFunc(selectionEvent) {
        var selection = selectionEvent.getSelection();
        if (selection && selection.getSelectionType() != Communicator.SelectionType.None) {
            console.log("Selected Node: " + selection.getNodeId());
			hwv.model.setNodesFaceColor([selection.getNodeId()], Communicator.Color.red());
        }
        else {
            console.log("Selected: None");
        }
   }

hwv.setCallbacks({
        selection: mySelectionFunc
    });

This code snippet changes the selected node to red:

Also, the function to highlight nodes is setNodesHighlighted – which is already included in the selection operator.

Thanks,
Tino

1 Like

Hello tino
I was referring to your answer and found out that the function I was looking for was ‘setNodesHighlighted’ !
Thank you.

2 Likes