Back to the Shapespark home page

Grouping materials in code?

HI Guys

I am using the mouseover highlight feature on something that has 3-4 materials,

If I list all the materials they highlight one at a time, is there a way to code the feature to group all 4 materials so they highlight at the same time? I have tried a few things but no luck

Something Like this
viewer.onMaterialHoverChanged(‘SBS_logo_2_black’, ‘SBS_logo_2_red’, ‘SBS_logo_2_white’, handleHoverChanged);

Instead of this
viewer.onMaterialHoverChanged(‘SBS_logo_3_black’, handleHoverChanged);
viewer.onMaterialHoverChanged(‘SBS_logo_3_black_gradient’, handleHoverChanged);
viewer.onMaterialHoverChanged(‘SBS_logo_3_red_gradient’, handleHoverChanged);
viewer.onMaterialHoverChanged(‘SBS_logo_3_white’, handleHoverChanged)

or because the textures are named the same, bar the color at the end, is there code to select multiple characters, like example SBS_logo_2_"#"??

For four materials you need to register four handlers, but then, in the handler code, just can find all 4 materials (using the Viewer.findMaterial(materialName) function) and change their highlight.