Browse Source

typescript 3.6 compat fixes

Alexander Rose 5 years ago
parent
commit
25137f29d2

+ 1 - 1
src/apps/viewer/extensions/cellpack/model.ts

@@ -297,7 +297,7 @@ export const LoadCellPackModel = StateAction.build({
                 ['spacefill', 'Spacefill'],
                 ['gaussian-surface', 'Gaussian Surface'],
                 ['point', 'Point'],
-            ])
+            ] as ['spacefill' | 'gaussian-surface' | 'point', string][])
         }, { isExpanded: true })
     },
     from: PSO.Root

+ 1 - 1
src/mol-canvas3d/camera.ts

@@ -62,7 +62,7 @@ class Camera implements Object3D {
             default: throw new Error('unknown camera mode');
         }
 
-        const changed = !Mat4.areEqual(this.projection, this.prevProjection, EPSILON.Value) || !Mat4.areEqual(this.view, this.prevView, EPSILON.Value);
+        const changed = !Mat4.areEqual(this.projection, this.prevProjection, EPSILON) || !Mat4.areEqual(this.view, this.prevView, EPSILON);
 
         Mat4.mul(this.projectionView, this.projection, this.view)
         Mat4.invert(this.inverseProjectionView, this.projectionView)

+ 2 - 2
src/mol-canvas3d/camera/util.ts

@@ -65,9 +65,9 @@ export function cameraLookAt(position: Vec3, up: Vec3, direction: Vec3, target:
     if (!Vec3.isZero(tmpVec3)) {
         // change direction vector to look at target
         const d = Vec3.dot(tmpVec3, up)
-        if (Math.abs(d - 1) < EPSILON.Value) { // parallel
+        if (Math.abs(d - 1) < EPSILON) { // parallel
             Vec3.scale(up, direction, -1)
-        } else if (Math.abs(d + 1) < EPSILON.Value) { // anti parallel
+        } else if (Math.abs(d + 1) < EPSILON) { // anti parallel
             Vec3.copy(up, direction)
         }
         Vec3.copy(direction, tmpVec3)

+ 1 - 1
src/mol-canvas3d/controls/trackball.ts

@@ -220,7 +220,7 @@ namespace TrackballControls {
             checkDistances()
             cameraLookAt(object.position, object.up, object.direction, target)
 
-            if (Vec3.squaredDistance(lastPosition, object.position) > EPSILON.Value) {
+            if (Vec3.squaredDistance(lastPosition, object.position) > EPSILON) {
                 Vec3.copy(lastPosition, object.position)
             }
 

+ 1 - 1
src/mol-math/geometry/primitives/sphere3d.ts

@@ -124,7 +124,7 @@ namespace Sphere3D {
     export function equals(a: Sphere3D, b: Sphere3D) {
         const ar = a.radius;
         const br = b.radius;
-        return (Math.abs(ar - br) <= EPSILON.Value * Math.max(1.0, Math.abs(ar), Math.abs(br)) &&
+        return (Math.abs(ar - br) <= EPSILON * Math.max(1.0, Math.abs(ar), Math.abs(br)) &&
                 Vec3.equals(a.center, b.center));
     }
 }

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

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -17,7 +17,7 @@
  * furnished to do so, subject to the following conditions:
  */
 
-export const enum EPSILON { Value = 0.000001 }
+export const EPSILON = 0.000001;
 
 export function equalEps(a: number, b: number, eps: number) {
     return Math.abs(a - b) <= eps;

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

@@ -101,7 +101,7 @@ namespace Mat4 {
 
     const _id = identity();
     export function isIdentity(m: Mat4, eps?: number) {
-        return areEqual(m, _id, typeof eps === 'undefined' ? EPSILON.Value : eps);
+        return areEqual(m, _id, typeof eps === 'undefined' ? EPSILON : eps);
     }
 
     export function hasNaN(m: Mat4) {
@@ -499,7 +499,7 @@ namespace Mat4 {
             b10, b11, b12,
             b20, b21, b22;
 
-        if (Math.abs(len) < EPSILON.Value) {
+        if (Math.abs(len) < EPSILON) {
             return Mat4.identity();
         }
 
@@ -549,7 +549,7 @@ namespace Mat4 {
             len = Math.sqrt(x * x + y * y + z * z),
             s, c, t;
 
-        if (Math.abs(len) < EPSILON.Value) { return setIdentity(out); }
+        if (Math.abs(len) < EPSILON) { return setIdentity(out); }
 
         len = 1 / len;
         x *= len;
@@ -719,7 +719,7 @@ namespace Mat4 {
      * [ 0           1           ]
      */
     export function isRotationAndTranslation(a: Mat4, eps?: number) {
-        return _isRotationAndTranslation(a, typeof eps !== 'undefined' ? eps : EPSILON.Value)
+        return _isRotationAndTranslation(a, typeof eps !== 'undefined' ? eps : EPSILON)
     }
 
     function _isRotationAndTranslation(a: Mat4, eps: number) {
@@ -854,9 +854,9 @@ namespace Mat4 {
         const centery = center[1];
         const centerz = center[2];
 
-        if (Math.abs(eyex - centerx) < EPSILON.Value &&
-            Math.abs(eyey - centery) < EPSILON.Value &&
-            Math.abs(eyez - centerz) < EPSILON.Value
+        if (Math.abs(eyex - centerx) < EPSILON &&
+            Math.abs(eyey - centery) < EPSILON &&
+            Math.abs(eyez - centerz) < EPSILON
         ) {
             return setIdentity(out);
         }

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

@@ -281,7 +281,7 @@ namespace Quat {
     export function fromUnitVec3 (out: Quat, a: Vec3, b: Vec3) {
         // assumes a and b are normalized
         let r = Vec3.dot(a, b) + 1
-        if (r < EPSILON.Value) {
+        if (r < EPSILON) {
             // If u and v are exactly opposite, rotate 180 degrees
             // around an arbitrary orthogonal axis. Axis normalisation
             // can happen later, when we normalise the quaternion.

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

@@ -490,9 +490,9 @@ namespace Vec3 {
     export function equals(a: Vec3, b: Vec3) {
         const a0 = a[0], a1 = a[1], a2 = a[2];
         const b0 = b[0], b1 = b[1], b2 = b[2];
-        return (Math.abs(a0 - b0) <= EPSILON.Value * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
-                Math.abs(a1 - b1) <= EPSILON.Value * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
-                Math.abs(a2 - b2) <= EPSILON.Value * Math.max(1.0, Math.abs(a2), Math.abs(b2)));
+        return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
+                Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
+                Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)));
     }
 
     const rotTemp = zero();
@@ -500,7 +500,7 @@ namespace Vec3 {
     export function makeRotation(mat: Mat4, a: Vec3, b: Vec3): Mat4 {
         const by = angle(a, b);
         if (Math.abs(by) < 0.0001) return Mat4.setIdentity(mat);
-        if (Math.abs(by - Math.PI) < EPSILON.Value) {
+        if (Math.abs(by - Math.PI) < EPSILON) {
             // here, axis can be [0,0,0] but the rotation is a simple flip
             return Mat4.fromScaling(mat, flipScaling);
         }

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

@@ -220,10 +220,10 @@ namespace Vec4 {
     export function equals(a: Vec4, b: Vec4) {
         const a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
         const b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
-        return (Math.abs(a0 - b0) <= EPSILON.Value * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
-                Math.abs(a1 - b1) <= EPSILON.Value * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
-                Math.abs(a2 - b2) <= EPSILON.Value * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
-                Math.abs(a3 - b3) <= EPSILON.Value * Math.max(1.0, Math.abs(a3), Math.abs(b3)));
+        return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
+                Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
+                Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
+                Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)));
     }
 
     export function toString(a: Vec4, precision?: number) {

+ 1 - 1
src/mol-plugin/layout.ts

@@ -162,7 +162,7 @@ export class PluginLayout extends PluginComponent<PluginLayoutStateProps> {
                     s.marginBottom = t.marginBottom;
 
                     s.position = t.position;
-                    s.overflow = t.overflow;
+                    s.overflow = t.overflow || 'fixed';
                     let doc = this.getScrollElement();
                     doc.scrollTop = t.scrollTop;
                     doc.scrollLeft = t.scrollLeft;

+ 1 - 1
src/mol-plugin/state/actions/structure.ts

@@ -107,7 +107,7 @@ const DownloadStructure = StateAction.build({
             }, { isFlat: true, description: 'Loads the best homology model or experimental structure' }),
             'url': PD.Group({
                 url: PD.Text(''),
-                format: PD.Select('cif', [['cif', 'CIF'], ['pdb', 'PDB']]),
+                format: PD.Select('cif', [['cif', 'CIF'], ['pdb', 'PDB']] as ['cif' | 'pdb', string][]),
                 isBinary: PD.Boolean(false),
                 options: PD.Group({
                     supportProps: PD.Optional(PD.Boolean(false))

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

@@ -437,7 +437,7 @@ const TransparencyStructureRepresentation3DFromScript = PluginStateTransform.Bui
     params: {
         script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
         value: PD.Numeric(0.75, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
-        variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']])
+        variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']] as ['single' | 'multi', string][])
     }
 })({
     canAutoUpdate() {
@@ -477,7 +477,7 @@ const TransparencyStructureRepresentation3DFromBundle = PluginStateTransform.Bui
     params: {
         bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
         value: PD.Numeric(0.75, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
-        variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']])
+        variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']] as ['single' | 'multi', string][])
     }
 })({
     canAutoUpdate() {