3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
813 stars 195 forks source link

Color by chains for multiple models #671

Closed data2code closed 1 year ago

data2code commented 1 year ago

Is your feature request related to a problem? Please describe. I plan to display multiple models within one view, so I try to specify styles for each model separately.

If I do not specify which model, the following line colors the object by chains and the protein is displayed: viewer_16811107181320505.setStyle({"chain": "B"},{"cartoon": {"color": "#00ffff"}});

However, once I explicitly specify the model as the following, nothing is displayed: viewer_16811107181320505.setStyle({"model": 0},{"chain": "B"},{"cartoon": {"color": "#00ffff"}});

Describe the solution you'd like My aim is to load two models and specify different colors for each chain of each model separately. What did I do wrong in the above example? Thank you!

data2code commented 1 year ago

Attached are two example files, the difference between good.html and bad.html is there is "model":0 added to bad.html. visual.zip

dkoes commented 1 year ago

setStyle takes a selection object and a style object. You are providing three objects. You need to merge the model and chain specifiers into one object: viewer_16811107181320505.setStyle({"model": 0,"chain": "B"},{"cartoon": {"color": "#00ffff"}});

data2code commented 1 year ago

Thank you so much, extremely helpful!!!