Skip to content

Commit f4b9e89

Browse files
authored
invert selected atom color and switch to jmol color scheme (#37)
1 parent 6f60477 commit f4b9e89

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

web-conexs-client/src/components/React3dMol.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default function React3dMol(props: Molecule3DProps) {
4040

4141
const viewer = mol3d.createViewer(moleculeViewer.current, {
4242
backgroundColor: props.color,
43+
defaultcolors: mol3d.elementColors.Jmol,
4344
});
4445

4546
if (props.orbital) {
@@ -97,11 +98,16 @@ export default function React3dMol(props: Molecule3DProps) {
9798
if (props.labelledAtom != undefined) {
9899
viewer.addLabel(
99100
"*",
100-
{ backgroundOpacity: 0, fontSize: 28 },
101+
{ backgroundOpacity: 0, fontSize: 18 },
101102
{ index: props.labelledAtom }
102103
);
103-
104-
104+
const invertColor = function (atom) {
105+
return (0xffffff - atom.color) | 0xff000000;
106+
};
107+
viewer.setStyle(
108+
{ index: props.labelledAtom },
109+
{ sphere: { colorfunc: invertColor, radius: 0.6 } }
110+
);
105111
}
106112
} else if (props.moleculedata) {
107113
const xyz = moleculeInputToXYZ(props.moleculedata);

0 commit comments

Comments
 (0)