nglviewer / ngl

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

How to allow the user change the quality and remove visualization of a component? #445

Open wandreveloso opened 6 years ago

wandreveloso commented 6 years ago

Hi, I'm trying to allow the user, with javascript buttons, set the parameters of a protein visualization (quality low, medium and high) and remove surface or sticks, but I can't find any examples of this. Can anybody help me?

wandreveloso commented 6 years ago

@arose @fredludlow

ppillot commented 6 years ago

If you want to modify a representation after its creation, you need to keep it (or the components, or the stage it belongs to) in a javascript variable. When that is the case, you can adjust the representation parameters to your users actions. for example, r = stage.compList[0].addRepresentation('licorice') if you want to hide this representation, you can r.setVisibility(false) if you want to change quality, you can r.setParameters({quality: 'high'})

arose commented 6 years ago

For more examples of how to script NGL, look at the gallery here http://nglviewer.org/ts2/gallery/index.html