Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ThreeJS Molecules - Double Bonds

Working with threejs, I am trying to use the following example: http://threejs.org/examples/#css3d_molecules

The problem is that in that example, the bonds from the grey to the red balls are supposed to be double bonds. I have found a few links that suggest how this is done, but it doesn't seem supported by threejs. Here is what I was talking about: https://www.umass.edu/microbio/rasmol/faq_em.htm#doublebonds

There you can see the fumerate molecule (it is a text file) and how they structured it. Any tips on how to add a double bond either visually, or by changing the class of the line so I can change the size or color?

like image 559
Alan Avatar asked Nov 09 '22 22:11

Alan


1 Answers

In the function loadMolecule, there is a loader.load function, some lines from it are pasted below, this is where you would add a second bond next to the first. You'd offset the start and end positions by some vector amount and draw another one.

for ( var i = 0; i < geometryBonds.vertices.length; i += 2 ) {

  var start = geometryBonds.vertices[ i ];
  var end = geometryBonds.vertices[ i + 1 ];

  start.multiplyScalar( 75 );
  end.multiplyScalar( 75 );

  tmpVec1.subVectors( end, start );
  var bondLength = tmpVec1.length() - 50;

}
like image 67
user2016641 Avatar answered Nov 14 '22 22:11

user2016641