|
@@ -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
|
|
|
},
|