Skip to content
Snippets Groups Projects
Commit a81f0d91 authored by Alexander Rose's avatar Alexander Rose
Browse files

linting style

parent 28e22279
Branches
Tags
No related merge requests found
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
"error", "error",
"1tbs", { "allowSingleLine": true } "1tbs", { "allowSingleLine": true }
], ],
"comma-spacing": "off",
"@typescript-eslint/comma-spacing": "error",
"space-infix-ops": "error",
"comma-dangle": "off", "comma-dangle": "off",
"eqeqeq": [ "eqeqeq": [
"error", "error",
......
...@@ -52,7 +52,7 @@ export function CellPackColorTheme(ctx: ThemeDataContext, props: PD.Values<CellP ...@@ -52,7 +52,7 @@ export function CellPackColorTheme(ctx: ThemeDataContext, props: PD.Values<CellP
}}) }})
legend = palette.legend legend = palette.legend
const modelColor = new Map<number, Color>() const modelColor = new Map<number, Color>()
for (let i = 0, il = models.length; i <il; ++i) { for (let i = 0, il = models.length; i < il; ++i) {
const idx = models[i].trajectoryInfo.index; const idx = models[i].trajectoryInfo.index;
modelColor.set(models[i].trajectoryInfo.index, palette.color(idx)) modelColor.set(models[i].trajectoryInfo.index, palette.color(idx))
} }
......
...@@ -119,7 +119,7 @@ function GetSmoothNormals(points: Vec3[]) { ...@@ -119,7 +119,7 @@ function GetSmoothNormals(points: Vec3[]) {
p0 = points[i - 1] p0 = points[i - 1]
p1 = points[i] p1 = points[i]
p2 = points[i + 1] p2 = points[i + 1]
const t = Vec3.normalize(tmpV1, Vec3.sub(tmpV1, p2 , p0)) const t = Vec3.normalize(tmpV1, Vec3.sub(tmpV1, p2, p0))
const b = Vec3.normalize(tmpV2, Vec3.cross(tmpV2, t, prevV)) const b = Vec3.normalize(tmpV2, Vec3.cross(tmpV2, t, prevV))
const n = Vec3.normalize(Vec3(), Vec3.cross(tmpV3, t, b)) const n = Vec3.normalize(Vec3(), Vec3.cross(tmpV3, t, b))
Vec3.negate(n, n) Vec3.negate(n, n)
...@@ -128,8 +128,8 @@ function GetSmoothNormals(points: Vec3[]) { ...@@ -128,8 +128,8 @@ function GetSmoothNormals(points: Vec3[]) {
} }
const last = Vec3() const last = Vec3()
Vec3.normalize(last, Vec3.cross(last, Vec3.normalize(last, Vec3.cross(last,
Vec3.sub(tmpV1, points[nP - 3], points[nP-2]), Vec3.sub(tmpV1, points[nP - 3], points[nP - 2]),
Vec3.sub(tmpV2, points[nP-2] , points[nP-1])) Vec3.sub(tmpV2, points[nP - 2], points[nP - 1]))
) )
smoothNormals.push(last) smoothNormals.push(last)
return smoothNormals; return smoothNormals;
...@@ -168,8 +168,8 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) { ...@@ -168,8 +168,8 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) {
const t0 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[1], points[0])) const t0 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[1], points[0]))
frames.push(getFrame(normals[0], t0)) frames.push(getFrame(normals[0], t0))
for (let i = 0; i< points.length-2; ++i) { for (let i = 0; i < points.length - 2; ++i) {
const t2 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[i+2], points[i+1])) const t2 = Vec3.normalize(mfTmpV1, Vec3.sub(mfTmpV1, points[i + 2], points[i + 1]))
const v1 = Vec3.sub(mfTmpV2, points[i + 1], points[i]) // this is tangeant const v1 = Vec3.sub(mfTmpV2, points[i + 1], points[i]) // this is tangeant
const c1 = Vec3.dot(v1, v1) const c1 = Vec3.dot(v1, v1)
// compute r_i^L = R_1 * r_i // compute r_i^L = R_1 * r_i
...@@ -179,10 +179,10 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) { ...@@ -179,10 +179,10 @@ function GetMiniFrame(points: Vec3[], normals: Vec3[]) {
const v1t = Vec3.scale(mfTmpV5, v1, (2.0 / c1) * Vec3.dot(v1, frames[i].t)) const v1t = Vec3.scale(mfTmpV5, v1, (2.0 / c1) * Vec3.dot(v1, frames[i].t))
const tan_L_i = Vec3.sub(mfTmpV6, frames[i].t, v1t) const tan_L_i = Vec3.sub(mfTmpV6, frames[i].t, v1t)
// # compute reflection vector of R_2 // # compute reflection vector of R_2
const v2 = Vec3.sub(mfTmpV7, t2 , tan_L_i) const v2 = Vec3.sub(mfTmpV7, t2, tan_L_i)
const c2 = Vec3.dot(v2, v2) const c2 = Vec3.dot(v2, v2)
// compute r_(i+1) = R_2 * r_i^L // compute r_(i+1) = R_2 * r_i^L
const v2l = Vec3.scale(mfTmpV8, v1, (2.0/c2) * Vec3.dot(v2, ref_L_i)) const v2l = Vec3.scale(mfTmpV8, v1, (2.0 / c2) * Vec3.dot(v2, ref_L_i))
const ref_next = Vec3.sub(mfTmpV9, ref_L_i, v2l) // ref_L_i - (2 / c2) * v2.dot(ref_L_i) * v2 const ref_next = Vec3.sub(mfTmpV9, ref_L_i, v2l) // ref_L_i - (2 / c2) * v2.dot(ref_L_i) * v2
frames.push(getFrame(ref_next, t2)) // frames.append(Frame(ref_next, tangents[i+1])) frames.push(getFrame(ref_next, t2)) // frames.append(Frame(ref_next, tangents[i+1]))
} }
...@@ -199,13 +199,13 @@ export function getMatFromResamplePoints(points: NumberArray, segmentLength: num ...@@ -199,13 +199,13 @@ export function getMatFromResamplePoints(points: NumberArray, segmentLength: num
const limit = npoints const limit = npoints
const transforms: Mat4[] = [] const transforms: Mat4[] = []
const pti = Vec3.copy(rpTmpVec1, new_points[0]); const pti = Vec3.copy(rpTmpVec1, new_points[0]);
for (let i = 0; i<npoints-2; ++i) { for (let i = 0; i < npoints - 2; ++i) {
const pti1: Vec3 = new_points[i+1] // Vec3.create(points[(i+1)*3],points[(i+1)*3+1],points[(i+1)*3+2]); const pti1: Vec3 = new_points[i + 1] // Vec3.create(points[(i+1)*3],points[(i+1)*3+1],points[(i+1)*3+2]);
const d = Vec3.distance(pti, pti1) const d = Vec3.distance(pti, pti1)
if (d >= segmentLength) { if (d >= segmentLength) {
// use twist or random? // use twist or random?
const quat = Quat.rotationTo(Quat.zero(), Vec3.create(0, 0, 1), frames[i].t) // Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),new_normal[i]);//Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),direction);new_normal const quat = Quat.rotationTo(Quat.zero(), Vec3.create(0, 0, 1), frames[i].t) // Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),new_normal[i]);//Quat.rotationTo(Quat.zero(), Vec3.create(0,0,1),direction);new_normal
const rq = Quat.setAxisAngle(Quat.zero(), frames[i].t, Math.random()*3.60 ) // Quat.setAxisAngle(Quat.zero(),direction, Math.random()*3.60 );//Quat.identity();// const rq = Quat.setAxisAngle(Quat.zero(), frames[i].t, Math.random() * 3.60 ) // Quat.setAxisAngle(Quat.zero(),direction, Math.random()*3.60 );//Quat.identity();//
const m = Mat4.fromQuat(Mat4.zero(), Quat.multiply(Quat.zero(), rq, quat)) // Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),quat1,quat2));//Mat4.fromQuat(Mat4.zero(),quat);//Mat4.identity();//Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),rq,quat)); const m = Mat4.fromQuat(Mat4.zero(), Quat.multiply(Quat.zero(), rq, quat)) // Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),quat1,quat2));//Mat4.fromQuat(Mat4.zero(),quat);//Mat4.identity();//Mat4.fromQuat(Mat4.zero(),Quat.multiply(Quat.zero(),rq,quat));
// let pos:Vec3 = Vec3.add(Vec3.zero(),pti1,pti) // let pos:Vec3 = Vec3.add(Vec3.zero(),pti1,pti)
// pos = Vec3.scale(pos,pos,1.0/2.0); // pos = Vec3.scale(pos,pos,1.0/2.0);
......
...@@ -49,7 +49,6 @@ async function getModel(id: string, model_id: number, baseUrl: string, file?: Fi ...@@ -49,7 +49,6 @@ async function getModel(id: string, model_id: number, baseUrl: string, file?: Fi
throw new Error(`unsupported file type '${file.name}'`) throw new Error(`unsupported file type '${file.name}'`)
} }
} else if (id.match(/^[1-9][a-zA-Z0-9]{3,3}$/i)) { } else if (id.match(/^[1-9][a-zA-Z0-9]{3,3}$/i)) {
// return
const cif = await getFromPdb(id) const cif = await getFromPdb(id)
model = (await trajectoryFromMmCIF(cif).run())[model_id] model = (await trajectoryFromMmCIF(cif).run())[model_id]
} else { } else {
...@@ -68,7 +67,7 @@ async function getStructure(model: Model, source: IngredientSource, props: { ass ...@@ -68,7 +67,7 @@ async function getStructure(model: Model, source: IngredientSource, props: { ass
} }
let query; let query;
if (source.selection){ if (source.selection){
const asymIds: string[] = source.selection.replace(' :','').split(' or') const asymIds: string[] = source.selection.replace(' :', '').split(' or')
query = MS.struct.modifier.union([ query = MS.struct.modifier.union([
MS.struct.generator.atomGroups({ MS.struct.generator.atomGroups({
'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']), 'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']),
...@@ -102,7 +101,7 @@ function getTransformLegacy(trans: Vec3, rot: Quat) { ...@@ -102,7 +101,7 @@ function getTransformLegacy(trans: Vec3, rot: Quat) {
function getTransform(trans: Vec3, rot: Quat) { function getTransform(trans: Vec3, rot: Quat) {
const q: Quat = Quat.create(rot[0], rot[1], rot[2], rot[3]) const q: Quat = Quat.create(rot[0], rot[1], rot[2], rot[3])
const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q) const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q)
const p: Vec3 = Vec3.create(trans[0],trans[1],trans[2]) const p: Vec3 = Vec3.create(trans[0], trans[1], trans[2])
Mat4.setTranslation(m, p) Mat4.setTranslation(m, p)
return m return m
} }
...@@ -116,7 +115,11 @@ function getResultTransforms(results: Ingredient['results'], legacy: boolean) { ...@@ -116,7 +115,11 @@ function getResultTransforms(results: Ingredient['results'], legacy: boolean) {
function getCurveTransforms(ingredient: Ingredient) { function getCurveTransforms(ingredient: Ingredient) {
const n = ingredient.nbCurve || 0 const n = ingredient.nbCurve || 0
const instances: Mat4[] = [] const instances: Mat4[] = []
const segmentLength = (ingredient.radii)? ((ingredient.radii[0].radii)?ingredient.radii[0].radii[0]*2.0:3.4):3.4; const segmentLength = ingredient.radii
? (ingredient.radii[0].radii
? ingredient.radii[0].radii[0] * 2.0
: 3.4)
: 3.4;
for (let i = 0; i < n; ++i) { for (let i = 0; i < n; ++i) {
const cname = `curve${i}` const cname = `curve${i}`
if (!(cname in ingredient)) { if (!(cname in ingredient)) {
...@@ -130,7 +133,7 @@ function getCurveTransforms(ingredient: Ingredient) { ...@@ -130,7 +133,7 @@ function getCurveTransforms(ingredient: Ingredient) {
} }
const points = new Float32Array(_points.length * 3) const points = new Float32Array(_points.length * 3)
for (let i = 0, il = _points.length; i < il; ++i) Vec3.toArray(_points[i], points, i * 3) for (let i = 0, il = _points.length; i < il; ++i) Vec3.toArray(_points[i], points, i * 3)
const newInstances = getMatFromResamplePoints(points,segmentLength) const newInstances = getMatFromResamplePoints(points, segmentLength)
instances.push(...newInstances) instances.push(...newInstances)
} }
...@@ -273,8 +276,8 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i ...@@ -273,8 +276,8 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i
} }
// model id in case structure is NMR // model id in case structure is NMR
const model_id = (ingredient.source.model)? parseInt(ingredient.source.model) : 0; const model_id = (ingredient.source.model) ? parseInt(ingredient.source.model) : 0;
const model = await getModel(source.pdb || name,model_id, baseUrl, file) const model = await getModel(source.pdb || name, model_id, baseUrl, file)
if (!model) return if (!model) return
if (nbCurve) { if (nbCurve) {
...@@ -288,35 +291,35 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i ...@@ -288,35 +291,35 @@ async function getIngredientStructure(ingredient: Ingredient, baseUrl: string, i
bu = bu.slice(2) bu = bu.slice(2)
} }
} }
let structure = await getStructure(model,source, { assembly: bu }) let structure = await getStructure(model, source, { assembly: bu })
// transform with offset and pcp // transform with offset and pcp
let legacy: boolean = true let legacy: boolean = true
if (ingredient.offset || ingredient.principalAxis){ if (ingredient.offset || ingredient.principalAxis){
// center the structure // center the structure
legacy=false legacy = false
const boundary = structure.boundary const boundary = structure.boundary
let structureCenter: Vec3 = Vec3.zero() let structureCenter: Vec3 = Vec3.zero()
Vec3.negate(structureCenter,boundary.sphere.center) Vec3.negate(structureCenter, boundary.sphere.center)
const m1: Mat4 = Mat4.identity() const m1: Mat4 = Mat4.identity()
Mat4.setTranslation(m1, structureCenter) Mat4.setTranslation(m1, structureCenter)
structure = Structure.transform(structure,m1) structure = Structure.transform(structure, m1)
if (ingredient.offset){ if (ingredient.offset){
if (!Vec3.exactEquals(ingredient.offset,Vec3.zero())){ if (!Vec3.exactEquals(ingredient.offset, Vec3.zero())){
const m: Mat4 = Mat4.identity(); const m: Mat4 = Mat4.identity();
Mat4.setTranslation(m, ingredient.offset) Mat4.setTranslation(m, ingredient.offset)
structure = Structure.transform(structure,m); structure = Structure.transform(structure, m);
} }
} }
if (ingredient.principalAxis){ if (ingredient.principalAxis){
if (!Vec3.exactEquals(ingredient.principalAxis,Vec3.unitZ)){ if (!Vec3.exactEquals(ingredient.principalAxis, Vec3.unitZ)){
const q: Quat = Quat.identity(); const q: Quat = Quat.identity();
Quat.rotationTo(q,ingredient.principalAxis,Vec3.unitZ) Quat.rotationTo(q, ingredient.principalAxis, Vec3.unitZ)
const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q) const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q)
structure = Structure.transform(structure,m); structure = Structure.transform(structure, m);
} }
} }
} }
return getAssembly(getResultTransforms(results,legacy), structure) return getAssembly(getResultTransforms(results, legacy), structure)
} }
} }
...@@ -388,7 +391,7 @@ async function loadMembrane(name: string, plugin: PluginContext, runtime: Runtim ...@@ -388,7 +391,7 @@ async function loadMembrane(name: string, plugin: PluginContext, runtime: Runtim
} }
const url = `${params.baseUrl}/membranes/${name}.bcif` const url = `${params.baseUrl}/membranes/${name}.bcif`
// //
const file = (ingredientFiles)?ingredientFiles[fname]:null; const file = (ingredientFiles) ? ingredientFiles[fname] : null;
// can we check if url exist // can we check if url exist
let membrane let membrane
if (!file) { if (!file) {
......
...@@ -237,7 +237,7 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty: ...@@ -237,7 +237,7 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty:
<div className='msp-semi-transparent-background' /> <div className='msp-semi-transparent-background' />
<IconButton icon={isAnimating || isPlaying ? 'stop' : 'tape'} transparent title={isAnimating ? 'Stop' : 'Select Animation'} <IconButton icon={isAnimating || isPlaying ? 'stop' : 'tape'} transparent title={isAnimating ? 'Stop' : 'Select Animation'}
onClick={isAnimating || isPlaying ? this.stop : this.toggleExpanded} onClick={isAnimating || isPlaying ? this.stop : this.toggleExpanded}
disabled={isAnimating|| isPlaying ? false : this.state.isBusy || this.state.isPlaying || this.state.isEmpty} /> disabled={isAnimating || isPlaying ? false : this.state.isBusy || this.state.isPlaying || this.state.isEmpty} />
</div> </div>
{(this.state.isExpanded && !this.state.isBusy) && <div className='msp-animation-viewport-controls-select'> {(this.state.isExpanded && !this.state.isBusy) && <div className='msp-animation-viewport-controls-select'>
<AnimationControls onStart={this.toggleExpanded} /> <AnimationControls onStart={this.toggleExpanded} />
......
...@@ -17,8 +17,8 @@ namespace UUID { ...@@ -17,8 +17,8 @@ namespace UUID {
export function create22(): UUID { export function create22(): UUID {
let d = (+new Date()) + now(); let d = (+new Date()) + now();
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
chars[i] = String.fromCharCode((d + Math.random()*0xff)%0xff | 0); chars[i] = String.fromCharCode((d + Math.random() * 0xff) % 0xff | 0);
d = Math.floor(d/0xff); d = Math.floor(d / 0xff);
} }
return _btoa(chars.join('')).replace(/\+/g, '-').replace(/\//g, '_').substr(0, 22) as UUID; return _btoa(chars.join('')).replace(/\+/g, '-').replace(/\//g, '_').substr(0, 22) as UUID;
} }
...@@ -26,9 +26,9 @@ namespace UUID { ...@@ -26,9 +26,9 @@ namespace UUID {
export function createv4(): UUID { export function createv4(): UUID {
let d = (+new Date()) + now(); let d = (+new Date()) + now();
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = (d + Math.random()*16)%16 | 0; const r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d/16); d = Math.floor(d / 16);
return (c==='x' ? r : (r&0x3|0x8)).toString(16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
}); });
return uuid as any; return uuid as any;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment