Viewer 2 highlight

Hello, I would like to ask for a little help.

In the previous version of the Speckle Viewer, I could use viewer.highlightObjects() to highlight certain objects. However, this function does not exist in version 2.18.14.

Can anyone help me with which function I can use to achieve this in this version?

(I am aware of the viewer.getExtension(MySelectionExtension).selectObjects() function, but it does not do what I need, I just want to apply the highlight effect on the elements.)

Hi @Gircsi117

Indeed, highlightObjects was completely removed from the API. The reason for doing that is because viewer-core functionality already offers this functionality. In fact you can achieve the same end result as the old highlightObjects multiple ways. I’ll go over two(three) of them:

  • You can create an extension that inherits from SelectionExtension and configure the ‘selection’ material to look like you want. Infact, LegacyViewer already does this to emulate the old highlightObjects API entry point. You can see it here. This is probably the easiest approach since it’s basically already done
  • Just use the viewer-core’s setMaterial functionality either by setting a direct material instance, either by using the simpler RenderMaterial interface. The downside of using this approach is the need to 100% keep track of object material states yourself
  • Make your own extension from scratch, use the viewer-core and/or other relevant extensions and go crazy :wink:

Let me know if you need more help with this!