Prechádzať zdrojové kódy

avoid some static dependencies

- those can lead to errors due to circular dependencies
- making them runtime dependencies fixes this
Alexander Rose 4 rokov pred
rodič
commit
a16faaac4e
34 zmenil súbory, kde vykonal 174 pridanie a 159 odobranie
  1. 6 5
      src/apps/docking-viewer/index.ts
  2. 7 6
      src/apps/viewer/index.ts
  3. 1 1
      src/examples/alpha-orbitals/index.ts
  4. 1 1
      src/examples/basic-wrapper/index.ts
  5. 1 1
      src/examples/lighting/index.ts
  6. 1 1
      src/examples/proteopedia-wrapper/index.ts
  7. 3 2
      src/extensions/anvil/algorithm.ts
  8. 1 1
      src/mol-math/geometry/boundary-helper.ts
  9. 1 1
      src/mol-math/geometry/centroid-helper.ts
  10. 1 1
      src/mol-math/geometry/molecular-surface.ts
  11. 8 5
      src/mol-math/geometry/symmetry-operator.ts
  12. 5 5
      src/mol-math/linear-algebra/3d/mat3.ts
  13. 25 25
      src/mol-math/linear-algebra/3d/mat4.ts
  14. 3 3
      src/mol-math/linear-algebra/3d/quat.ts
  15. 17 15
      src/mol-math/linear-algebra/3d/vec3.ts
  16. 1 1
      src/mol-math/linear-algebra/3d/vec4.ts
  17. 2 1
      src/mol-math/linear-algebra/_spec/mat3.spec.ts
  18. 6 5
      src/mol-math/linear-algebra/_spec/mat4.spec.ts
  19. 1 1
      src/mol-math/linear-algebra/_spec/tensor.spec.ts
  20. 7 1
      src/mol-math/linear-algebra/_spec/vec3.spec.ts
  21. 1 1
      src/mol-math/linear-algebra/matrix/principal-axes.ts
  22. 4 1
      src/mol-math/linear-algebra/tensor.ts
  23. 2 2
      src/mol-model-props/computed/accessible-surface-area/shrake-rupley/area.ts
  24. 1 2
      src/mol-model-props/computed/accessible-surface-area/shrake-rupley/radii.ts
  25. 7 9
      src/mol-model-props/computed/representations/interactions-inter-unit-cylinder.ts
  26. 4 6
      src/mol-model/structure/export/categories/atom_site.ts
  27. 4 4
      src/mol-model/structure/export/categories/secondary-structure.ts
  28. 2 1
      src/mol-plugin-state/animation/built-in/camera-spin.ts
  29. 3 3
      src/mol-plugin-state/helpers/structure-component.ts
  30. 8 8
      src/mol-plugin-state/transforms/model.ts
  31. 24 24
      src/mol-plugin-state/transforms/representation.ts
  32. 1 1
      src/mol-plugin/behavior/dynamic/custom-props/structure-info.ts
  33. 4 4
      src/mol-plugin/index.ts
  34. 11 11
      src/mol-repr/structure/visual/bond-inter-unit-line.ts

+ 6 - 5
src/apps/docking-viewer/index.ts

@@ -69,9 +69,10 @@ class Viewer {
             viewportShowSelectionMode: false,
             viewportShowAnimation: false,
         } };
+        const defaultSpec = DefaultPluginSpec();
 
         const spec: PluginSpec = {
-            actions: [...DefaultPluginSpec.actions],
+            actions: [...defaultSpec.actions],
             behaviors: [
                 PluginSpec.Behavior(PluginBehaviors.Representation.HighlightLoci, { mark: false }),
                 PluginSpec.Behavior(PluginBehaviors.Representation.DefaultLociLabelProvider),
@@ -81,8 +82,8 @@ class Viewer {
                 PluginSpec.Behavior(PluginBehaviors.CustomProps.Interactions),
                 PluginSpec.Behavior(PluginBehaviors.CustomProps.SecondaryStructure),
             ],
-            animations: [...DefaultPluginSpec.animations || []],
-            customParamEditors: DefaultPluginSpec.customParamEditors,
+            animations: [...defaultSpec.animations || []],
+            customParamEditors: defaultSpec.customParamEditors,
             layout: {
                 initial: {
                     isExpanded: o.layoutIsExpanded,
@@ -90,14 +91,14 @@ class Viewer {
                     controlsDisplay: o.layoutControlsDisplay,
                 },
                 controls: {
-                    ...DefaultPluginSpec.layout && DefaultPluginSpec.layout.controls,
+                    ...defaultSpec.layout && defaultSpec.layout.controls,
                     top: o.layoutShowSequence ? undefined : 'none',
                     bottom: o.layoutShowLog ? undefined : 'none',
                     left: o.layoutShowLeftPanel ? undefined : 'none',
                 }
             },
             components: {
-                ...DefaultPluginSpec.components,
+                ...defaultSpec.components,
                 remoteState: o.layoutShowRemoteState ? 'default' : 'none',
                 viewport: {
                     view: ViewportComponent

+ 7 - 6
src/apps/viewer/index.ts

@@ -89,15 +89,16 @@ export class Viewer {
 
     constructor(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
         const o = { ...DefaultViewerOptions, ...options };
+        const defaultSpec = DefaultPluginSpec();
 
         const spec: PluginSpec = {
-            actions: [...DefaultPluginSpec.actions],
+            actions: [...defaultSpec.actions],
             behaviors: [
-                ...DefaultPluginSpec.behaviors,
+                ...defaultSpec.behaviors,
                 ...o.extensions.map(e => Extensions[e]),
             ],
-            animations: [...DefaultPluginSpec.animations || []],
-            customParamEditors: DefaultPluginSpec.customParamEditors,
+            animations: [...defaultSpec.animations || []],
+            customParamEditors: defaultSpec.customParamEditors,
             customFormats: o?.customFormats,
             layout: {
                 initial: {
@@ -106,14 +107,14 @@ export class Viewer {
                     controlsDisplay: o.layoutControlsDisplay,
                 },
                 controls: {
-                    ...DefaultPluginSpec.layout && DefaultPluginSpec.layout.controls,
+                    ...defaultSpec.layout && defaultSpec.layout.controls,
                     top: o.layoutShowSequence ? undefined : 'none',
                     bottom: o.layoutShowLog ? undefined : 'none',
                     left: o.layoutShowLeftPanel ? undefined : 'none',
                 }
             },
             components: {
-                ...DefaultPluginSpec.components,
+                ...defaultSpec.components,
                 remoteState: o.layoutShowRemoteState ? 'default' : 'none',
             },
             config: [

+ 1 - 1
src/examples/alpha-orbitals/index.ts

@@ -53,7 +53,7 @@ export class AlphaOrbitalsExample {
 
     async init(target: string | HTMLElement) {
         this.plugin = await createPluginAsync(typeof target === 'string' ? document.getElementById(target)! : target, {
-            ...DefaultPluginSpec,
+            ...DefaultPluginSpec(),
             layout: {
                 initial: {
                     isExpanded: false,

+ 1 - 1
src/examples/basic-wrapper/index.ts

@@ -28,7 +28,7 @@ class BasicWrapper {
 
     init(target: string | HTMLElement) {
         this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
-            ...DefaultPluginSpec,
+            ...DefaultPluginSpec(),
             layout: {
                 initial: {
                     isExpanded: false,

+ 1 - 1
src/examples/lighting/index.ts

@@ -67,7 +67,7 @@ class LightingDemo {
 
     init(target: string | HTMLElement) {
         this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
-            ...DefaultPluginSpec,
+            ...DefaultPluginSpec(),
             layout: {
                 initial: {
                     isExpanded: false,

+ 1 - 1
src/examples/proteopedia-wrapper/index.ts

@@ -46,7 +46,7 @@ class MolStarProteopediaWrapper {
         customColorList?: number[]
     }) {
         this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
-            ...DefaultPluginSpec,
+            ...DefaultPluginSpec(),
             animations: [
                 AnimateModelIndex
             ],

+ 3 - 2
src/extensions/anvil/algorithm.ts

@@ -54,13 +54,13 @@ export function computeANVIL(structure: Structure, props: ANVILProps) {
     });
 }
 
-const l = StructureElement.Location.create(void 0);
+
 const centroidHelper = new CentroidHelper();
 function initialize(structure: Structure, props: ANVILProps): ANVILContext {
+    const l = StructureElement.Location.create(structure);
     const { label_atom_id, x, y, z } = StructureProperties.atom;
     const elementCount = structure.polymerResidueCount;
     centroidHelper.reset();
-    l.structure = structure;
 
     let offsets = new Int32Array(elementCount);
     let exposed = new Array<boolean>(elementCount);
@@ -328,6 +328,7 @@ namespace HphobHphil {
     const testPoint = Vec3();
     export function filtered(ctx: ANVILContext, label_comp_id: StructureElement.Property<string>, filter?: (test: Vec3) => boolean): HphobHphil {
         const { offsets, exposed, structure } = ctx;
+        const l = StructureElement.Location.create(structure);
         const { x, y, z } = StructureProperties.atom;
         let hphob = 0;
         let hphil = 0;

+ 1 - 1
src/mol-math/geometry/boundary-helper.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Vec3 } from '../linear-algebra/3d';
+import { Vec3 } from '../linear-algebra/3d/vec3';
 import { CentroidHelper } from './centroid-helper';
 import { Sphere3D } from '../geometry';
 import { Box3D } from './primitives/box3d';

+ 1 - 1
src/mol-math/geometry/centroid-helper.ts

@@ -5,7 +5,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Vec3 } from '../../mol-math/linear-algebra/3d';
+import { Vec3 } from '../../mol-math/linear-algebra/3d/vec3';
 import { Sphere3D } from './primitives/sphere3d';
 
 export { CentroidHelper };

+ 1 - 1
src/mol-math/geometry/molecular-surface.ts

@@ -12,7 +12,7 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { RuntimeContext } from '../../mol-task';
 import { OrderedSet } from '../../mol-data/int';
 import { PositionData } from './common';
-import { Mat4 } from '../../mol-math/linear-algebra/3d';
+import { Mat4 } from '../../mol-math/linear-algebra/3d/mat4';
 import { Box3D, GridLookup3D, fillGridDim } from '../../mol-math/geometry';
 import { BaseGeometry } from '../../mol-geo/geometry/base';
 import { Boundary } from './boundary';

+ 8 - 5
src/mol-math/geometry/symmetry-operator.ts

@@ -4,9 +4,12 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Vec3, Mat4, Mat3, Quat } from '../linear-algebra/3d';
 import { lerp as scalar_lerp } from '../../mol-math/interpolate';
 import { defaults } from '../../mol-util';
+import { Mat3 } from '../linear-algebra/3d/mat3';
+import { Mat4 } from '../linear-algebra/3d/mat4';
+import { Quat } from '../linear-algebra/3d/quat';
+import { Vec3 } from '../linear-algebra/3d/vec3';
 
 interface SymmetryOperator {
     readonly name: string,
@@ -51,13 +54,13 @@ namespace SymmetryOperator {
     export type CreateInfo = { assembly?: SymmetryOperator['assembly'], ncsId?: number, hkl?: Vec3, spgrOp?: number }
     export function create(name: string, matrix: Mat4, info?: CreateInfo): SymmetryOperator {
         let { assembly, ncsId, hkl, spgrOp } = info || { };
-        const _hkl = hkl ? Vec3.clone(hkl) : Vec3.zero();
+        const _hkl = hkl ? Vec3.clone(hkl) : Vec3();
         spgrOp = defaults(spgrOp, -1);
         ncsId = ncsId || -1;
         const suffix = getSuffix(info);
         if (Mat4.isIdentity(matrix)) return { name, assembly, matrix, inverse: Mat4.identity(), isIdentity: true, hkl: _hkl, spgrOp, ncsId, suffix };
         if (!Mat4.isRotationAndTranslation(matrix, RotationTranslationEpsilon)) throw new Error(`Symmetry operator (${name}) must be a composition of rotation and translation.`);
-        return { name, assembly, matrix, inverse: Mat4.invert(Mat4.zero(), matrix), isIdentity: false, hkl: _hkl, spgrOp, ncsId, suffix };
+        return { name, assembly, matrix, inverse: Mat4.invert(Mat4(), matrix), isIdentity: false, hkl: _hkl, spgrOp, ncsId, suffix };
     }
 
     function getSuffix(info?: CreateInfo) {
@@ -101,7 +104,7 @@ namespace SymmetryOperator {
         return create(name, t, { ncsId });
     }
 
-    const _q1 = Quat.identity(), _q2 = Quat.zero(), _q3 = Quat.zero(), _axis = Vec3.zero();
+    const _q1 = Quat.identity(), _q2 = Quat(), _q3 = Quat(), _axis = Vec3();
     export function lerpFromIdentity(out: Mat4, op: SymmetryOperator, t: number): Mat4 {
         const m = op.inverse;
         if (op.isIdentity) return Mat4.copy(out, m);
@@ -145,7 +148,7 @@ namespace SymmetryOperator {
      * Keep `name`, `assembly`, `ncsId`, `hkl` and `spgrOpId` properties from second.
      */
     export function compose(first: SymmetryOperator, second: SymmetryOperator) {
-        const matrix = Mat4.mul(Mat4.zero(), second.matrix, first.matrix);
+        const matrix = Mat4.mul(Mat4(), second.matrix, first.matrix);
         return create(second.name, matrix, second);
     }
 

+ 5 - 5
src/mol-math/linear-algebra/3d/mat3.ts

@@ -134,7 +134,7 @@ namespace Mat3 {
      * Creates a new Mat3 initialized with values from an existing matrix
      */
     export function clone(a: Mat3) {
-        return Mat3.copy(Mat3.zero(), a);
+        return copy(zero(), a);
     }
 
     export function areEqual(a: Mat3, b: Mat3, eps: number) {
@@ -372,7 +372,7 @@ namespace Mat3 {
     }
 
     const piThird = Math.PI / 3;
-    const tmpB = Mat3();
+    const tmpB = zero();
     /**
      * Given a real symmetric 3x3 matrix A, compute the eigenvalues
      *
@@ -447,9 +447,9 @@ namespace Mat3 {
      * Get matrix to transform directions, e.g. normals
      */
     export function directionTransform(out: Mat3, t: Mat4) {
-        Mat3.fromMat4(out, t);
-        Mat3.invert(out, out);
-        Mat3.transpose(out, out);
+        fromMat4(out, t);
+        invert(out, out);
+        transpose(out, out);
         return out;
     }
 

+ 25 - 25
src/mol-math/linear-algebra/3d/mat4.ts

@@ -165,17 +165,17 @@ namespace Mat4 {
     }
 
     export function fromBasis(a: Mat4, x: Vec3, y: Vec3, z: Vec3) {
-        Mat4.setZero(a);
-        Mat4.setValue(a, 0, 0, x[0]);
-        Mat4.setValue(a, 1, 0, x[1]);
-        Mat4.setValue(a, 2, 0, x[2]);
-        Mat4.setValue(a, 0, 1, y[0]);
-        Mat4.setValue(a, 1, 1, y[1]);
-        Mat4.setValue(a, 2, 1, y[2]);
-        Mat4.setValue(a, 0, 2, z[0]);
-        Mat4.setValue(a, 1, 2, z[1]);
-        Mat4.setValue(a, 2, 2, z[2]);
-        Mat4.setValue(a, 3, 3, 1);
+        setZero(a);
+        setValue(a, 0, 0, x[0]);
+        setValue(a, 1, 0, x[1]);
+        setValue(a, 2, 0, x[2]);
+        setValue(a, 0, 1, y[0]);
+        setValue(a, 1, 1, y[1]);
+        setValue(a, 2, 1, y[2]);
+        setValue(a, 0, 2, z[0]);
+        setValue(a, 1, 2, z[1]);
+        setValue(a, 2, 2, z[2]);
+        setValue(a, 3, 3, 1);
         return a;
     }
 
@@ -200,7 +200,7 @@ namespace Mat4 {
     }
 
     export function clone(a: Mat4) {
-        return Mat4.copy(Mat4.zero(), a);
+        return copy(zero(), a);
     }
 
     /**
@@ -541,7 +541,7 @@ namespace Mat4 {
             b20, b21, b22;
 
         if (Math.abs(len) < EPSILON) {
-            return Mat4.identity();
+            return identity();
         }
 
         len = 1 / len;
@@ -1075,29 +1075,29 @@ namespace Mat4 {
     const zAxis = Vec3.create(0, 0, 1);
 
     /** Rotation matrix for 90deg around x-axis */
-    export const rotX90: ReadonlyMat4 = fromRotation(Mat4(), degToRad(90), xAxis);
+    export const rotX90: ReadonlyMat4 = fromRotation(zero(), degToRad(90), xAxis);
     /** Rotation matrix for 180deg around x-axis */
-    export const rotX180: ReadonlyMat4 = fromRotation(Mat4(), degToRad(180), xAxis);
+    export const rotX180: ReadonlyMat4 = fromRotation(zero(), degToRad(180), xAxis);
     /** Rotation matrix for 90deg around y-axis */
-    export const rotY90: ReadonlyMat4 = fromRotation(Mat4(), degToRad(90), yAxis);
+    export const rotY90: ReadonlyMat4 = fromRotation(zero(), degToRad(90), yAxis);
     /** Rotation matrix for 180deg around y-axis */
-    export const rotY180: ReadonlyMat4 = fromRotation(Mat4(), degToRad(180), yAxis);
+    export const rotY180: ReadonlyMat4 = fromRotation(zero(), degToRad(180), yAxis);
     /** Rotation matrix for 270deg around y-axis */
-    export const rotY270: ReadonlyMat4 = fromRotation(Mat4(), degToRad(270), yAxis);
+    export const rotY270: ReadonlyMat4 = fromRotation(zero(), degToRad(270), yAxis);
     /** Rotation matrix for 90deg around z-axis */
-    export const rotZ90: ReadonlyMat4 = fromRotation(Mat4(), degToRad(90), zAxis);
+    export const rotZ90: ReadonlyMat4 = fromRotation(zero(), degToRad(90), zAxis);
     /** Rotation matrix for 180deg around z-axis */
-    export const rotZ180: ReadonlyMat4 = fromRotation(Mat4(), degToRad(180), zAxis);
+    export const rotZ180: ReadonlyMat4 = fromRotation(zero(), degToRad(180), zAxis);
     /** Rotation matrix for 90deg around first x-axis and then y-axis */
-    export const rotXY90: ReadonlyMat4 = mul(Mat4(), rotX90, rotY90);
+    export const rotXY90: ReadonlyMat4 = mul(zero(), rotX90, rotY90);
     /** Rotation matrix for 90deg around first z-axis and then y-axis */
-    export const rotZY90: ReadonlyMat4 = mul(Mat4(), rotZ90, rotY90);
+    export const rotZY90: ReadonlyMat4 = mul(zero(), rotZ90, rotY90);
     /** Rotation matrix for 90deg around first z-axis and then y-axis and then z-axis */
-    export const rotZYZ90: ReadonlyMat4 = mul(Mat4(), rotZY90, rotZ90);
+    export const rotZYZ90: ReadonlyMat4 = mul(zero(), rotZY90, rotZ90);
     /** Rotation matrix for 90deg around first z-axis and then 180deg around x-axis */
-    export const rotZ90X180: ReadonlyMat4 = mul(Mat4(), rotZ90, rotX180);
+    export const rotZ90X180: ReadonlyMat4 = mul(zero(), rotZ90, rotX180);
     /** Rotation matrix for 90deg around first y-axis and then 180deg around z-axis */
-    export const rotY90Z180: ReadonlyMat4 = mul(Mat4(), rotY90, rotZ180);
+    export const rotY90Z180: ReadonlyMat4 = mul(zero(), rotY90, rotZ180);
 
     /** Identity matrix */
     export const id: ReadonlyMat4 = identity();

+ 3 - 3
src/mol-math/linear-algebra/3d/quat.ts

@@ -407,8 +407,8 @@ namespace Quat {
     /**
      * Performs a spherical linear interpolation with two control points
      */
-    let sqlerpTemp1 = Quat();
-    let sqlerpTemp2 = Quat();
+    let sqlerpTemp1 = zero();
+    let sqlerpTemp2 = zero();
     export function sqlerp(out: Quat, a: Quat, b: Quat, c: Quat, d: Quat, t: number) {
         slerp(sqlerpTemp1, a, d, t);
         slerp(sqlerpTemp2, b, c, t);
@@ -435,7 +435,7 @@ namespace Quat {
         axesTmpMat[5] = -view[1];
         axesTmpMat[8] = -view[2];
 
-        return normalize(out, Quat.fromMat3(out, axesTmpMat));
+        return normalize(out, fromMat3(out, axesTmpMat));
     }
 
     export function toString(a: Quat, precision?: number) {

+ 17 - 15
src/mol-math/linear-algebra/3d/vec3.ts

@@ -18,9 +18,11 @@
  */
 
 import { Mat4 } from './mat4';
-import { Quat, Mat3, EPSILON } from '../3d';
 import { spline as _spline, quadraticBezier as _quadraticBezier, clamp } from '../../interpolate';
 import { NumberArray } from '../../../mol-util/type-helpers';
+import { Mat3 } from './mat3';
+import { Quat } from './quat';
+import { EPSILON } from './common';
 
 export { ReadonlyVec3 };
 
@@ -273,7 +275,7 @@ namespace Vec3 {
     }
 
     export function setMagnitude(out: Vec3, a: Vec3, l: number) {
-        return Vec3.scale(out, Vec3.normalize(out, a), l);
+        return scale(out, normalize(out, a), l);
     }
 
     /**
@@ -339,11 +341,11 @@ namespace Vec3 {
 
     const slerpRelVec = zero();
     export function slerp(out: Vec3, a: Vec3, b: Vec3, t: number) {
-        const dot = clamp(Vec3.dot(a, b), -1, 1);
-        const theta = Math.acos(dot) * t;
-        Vec3.scaleAndAdd(slerpRelVec, b, a, -dot);
-        Vec3.normalize(slerpRelVec, slerpRelVec);
-        return Vec3.add(out, Vec3.scale(out, a, Math.cos(theta)), Vec3.scale(slerpRelVec, slerpRelVec, Math.sin(theta)));
+        const d = clamp(dot(a, b), -1, 1);
+        const theta = Math.acos(d) * t;
+        scaleAndAdd(slerpRelVec, b, a, -d);
+        normalize(slerpRelVec, slerpRelVec);
+        return add(out, scale(out, a, Math.cos(theta)), scale(slerpRelVec, slerpRelVec, Math.sin(theta)));
     }
 
     /**
@@ -562,8 +564,8 @@ namespace Vec3 {
      * i.e. where the dot product is > 0
      */
     export function matchDirection(out: Vec3, a: Vec3, b: Vec3) {
-        if (Vec3.dot(a, b) > 0) Vec3.copy(out, a);
-        else Vec3.negate(out, Vec3.copy(out, a));
+        if (dot(a, b) > 0) copy(out, a);
+        else negate(out, copy(out, a));
         return out;
     }
 
@@ -580,14 +582,14 @@ namespace Vec3 {
         return `[${a[0].toPrecision(precision)} ${a[1].toPrecision(precision)} ${a[2].toPrecision(precision)}]`;
     }
 
-    export const origin: ReadonlyVec3 = Vec3.create(0, 0, 0);
+    export const origin: ReadonlyVec3 = create(0, 0, 0);
 
-    export const unit: ReadonlyVec3 = Vec3.create(1, 1, 1);
-    export const negUnit: ReadonlyVec3 = Vec3.create(-1, -1, -1);
+    export const unit: ReadonlyVec3 = create(1, 1, 1);
+    export const negUnit: ReadonlyVec3 = create(-1, -1, -1);
 
-    export const unitX: ReadonlyVec3 = Vec3.create(1, 0, 0);
-    export const unitY: ReadonlyVec3 = Vec3.create(0, 1, 0);
-    export const unitZ: ReadonlyVec3 = Vec3.create(0, 0, 1);
+    export const unitX: ReadonlyVec3 = create(1, 0, 0);
+    export const unitY: ReadonlyVec3 = create(0, 1, 0);
+    export const unitZ: ReadonlyVec3 = create(0, 0, 1);
 }
 
 export { Vec3 };

+ 1 - 1
src/mol-math/linear-algebra/3d/vec4.ts

@@ -18,9 +18,9 @@
  */
 
 import { Mat4 } from './mat4';
-import { EPSILON } from '../3d';
 import { NumberArray } from '../../../mol-util/type-helpers';
 import { Sphere3D } from '../../geometry/primitives/sphere3d';
+import { EPSILON } from './common';
 
 interface Vec4 extends Array<number> { [d: number]: number, '@type': 'vec4', length: 4 }
 

+ 2 - 1
src/mol-math/linear-algebra/_spec/mat3.spec.ts

@@ -4,7 +4,8 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Mat3, Vec3 } from '../3d';
+import { Mat3 } from '../3d/mat3';
+import { Vec3 } from '../3d/vec3';
 
 describe('Mat3', () => {
     it('symmetricEigenvalues', () => {

+ 6 - 5
src/mol-math/linear-algebra/_spec/mat4.spec.ts

@@ -4,21 +4,22 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Mat4, Vec3 } from '../3d';
+import { Mat4 } from '../3d/mat4';
+import { Vec3 } from '../3d/vec3';
 
 describe('Mat4', () => {
     it('permutation', () => {
-        expect(Mat4.areEqual(Mat4.fromPermutation(Mat4.zero(), [0, 1, 2, 3]), Mat4.identity(), 1e-6)).toBe(true);
+        expect(Mat4.areEqual(Mat4.fromPermutation(Mat4(), [0, 1, 2, 3]), Mat4.identity(), 1e-6)).toBe(true);
 
-        expect(Mat4.areEqual(Mat4.fromPermutation(Mat4.zero(), [1, 0, 2, 3]), Mat4.ofRows([
+        expect(Mat4.areEqual(Mat4.fromPermutation(Mat4(), [1, 0, 2, 3]), Mat4.ofRows([
             [0, 1, 0, 0],
             [1, 0, 0, 0],
             [0, 0, 1, 0],
             [0, 0, 0, 1],
         ]), 1e-6)).toBe(true);
 
-        const perm = Mat4.fromPermutation(Mat4.zero(), [1, 2, 0, 3]);
+        const perm = Mat4.fromPermutation(Mat4(), [1, 2, 0, 3]);
 
-        expect(Vec3.transformMat4(Vec3.zero(), Vec3.create(1, 2, 3), perm)).toEqual(Vec3.create(2, 3, 1));
+        expect(Vec3.transformMat4(Vec3(), Vec3.create(1, 2, 3), perm)).toEqual(Vec3.create(2, 3, 1));
     });
 });

+ 1 - 1
src/mol-math/linear-algebra/_spec/tensor.spec.ts

@@ -5,7 +5,7 @@
  */
 
 import { Tensor as T } from '../tensor';
-import { Mat4 } from '../3d';
+import { Mat4 } from '../3d/mat4';
 
 describe('tensor', () => {
     it('vector', () => {

+ 7 - 1
src/mol-math/linear-algebra/_spec/vec3.spec.ts

@@ -1,4 +1,10 @@
-import { Vec3 } from '../3d';
+/**
+ * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
+ */
+
+import { Vec3 } from '../3d/vec3';
 
 describe('vec3', () => {
     const vec1 = [ 1, 2, 3 ] as Vec3;

+ 1 - 1
src/mol-math/linear-algebra/matrix/principal-axes.ts

@@ -5,7 +5,7 @@
  */
 
 import { Matrix } from './matrix';
-import { Vec3 } from '../3d';
+import { Vec3 } from '../3d/vec3';
 import { svd } from './svd';
 import { NumberArray } from '../../../mol-util/type-helpers';
 import { Axes3D } from '../../geometry';

+ 4 - 1
src/mol-math/linear-algebra/tensor.ts

@@ -1,3 +1,4 @@
+import { Mat3 } from './3d/mat3';
 /**
  * Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
@@ -5,7 +6,9 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Mat4, Vec3, Vec4, Mat3 } from './3d';
+import { Mat4 } from './3d/mat4';
+import { Vec3 } from './3d/vec3';
+import { Vec4 } from './3d/vec4';
 
 export interface Tensor { data: Tensor.Data, space: Tensor.Space }
 

+ 2 - 2
src/mol-model-props/computed/accessible-surface-area/shrake-rupley/area.ts

@@ -31,8 +31,6 @@ export async function computeArea(runtime: RuntimeContext, ctx: ShrakeRupleyCont
 const aPos = Vec3();
 const bPos = Vec3();
 const testPoint = Vec3();
-const aLoc = StructureElement.Location.create(void 0 as any);
-const bLoc = StructureElement.Location.create(void 0 as any);
 
 function setLocation(l: StructureElement.Location, structure: Structure, serialIndex: number) {
     l.structure = structure;
@@ -43,6 +41,8 @@ function setLocation(l: StructureElement.Location, structure: Structure, serialI
 
 function computeRange(ctx: ShrakeRupleyContext, begin: number, end: number) {
     const { structure, atomRadiusType, serialResidueIndex, area, spherePoints, scalingConstant, maxLookupRadius, probeSize } = ctx;
+    const aLoc = StructureElement.Location.create(structure);
+    const bLoc = StructureElement.Location.create(structure);
     const { x, y, z } = StructureProperties.atom;
     const { lookup3d, serialMapping, unitIndexMap } = structure;
     const { cumulativeUnitElementCount } = serialMapping;

+ 1 - 2
src/mol-model-props/computed/accessible-surface-area/shrake-rupley/radii.ts

@@ -12,12 +12,11 @@ import { VdwRadius } from '../../../../mol-model/structure/model/properties/atom
 import { StructureElement, StructureProperties } from '../../../../mol-model/structure/structure';
 import { getElementMoleculeType } from '../../../../mol-model/structure/util';
 
-const l = StructureElement.Location.create(void 0);
-
 export function assignRadiusForHeavyAtoms(ctx: ShrakeRupleyContext) {
     const { key } = StructureProperties.residue;
     const { type_symbol, label_atom_id, label_comp_id } = StructureProperties.atom;
     const { structure, atomRadiusType, serialResidueIndex } = ctx;
+    const l = StructureElement.Location.create(structure);
 
     let prevResidueIdx = 0;
     let residueIdx = 0;

+ 7 - 9
src/mol-model-props/computed/representations/interactions-inter-unit-cylinder.ts

@@ -23,11 +23,10 @@ import { InteractionFlag } from '../interactions/common';
 import { Unit } from '../../../mol-model/structure/structure';
 import { Sphere3D } from '../../../mol-math/geometry';
 
-const tmpLoc = StructureElement.Location.create(void 0);
-
 function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InteractionsInterUnitParams>, mesh?: Mesh) {
     if (!structure.hasAtomic) return Mesh.createEmpty(mesh);
 
+    const l = StructureElement.Location.create(structure);
     const interactions = InteractionsProvider.get(structure).value!;
     const { contacts, unitsFeatures } = interactions;
 
@@ -55,14 +54,13 @@ function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: S
         radius: (edgeIndex: number) => {
             const b = edges[edgeIndex];
             const fA = unitsFeatures.get(b.unitA);
-            tmpLoc.structure = structure;
-            tmpLoc.unit = structure.unitMap.get(b.unitA);
-            tmpLoc.element = tmpLoc.unit.elements[fA.members[fA.offsets[b.indexA]]];
-            const sizeA = theme.size.size(tmpLoc);
+            l.unit = structure.unitMap.get(b.unitA);
+            l.element = l.unit.elements[fA.members[fA.offsets[b.indexA]]];
+            const sizeA = theme.size.size(l);
             const fB = unitsFeatures.get(b.unitB);
-            tmpLoc.unit = structure.unitMap.get(b.unitB);
-            tmpLoc.element = tmpLoc.unit.elements[fB.members[fB.offsets[b.indexB]]];
-            const sizeB = theme.size.size(tmpLoc);
+            l.unit = structure.unitMap.get(b.unitB);
+            l.element = l.unit.elements[fB.members[fB.offsets[b.indexB]]];
+            const sizeB = theme.size.size(l);
             return Math.min(sizeA, sizeB) * sizeFactor;
         },
         ignore: (edgeIndex: number) => edges[edgeIndex].props.flag === InteractionFlag.Filtered

+ 4 - 6
src/mol-model/structure/export/categories/atom_site.ts

@@ -12,23 +12,21 @@ import CifField = CifWriter.Field
 import CifCategory = CifWriter.Category
 import E = CifWriter.Encodings
 
-const _label_asym_id = P.chain.label_asym_id;
 function atom_site_label_asym_id(e: StructureElement.Location) {
-    const l = _label_asym_id(e);
+    const l = P.chain.label_asym_id(e);
     const suffix = e.unit.conformation.operator.suffix;
     if (!suffix) return l;
     return l + suffix;
 }
 
-const _auth_asym_id = P.chain.auth_asym_id;
 function atom_site_auth_asym_id(e: StructureElement.Location) {
-    const l = _auth_asym_id(e);
+    const l = P.chain.auth_asym_id(e);
     const suffix = e.unit.conformation.operator.suffix;
     if (!suffix) return l;
     return l + suffix;
 }
 
-const atom_site_fields = CifWriter.fields<StructureElement.Location, Structure>()
+const atom_site_fields = () => CifWriter.fields<StructureElement.Location, Structure>()
     .str('group_PDB', P.residue.group_PDB)
     .index('id')
     .str('type_symbol', P.atom.type_symbol as any)
@@ -73,7 +71,7 @@ export const _atom_site: CifCategory<CifExportContext> = {
     name: 'atom_site',
     instance({ structures }: CifExportContext) {
         return {
-            fields: atom_site_fields,
+            fields: atom_site_fields(),
             source: structures.map(s => ({
                 data: s,
                 rowCount: s.elementCount,

+ 4 - 4
src/mol-model/structure/export/categories/secondary-structure.ts

@@ -20,7 +20,7 @@ export const _struct_conf: CifCategory<CifExportContext> = {
     instance(ctx) {
         const elements = findElements(ctx, 'helix');
         return {
-            fields: struct_conf_fields,
+            fields: struct_conf_fields(),
             source: [{ data: elements, rowCount: elements.length }]
         };
     }
@@ -31,7 +31,7 @@ export const _struct_sheet_range: CifCategory<CifExportContext> = {
     instance(ctx) {
         const elements = (findElements(ctx, 'sheet') as SSElement<SecondaryStructure.Sheet>[]).sort(compare_ssr);
         return {
-            fields: struct_sheet_range_fields,
+            fields: struct_sheet_range_fields(),
             source: [{ data: elements, rowCount: elements.length }]
         };
     }
@@ -42,7 +42,7 @@ function compare_ssr(x: SSElement<SecondaryStructure.Sheet>, y: SSElement<Second
     return a.sheet_id < b.sheet_id ? -1 : a.sheet_id === b.sheet_id ? x.start.element - y.start.element : 1;
 };
 
-const struct_conf_fields: CifField[] = [
+const struct_conf_fields = (): CifField[] => [
     CifField.str<number, SSElement<SecondaryStructure.Helix>[]>('conf_type_id', (i, data) => data[i].element.type_id),
     CifField.str<number, SSElement<SecondaryStructure.Helix>[]>('id', (i, data, idx) => `${data[i].element.type_id}${idx + 1}`),
     ...residueIdFields<number, SSElement<SecondaryStructure.Helix>[]>((i, e) => e[i].start, { prefix: 'beg' }),
@@ -54,7 +54,7 @@ const struct_conf_fields: CifField[] = [
     CifField.int<number, SSElement<SecondaryStructure.Helix>[]>('pdbx_PDB_helix_length', (i, data) => data[i].length)
 ];
 
-const struct_sheet_range_fields: CifField[] = [
+const struct_sheet_range_fields = (): CifField[] => [
     CifField.str<number, SSElement<SecondaryStructure.Sheet>[]>('sheet_id', (i, data) => data[i].element.sheet_id),
     CifField.index('id'),
     ...residueIdFields<number, SSElement<SecondaryStructure.Sheet>[]>((i, e) => e[i].start, { prefix: 'beg' }),

+ 2 - 1
src/mol-plugin-state/animation/built-in/camera-spin.ts

@@ -6,7 +6,8 @@
 
 import { Camera } from '../../../mol-canvas3d/camera';
 import { clamp } from '../../../mol-math/interpolate';
-import { Quat, Vec3 } from '../../../mol-math/linear-algebra/3d';
+import { Quat } from '../../../mol-math/linear-algebra/3d/quat';
+import { Vec3 } from '../../../mol-math/linear-algebra/3d/vec3';
 import { ParamDefinition as PD } from '../../../mol-util/param-definition';
 import { PluginStateAnimation } from '../model';
 

+ 3 - 3
src/mol-plugin-state/helpers/structure-component.ts

@@ -34,7 +34,7 @@ export const StaticStructureComponentTypes = [
 
 export type StaticStructureComponentType = (typeof StaticStructureComponentTypes)[number]
 
-export const StructureComponentParams = {
+export const StructureComponentParams = () => ({
     type: PD.MappedStatic('static', {
         static: PD.Text<StaticStructureComponentType>('polymer'),
         expression: PD.Value<Expression>(MolScriptBuilder.struct.generator.all),
@@ -43,8 +43,8 @@ export const StructureComponentParams = {
     }, { isHidden: true }),
     nullIfEmpty: PD.Optional(PD.Boolean(true, { isHidden: true })),
     label: PD.Text('', { isHidden: true })
-};
-export type StructureComponentParams = PD.ValuesFor<typeof StructureComponentParams>
+});
+export type StructureComponentParams = PD.ValuesFor<ReturnType<typeof StructureComponentParams>>
 
 export function createStructureComponent(a: Structure, params: StructureComponentParams, cache: { source: Structure, entry?: StructureQueryHelper.CacheEntry }) {
     cache.source = a;

+ 8 - 8
src/mol-plugin-state/transforms/model.ts

@@ -486,10 +486,10 @@ const StructureSelectionFromExpression = PluginStateTransform.BuiltIn({
     display: { name: 'Selection', description: 'Create a molecular structure from the specified expression.' },
     from: SO.Molecule.Structure,
     to: SO.Molecule.Structure,
-    params: {
+    params: () => ({
         expression: PD.Value<Expression>(MolScriptBuilder.struct.generator.all, { isHidden: true }),
         label: PD.Optional(PD.Text('', { isHidden: true }))
-    }
+    })
 })({
     apply({ a, params, cache }) {
         const { selection, entry } = StructureQueryHelper.createAndRun(a.data, params.expression);
@@ -526,7 +526,7 @@ const MultiStructureSelectionFromExpression = PluginStateTransform.BuiltIn({
     display: { name: 'Multi-structure Measurement Selection', description: 'Create selection object from multiple structures.' },
     from: SO.Root,
     to: SO.Molecule.Structure.Selections,
-    params: {
+    params: () => ({
         selections: PD.ObjectList({
             key: PD.Text(void 0, { description: 'A unique key.' }),
             ref: PD.Text(),
@@ -535,7 +535,7 @@ const MultiStructureSelectionFromExpression = PluginStateTransform.BuiltIn({
         }, e => e.ref, { isHidden: true }),
         isTransitive: PD.Optional(PD.Boolean(false, { isHidden: true, description: 'Remap the selections from the original structure if structurally equivalent.' })),
         label: PD.Optional(PD.Text('', { isHidden: true }))
-    }
+    })
 })({
     apply({ params, cache, dependencies }) {
         const entries = new Map<string, StructureQueryHelper.CacheEntry>();
@@ -651,10 +651,10 @@ const StructureSelectionFromScript = PluginStateTransform.BuiltIn({
     display: { name: 'Selection', description: 'Create a molecular structure from the specified script.' },
     from: SO.Molecule.Structure,
     to: SO.Molecule.Structure,
-    params: {
+    params: () => ({
         script: PD.Script({ language: 'mol-script', expression: '(sel.atom.atom-groups :residue-test (= atom.resname ALA))' }),
         label: PD.Optional(PD.Text(''))
-    }
+    })
 })({
     apply({ a, params, cache }) {
         const { selection, entry } = StructureQueryHelper.createAndRun(a.data, params.script);
@@ -690,10 +690,10 @@ const StructureSelectionFromBundle = PluginStateTransform.BuiltIn({
     display: { name: 'Selection', description: 'Create a molecular structure from the specified structure-element bundle.' },
     from: SO.Molecule.Structure,
     to: SO.Molecule.Structure,
-    params: {
+    params: () => ({
         bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty, { isHidden: true }),
         label: PD.Optional(PD.Text('', { isHidden: true }))
-    }
+    })
 })({
     apply({ a, params, cache }) {
         if (params.bundle.hash !== a.data.hashCode) {

+ 24 - 24
src/mol-plugin-state/transforms/representation.ts

@@ -258,7 +258,7 @@ const OverpaintStructureRepresentation3DFromScript = PluginStateTransform.BuiltI
     display: 'Overpaint 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
             color: PD.Color(ColorNames.blueviolet),
@@ -270,7 +270,7 @@ const OverpaintStructureRepresentation3DFromScript = PluginStateTransform.BuiltI
                 clear: false
             }]
         }),
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -309,7 +309,7 @@ const OverpaintStructureRepresentation3DFromBundle = PluginStateTransform.BuiltI
     display: 'Overpaint 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
             color: PD.Color(ColorNames.blueviolet),
@@ -322,7 +322,7 @@ const OverpaintStructureRepresentation3DFromBundle = PluginStateTransform.BuiltI
             }],
             isHidden: true
         }),
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -361,7 +361,7 @@ const TransparencyStructureRepresentation3DFromScript = PluginStateTransform.Bui
     display: 'Transparency 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
             value: PD.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
@@ -371,7 +371,7 @@ const TransparencyStructureRepresentation3DFromScript = PluginStateTransform.Bui
                 value: 0.5,
             }]
         })
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -409,7 +409,7 @@ const TransparencyStructureRepresentation3DFromBundle = PluginStateTransform.Bui
     display: 'Transparency 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
             value: PD.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
@@ -420,7 +420,7 @@ const TransparencyStructureRepresentation3DFromBundle = PluginStateTransform.Bui
             }],
             isHidden: true
         })
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -458,7 +458,7 @@ const ClippingStructureRepresentation3DFromScript = PluginStateTransform.BuiltIn
     display: 'Clipping 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
             groups: PD.Converted((g: Clipping.Groups) => Clipping.Groups.toNames(g), n => Clipping.Groups.fromNames(n), PD.MultiSelect(ObjectKeys(Clipping.Groups.Names), PD.objectToOptions(Clipping.Groups.Names))),
@@ -468,7 +468,7 @@ const ClippingStructureRepresentation3DFromScript = PluginStateTransform.BuiltIn
                 groups: Clipping.Groups.Flag.None,
             }]
         }),
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -506,7 +506,7 @@ const ClippingStructureRepresentation3DFromBundle = PluginStateTransform.BuiltIn
     display: 'Clipping 3D Representation',
     from: SO.Molecule.Structure.Representation3D,
     to: SO.Molecule.Structure.Representation3DState,
-    params: {
+    params: () => ({
         layers: PD.ObjectList({
             bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
             groups: PD.Converted((g: Clipping.Groups) => Clipping.Groups.toNames(g), n => Clipping.Groups.fromNames(n), PD.MultiSelect(ObjectKeys(Clipping.Groups.Names), PD.objectToOptions(Clipping.Groups.Names))),
@@ -517,7 +517,7 @@ const ClippingStructureRepresentation3DFromBundle = PluginStateTransform.BuiltIn
             }],
             isHidden: true
         }),
-    }
+    })
 })({
     canAutoUpdate() {
         return true;
@@ -705,9 +705,9 @@ const ModelUnitcell3D = PluginStateTransform.BuiltIn({
     display: 'Model Unit Cell',
     from: SO.Molecule.Model,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...UnitcellParams,
-    }
+    })
 })({
     isApplicable: a => !!ModelSymmetry.Provider.get(a.data),
     canAutoUpdate({ oldParams, newParams }) {
@@ -743,9 +743,9 @@ const StructureSelectionsDistance3D = PluginStateTransform.BuiltIn({
     display: '3D Distance',
     from: SO.Molecule.Structure.Selections,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...DistanceParams,
-    }
+    })
 })({
     canAutoUpdate({ oldParams, newParams }) {
         return true;
@@ -776,9 +776,9 @@ const StructureSelectionsAngle3D = PluginStateTransform.BuiltIn({
     display: '3D Angle',
     from: SO.Molecule.Structure.Selections,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...AngleParams,
-    }
+    })
 })({
     canAutoUpdate({ oldParams, newParams }) {
         return true;
@@ -809,9 +809,9 @@ const StructureSelectionsDihedral3D = PluginStateTransform.BuiltIn({
     display: '3D Dihedral',
     from: SO.Molecule.Structure.Selections,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...DihedralParams,
-    }
+    })
 })({
     canAutoUpdate({ oldParams, newParams }) {
         return true;
@@ -842,9 +842,9 @@ const StructureSelectionsLabel3D = PluginStateTransform.BuiltIn({
     display: '3D Label',
     from: SO.Molecule.Structure.Selections,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...LabelParams,
-    }
+    })
 })({
     canAutoUpdate({ oldParams, newParams }) {
         return true;
@@ -875,9 +875,9 @@ const StructureSelectionsOrientation3D = PluginStateTransform.BuiltIn({
     display: '3D Orientation',
     from: SO.Molecule.Structure.Selections,
     to: SO.Shape.Representation3D,
-    params: {
+    params: () => ({
         ...OrientationParams,
-    }
+    })
 })({
     canAutoUpdate({ oldParams, newParams }) {
         return true;

+ 1 - 1
src/mol-plugin/behavior/dynamic/custom-props/structure-info.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { PluginBehavior } from '../../../behavior';
+import { PluginBehavior } from '../../../behavior/behavior';
 import { Structure, Model } from '../../../../mol-model/structure';
 import { PluginStateObject } from '../../../../mol-plugin-state/objects';
 import { StateSelection, StateObject } from '../../../../mol-state';

+ 4 - 4
src/mol-plugin/index.ts

@@ -22,7 +22,7 @@ import { AnimateAssemblyUnwind } from '../mol-plugin-state/animation/built-in/as
 import { AnimateCameraSpin } from '../mol-plugin-state/animation/built-in/camera-spin';
 import { AnimateStateSnapshots } from '../mol-plugin-state/animation/built-in/state-snapshots';
 
-export const DefaultPluginSpec: PluginSpec = {
+export const DefaultPluginSpec = (): PluginSpec => ({
     actions: [
         PluginSpec.Action(StateActions.Structure.DownloadStructure),
         PluginSpec.Action(StateActions.Structure.AddTrajectory),
@@ -93,10 +93,10 @@ export const DefaultPluginSpec: PluginSpec = {
         AnimateStateSnapshots,
         AnimateAssemblyUnwind
     ]
-};
+});
 
 export function createPlugin(target: HTMLElement, spec?: PluginSpec): PluginContext {
-    const ctx = new PluginContext(spec || DefaultPluginSpec);
+    const ctx = new PluginContext(spec || DefaultPluginSpec());
     ctx.init();
     ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
     return ctx;
@@ -104,7 +104,7 @@ export function createPlugin(target: HTMLElement, spec?: PluginSpec): PluginCont
 
 /** Returns the instance of the plugin after all behaviors have been initialized */
 export async function createPluginAsync(target: HTMLElement, spec?: PluginSpec) {
-    const ctx = new PluginContext(spec || DefaultPluginSpec);
+    const ctx = new PluginContext(spec || DefaultPluginSpec());
     const init = ctx.init();
     ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
     await init;

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

@@ -29,9 +29,6 @@ function setRefPosition(pos: Vec3, structure: Structure, unit: Unit.Atomic, inde
     return null;
 }
 
-const tmpRef = Vec3();
-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;
@@ -39,6 +36,9 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them
 
     if (!edgeCount) return Lines.createEmpty(lines);
 
+    const ref = Vec3();
+    const loc = StructureElement.Location.create();
+
     const builderProps = {
         linkCount: edgeCount,
         referencePosition: (edgeIndex: number) => {
@@ -58,7 +58,7 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them
             } else {
                 throw new Error('same units in createInterUnitBondLines');
             }
-            return setRefPosition(tmpRef, structure, unitA, indexA) || setRefPosition(tmpRef, structure, unitB, indexB);
+            return setRefPosition(ref, structure, unitA, indexA) || setRefPosition(ref, structure, unitB, indexB);
         },
         position: (posA: Vec3, posB: Vec3, edgeIndex: number) => {
             const b = edges[edgeIndex];
@@ -83,13 +83,13 @@ function createInterUnitBondLines(ctx: VisualContext, structure: Structure, them
         },
         radius: (edgeIndex: number) => {
             const b = edges[edgeIndex];
-            tmpLoc.structure = structure;
-            tmpLoc.unit = structure.unitMap.get(b.unitA);
-            tmpLoc.element = tmpLoc.unit.elements[b.indexA];
-            const sizeA = theme.size.size(tmpLoc);
-            tmpLoc.unit = structure.unitMap.get(b.unitB);
-            tmpLoc.element = tmpLoc.unit.elements[b.indexB];
-            const sizeB = theme.size.size(tmpLoc);
+            loc.structure = structure;
+            loc.unit = structure.unitMap.get(b.unitA);
+            loc.element = loc.unit.elements[b.indexA];
+            const sizeA = theme.size.size(loc);
+            loc.unit = structure.unitMap.get(b.unitB);
+            loc.element = loc.unit.elements[b.indexB];
+            const sizeB = theme.size.size(loc);
             return Math.min(sizeA, sizeB) * sizeFactor;
         },
         ignore: makeInterBondIgnoreTest(structure, props)