Sfoglia il codice sorgente

lines fixes and tweaks

Alexander Rose 4 anni fa
parent
commit
9b6fcaeb79

+ 1 - 1
src/mol-geo/geometry/lines/lines-builder.ts

@@ -83,7 +83,7 @@ export namespace LinesBuilder {
                 const gb = ChunkedArray.compact(groups, true) as Float32Array;
                 const sb = ChunkedArray.compact(starts, true) as Float32Array;
                 const eb = ChunkedArray.compact(ends, true) as Float32Array;
-                return Lines.create(mb, ib, gb, sb, eb, indices.elementCount / 2);
+                return Lines.create(mb, ib, gb, sb, eb, indices.elementCount / 2, lines);
             }
         };
     }

+ 1 - 1
src/mol-repr/structure/units-representation.ts

@@ -104,7 +104,7 @@ export function UnitsRepresentation<P extends StructureParams>(label: string, ct
                     if (runtime.shouldUpdate) await runtime.update({ message: 'Creating or updating UnitsVisual', current: i, max: _groups.length });
                 }
                 oldVisuals.forEach(({ visual }) => {
-                    // console.log(label, 'removed unused visual')
+                    // console.log(label, 'removed unused visual');
                     visual.destroy();
                 });
 

+ 4 - 9
src/mol-repr/structure/visual/bond-inter-unit-line.ts

@@ -15,7 +15,7 @@ import { ComplexVisual, ComplexLinesVisual, ComplexLinesParams } from '../comple
 import { VisualUpdateState } from '../../util';
 import { isHydrogen } from './util/common';
 import { BondType } from '../../../mol-model/structure/model/types';
-import { ignoreBondType, BondCylinderParams, BondIterator, getInterBondLoci, eachInterBond } from './util/bond';
+import { ignoreBondType, BondIterator, getInterBondLoci, eachInterBond, BondLineParams } from './util/bond';
 import { Lines } from '../../../mol-geo/geometry/lines/lines';
 
 const tmpRefPosBondIt = new Bond.ElementBondIterator();
@@ -35,7 +35,7 @@ const tmpLoc = StructureElement.Location.create(void 0);
 function createInterUnitBondLines(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InterUnitBondLineParams>, lines?: Lines) {
     const bonds = structure.interUnitBonds;
     const { edgeCount, edges } = bonds;
-    const { sizeFactor, sizeAspectRatio, ignoreHydrogens, includeTypes, excludeTypes } = props;
+    const { sizeFactor, ignoreHydrogens, includeTypes, excludeTypes } = props;
 
     const include = BondType.fromNames(includeTypes);
     const exclude = BondType.fromNames(excludeTypes);
@@ -94,7 +94,7 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them
             tmpLoc.unit = b.unitB;
             tmpLoc.element = b.unitB.elements[b.indexB];
             const sizeB = theme.size.size(tmpLoc);
-            return Math.min(sizeA, sizeB) * sizeFactor * sizeAspectRatio;
+            return Math.min(sizeA, sizeB) * sizeFactor;
         },
         ignore: (edgeIndex: number) => ignoreHydrogen(edgeIndex) || ignoreBondType(include, exclude, edges[edgeIndex].props.flag)
     };
@@ -104,9 +104,7 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them
 
 export const InterUnitBondLineParams = {
     ...ComplexLinesParams,
-    ...BondCylinderParams,
-    sizeFactor: PD.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
-    sizeAspectRatio: PD.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }),
+    ...BondLineParams,
     ignoreHydrogens: PD.Boolean(false),
 };
 export type InterUnitBondLineParams = typeof InterUnitBondLineParams
@@ -121,12 +119,9 @@ export function InterUnitBondLineVisual(materialId: number): ComplexVisual<Inter
         setUpdateState: (state: VisualUpdateState, newProps: PD.Values<InterUnitBondLineParams>, currentProps: PD.Values<InterUnitBondLineParams>) => {
             state.createGeometry = (
                 newProps.sizeFactor !== currentProps.sizeFactor ||
-                newProps.sizeAspectRatio !== currentProps.sizeAspectRatio ||
-                newProps.radialSegments !== currentProps.radialSegments ||
                 newProps.linkScale !== currentProps.linkScale ||
                 newProps.linkSpacing !== currentProps.linkSpacing ||
                 newProps.ignoreHydrogens !== currentProps.ignoreHydrogens ||
-                newProps.linkCap !== currentProps.linkCap ||
                 !arrayEqual(newProps.includeTypes, currentProps.includeTypes) ||
                 !arrayEqual(newProps.excludeTypes, currentProps.excludeTypes)
             );

+ 2 - 2
src/mol-repr/structure/visual/util/bond.ts

@@ -9,7 +9,7 @@ import { Unit, StructureElement, Structure, Bond } from '../../../../mol-model/s
 import { ParamDefinition as PD } from '../../../../mol-util/param-definition';
 import { LocationIterator } from '../../../../mol-geo/util/location-iterator';
 import { StructureGroup } from '../../units-visual';
-import { LinkCylinderParams, LinkParams } from './link';
+import { LinkCylinderParams, LinkLineParams } from './link';
 import { ObjectKeys } from '../../../../mol-util/type-helpers';
 import { PickingId } from '../../../../mol-geo/geometry/picking';
 import { EmptyLoci, Loci } from '../../../../mol-model/loci';
@@ -30,7 +30,7 @@ export const DefaultBondCylinderProps = PD.getDefaultValues(BondCylinderParams);
 export type BondCylinderProps = typeof DefaultBondCylinderProps
 
 export const BondLineParams = {
-    ...LinkParams,
+    ...LinkLineParams,
     ...BondParams
 };
 export const DefaultBondLineProps = PD.getDefaultValues(BondLineParams);

+ 12 - 12
src/mol-repr/structure/visual/util/link.ts

@@ -15,21 +15,22 @@ import { BaseGeometry } from '../../../../mol-geo/geometry/base';
 import { Lines } from '../../../../mol-geo/geometry/lines/lines';
 import { LinesBuilder } from '../../../../mol-geo/geometry/lines/lines-builder';
 
-export const LinkParams = {
+export const LinkCylinderParams = {
     linkScale: PD.Numeric(0.4, { min: 0, max: 1, step: 0.1 }),
     linkSpacing: PD.Numeric(1, { min: 0, max: 2, step: 0.01 }),
-};
-export const DefaultLinkProps = PD.getDefaultValues(LinkParams);
-export type LinkProps = typeof DefaultLinkProps
-
-export const LinkCylinderParams = {
-    ...LinkParams,
     linkCap: PD.Boolean(false),
     radialSegments: PD.Numeric(16, { min: 2, max: 56, step: 2 }, BaseGeometry.CustomQualityParamInfo),
 };
 export const DefaultLinkCylinderProps = PD.getDefaultValues(LinkCylinderParams);
 export type LinkCylinderProps = typeof DefaultLinkCylinderProps
 
+export const LinkLineParams = {
+    linkScale: PD.Numeric(0.5, { min: 0, max: 1, step: 0.1 }),
+    linkSpacing: PD.Numeric(0.1, { min: 0, max: 2, step: 0.01 }),
+};
+export const DefaultLinkLineProps = PD.getDefaultValues(LinkLineParams);
+export type LinkLineProps = typeof DefaultLinkLineProps
+
 const tmpV12 = Vec3();
 const tmpShiftV12 = Vec3();
 const tmpShiftV13 = Vec3();
@@ -160,8 +161,8 @@ export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkBuil
  * Each edge is included twice to allow for coloring/picking
  * the half closer to the first vertex, i.e. vertex a.
  */
-export function createLinkLines(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkProps, lines?: Lines) {
-    const { linkCount, referencePosition, position, style, radius, ignore } = linkBuilder;
+export function createLinkLines(ctx: VisualContext, linkBuilder: LinkBuilderProps, props: LinkLineProps, lines?: Lines) {
+    const { linkCount, referencePosition, position, style, ignore } = linkBuilder;
 
     if (!linkCount) return Lines.createEmpty(lines);
 
@@ -181,15 +182,14 @@ export function createLinkLines(ctx: VisualContext, linkBuilder: LinkBuilderProp
         Vec3.scale(vb, Vec3.add(vb, va, vb), 0.5);
 
         // TODO use line width?
-        const linkRadius = radius(edgeIndex);
         const linkStyle = style ? style(edgeIndex) : LinkStyle.Solid;
 
         if (linkStyle === LinkStyle.Dashed) {
             builder.addFixedCountDashes(va, vb, 7, edgeIndex);
         } else if (linkStyle === LinkStyle.Double || linkStyle === LinkStyle.Triple) {
             const order = LinkStyle.Double ? 2 : 3;
-            const multiRadius = linkRadius * (linkScale / (0.5 * order));
-            const absOffset = (linkRadius - multiRadius) * linkSpacing;
+            const multiRadius = 1 * (linkScale / (0.5 * order));
+            const absOffset = (1 - multiRadius) * linkSpacing;
 
             calculateShiftDir(vShift, va, vb, referencePosition ? referencePosition(edgeIndex) : null);
             Vec3.setMagnitude(vShift, vShift, absOffset);