From 5c4a44fc99823713304eab986f531b717a936513 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Wed, 6 Mar 2019 15:33:39 -0800 Subject: [PATCH] fixed intra link referencePosition --- .../structure/visual/intra-unit-link-cylinder.ts | 10 ++++++++-- src/mol-repr/structure/visual/util/link.ts | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts index 116ef8cf1..9f86c6700 100644 --- a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts @@ -40,12 +40,18 @@ function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structu linkCount: edgeCount * 2, referencePosition: (edgeIndex: number) => { let aI = a[edgeIndex], bI = b[edgeIndex]; + if (aI > bI) [aI, bI] = [bI, aI] + if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI] + // TODO prefer reference atoms in rings + for (let i = offset[aI], il = offset[aI + 1]; i < il; ++i) { - if (b[i] !== bI) return pos(elements[b[i]], vRef) + const _bI = b[i] + if (_bI !== bI && _bI !== aI) return pos(elements[_bI], vRef) } for (let i = offset[bI], il = offset[bI + 1]; i < il; ++i) { - if (a[i] !== aI) return pos(elements[a[i]], vRef) + const _aI = a[i] + if (_aI !== aI && _aI !== bI) return pos(elements[_aI], vRef) } return null }, diff --git a/src/mol-repr/structure/visual/util/link.ts b/src/mol-repr/structure/visual/util/link.ts index 956f61728..ab5ddbd8f 100644 --- a/src/mol-repr/structure/visual/util/link.ts +++ b/src/mol-repr/structure/visual/util/link.ts @@ -29,7 +29,6 @@ const tmpShiftV13 = Vec3.zero() /** Calculate 'shift' direction that is perpendiculat to v1 - v2 and goes through v3 */ export function calculateShiftDir (out: Vec3, v1: Vec3, v2: Vec3, v3: Vec3 | null) { Vec3.normalize(tmpShiftV12, Vec3.sub(tmpShiftV12, v1, v2)) - if (v3 !== null) { Vec3.sub(tmpShiftV13, v1, v3) } else { -- GitLab