论坛: 公开讨论 (Thread #34603)

dynamic modification of rendered molecule (2013-10-10 18:02 by guillaume #70436)

Hi,
first let me say i'am amazed by your work, glmol run smoothly and embedding in page is straight forward.

Once the molecule is loaded is displayed as defined in defineRepresentation,
I am currently trying to alter the rendering of the molecule according to some events triggered by my page.
Using the api in a dumb way ()

$.get("../data/" + pdbName, function(ret) {
$('#' + self.srcSelector).val(ret);
self.glmol.loadMolecule();
});
//Loading and display ok

//now let's try to modify the color of a growing list of atoms

setInterval (function(){
this.id = this.id ? this.id + 10 : i;
var list = [];
for (var iatom = 1; iatom < this.id; iatom++) {
list.push(iatom);
}
self.glmol.colorAtoms(list, 0x990033);
// console.log(list);
}, 1000);


I'am not familiar at all with webgl

RE: dynamic modification of rendered molecule (2013-10-10 18:12 by biochem_fan #70438)

Hi,

Thank you very much for using GLmol.

You need to swap defineRepresentation() function and then call rebuildScene().
That is,

glmol01.defineRepresentation = function() { .... };
glmol01.rebuildScene();
glmol01.show();

If you just want to change colors, dynamic-coloring branch in my Github
https://github.com/biochem-fan/GLmol/tree/dynamic-coloring
provides much simpler way to change colors.
回复到 #70436

RE: dynamic modification of rendered molecule (2013-10-10 18:28 by guillaume #70439)

I was about to guess it right.
Thank you for pointing that out and such a quick response.

i'll have a look at label git branch

Have ever consider publishing your work ?





回复到 #70438

RE: dynamic modification of rendered molecule (2013-10-10 19:02 by biochem_fan #70440)

> Have ever consider publishing your work ?

No, but I am co-author of JSmol paper.
I contributed WebGL renderer.
回复到 #70439