Comments (2)
I've been working on improving this. The old way to color by properties is this:
glviewer.mapAtomProperties(function(a) { a.properties['b'] = a.b;});
m.setColorByProperty({}, 'b', new $3Dmol.Gradient.Sinebow(0,50));
This is a little cumbersome since you have to copy the property value and we're making the default color of each atom correspond to the property mapped color. Really, the color should be a property of the style, not the atom.
I've committed some code (13f3fc0) that let's you define property mappings as part of the style's color scheme. I've also made it so that b-factors can be referenced as properties.
glviewer.setStyle({},{sphere:{colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.Sinebow(0,50)}}});
There's also a function for computing the range of values of a property if you don't want to hard-code the gradient:
var gradient = new $3Dmol.Gradient.Sinebow($3Dmol.getPropertyRange(glviewer.selectedAtoms(),'b'));
This should work for surfaces as well.
viewer.addSurface($3Dmol.SurfaceType.VDW, {colorscheme:{prop:'b',gradient: gradient}});
You can colormap any numerical property. For example, mol2 and pqr files have a partialCharge property.
The 'spectrum' colorscheme will eventually be just shorthand for specifying a mapping colorscheme from the residue ids, as opposed to the special purpose code it is now (this is the fix to issue #79).
from 3dmol.js.
That's awesome, thanks a lot for the explanation. I'll give it a try as soon as I can.
from 3dmol.js.
Related Issues (20)
- Is it possible to have post-translational modifications (PTMs) features in 3Dmol? HOT 1
- Discrepancy in Atom Rendering Between 3Dmol.js and VESTA for Al1Cd2_H.cif File HOT 4
- .render() is not showing updated representation of models HOT 2
- [BUG] defaultcolors not applied when using addModelsAsFrames HOT 1
- py3Dmol is not working [BUG] HOT 4
- [BUG] Double bonds rendered out of plane (CID: 243, 2244) HOT 2
- Support wireframe and opacity for addIsoSurface in VRML Export HOT 2
- [BUG] Crystal supercell displays in a very weird way HOT 10
- Enable Model Translation on Right-Click and Mouse Movement. HOT 3
- Can't select properly, nor generate cartoon & multiple structures HOT 9
- Assign Property to selection, select and colour by property HOT 2
- View multiple models with absolute positions (i.e. no centering) HOT 8
- Stick representation for IONS HOT 2
- [BUG] WRONG BONDS BEING DRAWN HOT 8
- Opening MANY models efficiently HOT 3
- PRMTOP needs to parse residue names
- Highlighting specific residues HOT 7
- use less CPU for animations HOT 3
- Dinamic protein visualization HOT 1
- How to use native in React Js and Next Js 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 3dmol.js.