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 116ef8cf1eecafc06f6728b38fe32ed09109b5ee..9f86c6700696e789bcfd4b4b4895b981facc26bc 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 956f617281fabe76a138e3f77acd0a5aa18689fa..ab5ddbd8f996c460a8a55573f9b239a94b87c6de 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 {