3dmol/3Dmol.js

outline style in selected atom?

shubihu opened this issue · 5 comments

Hi, David, Use viewer.setViewStyle({style:"outline",color:"red",width:0.1}), the viewer display the outline style in all atoms.
Does support only display outline style in selected atom ? Thank you.

dkoes commented

Outline style is a function of the viewer and cannot be applied to individual atoms. If you want to highlight individual atoms you need to create your own selection spheres (e.g. #482).

Thanks, finaly I highlight individual atoms as follow:

viewer.setHoverable({},true,function(atom,viewer,event,container) {
     if(!atom.label) {
      viewer.setStyle({resi:atom.resi}, {cartoon: {color: '#FDFEFE'}});
      atom.label = viewer.addLabel(atom.resn+":"+atom.atom,{position: atom, backgroundColor: 'mintcream', fontColor:'black'});
      viewer.render();
     }
 },
 function(atom) {
     if(atom.label) {
      viewer.removeLabel(atom.label);
      delete atom.label;
      viewer.setStyle({resi:atom.resi}, {cartoon: {color: 'spectrum'}});
      viewer.render();
     }
    }
  );

But this delay is about 0.5s or even 1s, how can I optimize it?

dkoes commented

You can set the hoverDuration as a configuration option to the viewer:
https://3dmol.org/doc/ViewerSpec.html#hoverDuration

The default is 500ms, but perhaps hover isn't what you want since that's a pretty typical delay.

dkoes commented

You can also change the hover timeout after viewer creation:
https://3dmol.csb.pitt.edu/doc/GLViewer.html#setHoverDuration

Great ! It works, Thank you!