nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
664 stars 169 forks source link

Select the entire molecule by clicking on its atom #1039

Open hellhorse123 opened 5 months ago

hellhorse123 commented 5 months ago

How to implement the behavior: highlight a molecule and display information about all its atoms when you click on an atom in this molecule?

I guess what I need to use:

stage.signals.clicked.add((pickingProxy: any) => {
      if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {
        const atom = pickingProxy.atom || pickingProxy.closestBondAtom;
        console.log(atom); // Update selected residues
      }
});

but I don’t understand the implementation

papillot commented 5 months ago

Right, with this code atom will be a reference to an AtomProxy object. This object has many properties which are useful to get the element name, the corresponding residue and chain, etc...