Browse Source

apply Structure.coordinateSystem to interactions visual

David Sehnal 5 years ago
parent
commit
f5f9237a78

+ 2 - 0
src/mol-model-props/computed/representations/interactions-inter-unit-cylinder.ts

@@ -40,8 +40,10 @@ function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: S
             const { unitA, indexA, unitB, indexB } = edges[edgeIndex];
             const fA = unitsFeatures.get(unitA.id);
             const fB = unitsFeatures.get(unitB.id);
+
             Vec3.set(posA, fA.x[indexA], fA.y[indexA], fA.z[indexA]);
             Vec3.transformMat4(posA, posA, unitA.conformation.operator.matrix);
+
             Vec3.set(posB, fB.x[indexB], fB.y[indexB], fB.z[indexB]);
             Vec3.transformMat4(posB, posB, unitB.conformation.operator.matrix);
         },

+ 6 - 3
src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts

@@ -5,7 +5,7 @@
  */
 
 import { Unit, Structure, StructureElement } from '../../../mol-model/structure';
-import { Vec3 } from '../../../mol-math/linear-algebra';
+import { Vec3, Mat4 } from '../../../mol-math/linear-algebra';
 import { Loci, EmptyLoci } from '../../../mol-model/loci';
 import { Interval } from '../../../mol-data/int';
 import { ParamDefinition as PD } from '../../../mol-util/param-definition';
@@ -35,15 +35,18 @@ async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit:
     const { sizeFactor } = props;
     const { matrix } = unit.conformation.operator;
 
+    const operator = Mat4.copy(Mat4(), structure.coordinateSystem.inverse);
+    Mat4.mul(operator, operator, matrix);
+
     if (!edgeCount) return Mesh.createEmpty(mesh);
 
     const builderProps = {
         linkCount: edgeCount * 2,
         position: (posA: Vec3, posB: Vec3, edgeIndex: number) => {
             Vec3.set(posA, x[a[edgeIndex]], y[a[edgeIndex]], z[a[edgeIndex]]);
-            Vec3.transformMat4(posA, posA, matrix);
+            Vec3.transformMat4(posA, posA, operator);
             Vec3.set(posB, x[b[edgeIndex]], y[b[edgeIndex]], z[b[edgeIndex]]);
-            Vec3.transformMat4(posB, posB, matrix);
+            Vec3.transformMat4(posB, posB, operator);
         },
         style: (edgeIndex: number) => LinkCylinderStyle.Dashed,
         radius: (edgeIndex: number) => {