diff --git a/src/apps/viewer/extensions/cellpack/model.ts b/src/apps/viewer/extensions/cellpack/model.ts index 8712d6b8b321c4e55cfae3a6440c066ca626bcc9..320a20256c129cae70e001cc9f06aba0f74ea59d 100644 --- a/src/apps/viewer/extensions/cellpack/model.ts +++ b/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 diff --git a/src/mol-canvas3d/camera.ts b/src/mol-canvas3d/camera.ts index 43b390255697572aa8cc33efb32a9ddb2c39a195..d241d4cbe250fe8facd1ea7512efb9d6507b3d7e 100644 --- a/src/mol-canvas3d/camera.ts +++ b/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) diff --git a/src/mol-canvas3d/camera/util.ts b/src/mol-canvas3d/camera/util.ts index 8109567a0b2f01261d59250e9670c170ed402623..fcf9ba8934a92ccdcd4aff220eb956ab03e333c2 100644 --- a/src/mol-canvas3d/camera/util.ts +++ b/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) diff --git a/src/mol-canvas3d/controls/trackball.ts b/src/mol-canvas3d/controls/trackball.ts index 8589c81e8c0d6ff46df17680c8f63518fcb23f66..192f044f4358c11a900990a7c49221af2332af75 100644 --- a/src/mol-canvas3d/controls/trackball.ts +++ b/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) } diff --git a/src/mol-math/geometry/primitives/sphere3d.ts b/src/mol-math/geometry/primitives/sphere3d.ts index b11fca791b67c590f69d1b1f62fc81b6201bdc40..a1c0fc51f401761060a847eef80c97de8064c500 100644 --- a/src/mol-math/geometry/primitives/sphere3d.ts +++ b/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)); } } diff --git a/src/mol-math/linear-algebra/3d/common.ts b/src/mol-math/linear-algebra/3d/common.ts index 4276dd8d60b1e254621bfb87e8dbd5302b023d0e..56b3efa886280d5215e876f7db96402516f54d0e 100644 --- a/src/mol-math/linear-algebra/3d/common.ts +++ b/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; diff --git a/src/mol-math/linear-algebra/3d/mat4.ts b/src/mol-math/linear-algebra/3d/mat4.ts index abed77702a69a2821e7cf140c2569b5d84cdbdf9..e98d98361ea7fed7dfef11351646c0d2c81005a5 100644 --- a/src/mol-math/linear-algebra/3d/mat4.ts +++ b/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); } diff --git a/src/mol-math/linear-algebra/3d/quat.ts b/src/mol-math/linear-algebra/3d/quat.ts index 569dc63735aae842b58d80837d1e3721c8fc9e81..50e12f11a2f3ce05f4e47ccf475f5368ed9c2108 100644 --- a/src/mol-math/linear-algebra/3d/quat.ts +++ b/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. diff --git a/src/mol-math/linear-algebra/3d/vec3.ts b/src/mol-math/linear-algebra/3d/vec3.ts index b50d947b165eb1a9cb7b887b520a9cac304f7b19..08afca3531a52d1ca5bbd263fddec98d1188d7a2 100644 --- a/src/mol-math/linear-algebra/3d/vec3.ts +++ b/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); } diff --git a/src/mol-math/linear-algebra/3d/vec4.ts b/src/mol-math/linear-algebra/3d/vec4.ts index 753356f0c80ef3650fc3f108404a782a87b447f4..ab4eb2dbaf08ec2e9f07377308ec04ec431b647a 100644 --- a/src/mol-math/linear-algebra/3d/vec4.ts +++ b/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) { diff --git a/src/mol-plugin/layout.ts b/src/mol-plugin/layout.ts index 94cbdd8f30b057e9ef26139eeea914b27bae89a0..ace2b255977d3419441cab00f463a7b710861e39 100644 --- a/src/mol-plugin/layout.ts +++ b/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; diff --git a/src/mol-plugin/state/actions/structure.ts b/src/mol-plugin/state/actions/structure.ts index 7e2535c392c7b52d24e94a6ee37eaeca7b6954ad..c0f9c5a55a369cbc6e3d45391fdb2b6a8ef746e7 100644 --- a/src/mol-plugin/state/actions/structure.ts +++ b/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)) diff --git a/src/mol-plugin/state/transforms/representation.ts b/src/mol-plugin/state/transforms/representation.ts index 84be0e176ab66d8d095cb1ea2977d91832bf2918..417d200b97ff1c4c929d4f765f2e2fd85285a9ff 100644 --- a/src/mol-plugin/state/transforms/representation.ts +++ b/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() {