How to change a selection color

How to change a selection color

Web Toolkit version 1.x

There is an opportunity to change the selection color. In viewer.js you need to add a ModelData_ColorObject in ModelPrs_DisplayParams and add ModelPrs_DisplayParams into ModelPrs_DisplayerApplier

This a small example how to do it.

await cadex.ModelPrs_DisplayerApplier.apply(aLoadResult.roots, [], {
    displayer: new SceneDisplayer(aScene, aJsTree, aFileNode),
    displayMode: aDisplayMode,
    repSelector: new cadex.ModelData_RepresentationMaskSelector(aRepMode),
    selectionColor: new cadex.ModelData_ColorObject(1, 0, 1, 1) });

Web Toolkit version 3.x

Here there is a class ModelPrs_Style each object ModelPrs_SceneNode has. ModelPrs_Style has members "selectionAppearance" and "highlightAppearance". You can refer in PMI Example to view this functionality. The code of source example is represented here.

const aStyle = new cadex.ModelPrs_Style();
aStyle.selectionAppearance = new cadex.ModelData_Appearance(cadex.ModelData_ColorObject.fromHex(0xff0000)); // Red color
aStyle.highlightAppearance = new cadex.ModelData_Appearance(cadex.ModelData_ColorObject.fromHex(0xff0000));
aStyle.boundariesHighlightAppearance = new cadex.ModelData_Appearance(cadex.ModelData_ColorObject.fromHex(0xb2ff65));
aRootSceneNode.style = aStyle;