Giter Club home page Giter Club logo

Comments (2)

dkoes avatar dkoes commented on June 12, 2024

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.

josemduarte avatar josemduarte commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.