Browse Source

fixed intra link referencePosition

Alexander Rose 6 years ago
parent
commit
5c4a44fc99

+ 8 - 2
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
         },

+ 0 - 1
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 {