diff --git a/src/GLModel.ts b/src/GLModel.ts index c44ab1fc6..342e0860c 100644 --- a/src/GLModel.ts +++ b/src/GLModel.ts @@ -732,6 +732,9 @@ export class GLModel { return; var atomBondR = style.radius || this.defaultStickRadius; + var doubleBondScale = style.doubleBondScaling || 0.4; + var tripleBondScale = style.tripleBondScaling || 0.25; + var bondR = atomBondR; var atomSingleBond = style.singleBonds || false; var fromCap = 0, toCap = 0; @@ -839,7 +842,7 @@ export class GLModel { v = this.getSideBondV(atom, atom2, i); if (atom.bondOrder[i] == 2) { - r = bondR / 2.5; + r = bondR * doubleBondScale; v.multiplyScalar(r * 1.5); p1a = p1.clone(); @@ -889,7 +892,7 @@ export class GLModel { } } else if (atom.bondOrder[i] == 3) { - r = bondR / 4; + r = bondR * tripleBondScale; v.cross(dir); v.normalize(); v.multiplyScalar(r * 3); @@ -2872,6 +2875,10 @@ export interface StickStyleSpec { hidden?: boolean; /** radius of stick */ radius?: number; + /** radius scaling factor for drawing double bonds (default 0.4) */ + doubleBondScaling?: number; + /** radius scaling factor for drawing triple bonds (default 0.25) */ + tripleBondScaling?: number; /** draw all bonds as single bonds */ singleBonds?: boolean; /** colorscheme to use on atoms; overrides color */ diff --git a/src/GLShape.ts b/src/GLShape.ts index f501a34b6..7cf4aa94b 100644 --- a/src/GLShape.ts +++ b/src/GLShape.ts @@ -633,7 +633,7 @@ export class GLShape { boundingSphere: Sphere; intersectionShape: any; - color: any; + color: any = 0xffffff; hidden = false; wireframe = false; opacity = 1; diff --git a/tests/auto/tests/bondscaling.js b/tests/auto/tests/bondscaling.js new file mode 100644 index 000000000..530601ca9 --- /dev/null +++ b/tests/auto/tests/bondscaling.js @@ -0,0 +1,6 @@ +$3Dmol.download("cid:10321", viewer, {}, function () { + viewer.setStyle({stick:{doubleBondScaling: 1, tripleBondScaling: 0.5}}); + + viewer.zoomTo(); + viewer.render(); +}); diff --git a/tests/glcheck/reference-images/tests-glcheck-render-tests-bondscaling.html.png b/tests/glcheck/reference-images/tests-glcheck-render-tests-bondscaling.html.png new file mode 100644 index 000000000..acafabf2a Binary files /dev/null and b/tests/glcheck/reference-images/tests-glcheck-render-tests-bondscaling.html.png differ