ThreeJS molecules - double bonds

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

The problem is that in this example, the bonds from the gray to the red ball should be double bonds. I found some links that suggest how this is done, but this is not supported by threejs. Here is what I talked about: https://www.umass.edu/microbio/rasmol/faq_em.htm#doublebonds

There you can see the fumerate molecule (this 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 that I can change the size or color?

+4
source share
1 answer

The loadMolecule function has a loader.load function, some lines from it are pasted below, this is where you add the second link next to the first. You shift the start and end positions by a certain amount of the vector and draw another.

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;

}
0
source

All Articles