icn3d 3.54.0 → 3.54.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/icn3d.js CHANGED
@@ -56739,7 +56739,7 @@ class SubdivideCls {
56739
56739
 
56740
56740
  // cubic splines for four points: http://thalestriangles.blogspot.com/2014/02/a-bit-of-ex-spline-ation.html
56741
56741
  // https://math.stackexchange.com/questions/577641/how-to-calculate-interpolating-splines-in-3d-space
56742
- subdivide(_pnts, _clrs, DIV) { let me = this.icn3dui;
56742
+ subdivide(_pnts, _clrs, DIV, bOld) { let me = this.icn3dui;
56743
56743
 
56744
56744
  let ret = [];
56745
56745
  let pos = [];
@@ -56822,6 +56822,16 @@ class SubdivideCls {
56822
56822
  savedColor = [];
56823
56823
  pnts = [];
56824
56824
 
56825
+ // adjust the color
56826
+ if(!bOld) {
56827
+ let half = Math.floor(DIV / 2);
56828
+ for(let i = 0, il = color.length; i < il; ++i) {
56829
+ let j = i + half;
56830
+ if(j > il - 1) j = il - 1;
56831
+ color[i] = color[j];
56832
+ }
56833
+ }
56834
+
56825
56835
  pnts_positions.push(ret);
56826
56836
  pnts_positions.push(pos);
56827
56837
  pnts_positions.push(color);
@@ -78233,6 +78243,7 @@ class CurveStripArrow {
78233
78243
  // use the sheet coord for n-2 residues
78234
78244
  let colorsTmp = [];
78235
78245
  let extraArrow = (bStrip) ? 2 : 0; // extend the tube by 5 sub-points into a preceding/following helix/sheet
78246
+ // let extraArrow = (bStrip) ? 0 : 0; // extend the tube by 5 sub-points into a preceding/following helix/sheet
78236
78247
 
78237
78248
  let i, lastIndex = (bShowArrow === undefined || bShowArrow) ? pntsCA.length - ic.axisDIV + extraArrow : pntsCA.length;
78238
78249
 
@@ -78248,20 +78259,22 @@ class CurveStripArrow {
78248
78259
  posIndex.push(positions[i]);
78249
78260
  }
78250
78261
 
78251
- if(bStrip) {
78252
- if(bHelix) {
78253
- ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
78254
- undefined, posIndex, pntsCATmp, prevCOArrayTmp);
78262
+ // if(!(bShowArrow === undefined || bShowArrow)) {
78263
+ if(bStrip) {
78264
+ if(bHelix) {
78265
+ ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
78266
+ undefined, posIndex, pntsCATmp, prevCOArrayTmp);
78267
+ }
78268
+ else {
78269
+ ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
78270
+ undefined, posIndex);
78271
+ }
78255
78272
  }
78256
78273
  else {
78257
- ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
78258
- undefined, posIndex);
78274
+ ic.curveCls.createCurveSub(pnts[0], width, colorsTmp, div, bHighlight, bRibbon, true,
78275
+ undefined, posIndex);
78259
78276
  }
78260
- }
78261
- else {
78262
- ic.curveCls.createCurveSub(pnts[0], width, colorsTmp, div, bHighlight, bRibbon, true,
78263
- undefined, posIndex);
78264
- }
78277
+ // }
78265
78278
 
78266
78279
  if(bShowArrow === undefined || bShowArrow) {
78267
78280
  // draw the arrow
@@ -78278,6 +78291,8 @@ class CurveStripArrow {
78278
78291
  let scale = 1.8; // scale of the arrow width
78279
78292
  delta = delta * scale * (ic.axisDIV - cnt) / ic.axisDIV;
78280
78293
 
78294
+ if(!pntsCA[i] || !prevCOArray[i]) continue;
78295
+
78281
78296
  let v = new Vector3$1(pntsCA[i].x + prevCOArray[i].x * delta,
78282
78297
  pntsCA[i].y + prevCOArray[i].y * delta,
78283
78298
  pntsCA[i].z + prevCOArray[i].z * delta);
@@ -78299,7 +78314,7 @@ class CurveStripArrow {
78299
78314
  pntsCA[lastCAIndex].z + prevCOArray[lastCAIndex].z * delta);
78300
78315
 
78301
78316
  pnts[index].push(v);
78302
- colorsTmp.push(colors[i]);
78317
+ colorsTmp.push(colors[lastCAIndex]);
78303
78318
  if(index === 0) posIndex.push(positions[lastCAIndex]);
78304
78319
  }
78305
78320
 
@@ -79932,13 +79947,13 @@ class Tube {
79932
79947
  let maxDist2 = 3.0; // avoid tube between the residues in 3 residue helix
79933
79948
 
79934
79949
  let pnts_colors_radii = [];
79935
- let firstAtom, firstPos, prevAtom, prevPos;
79950
+ let firstAtom, firstPos, atom, prevAtom, prevPos;
79936
79951
  let half = Math.floor(ic.axisDIV / 2) - 1;
79937
79952
 
79938
79953
  for (let i = 0, il = atoms.length; i < il; ++i) {
79939
79954
  let pos = (tubePosArray) ? tubePosArray[i] : undefined;
79940
79955
 
79941
- let atom = atoms[i];
79956
+ atom = atoms[i];
79942
79957
  if ((atom.name === atomName) && !atom.het) {
79943
79958
  if(index == 0) {
79944
79959
  firstAtom = atom;
@@ -79965,7 +79980,61 @@ class Tube {
79965
79980
 
79966
79981
  pnts_colors_radii.push(result);
79967
79982
  }
79968
- else {
79983
+ else {
79984
+ /*
79985
+ if(!isNaN(firstAtom.resi) && !isNaN(prevAtom.resi)) {
79986
+ let prevoneResid = firstAtom.structure + '_' + firstAtom.chain + '_' + (parseInt(firstAtom.resi) - 1).toString();
79987
+ let prevoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(prevoneResid, atomName);
79988
+ prevone = (prevoneCoord !== undefined) ? [prevoneCoord] : [];
79989
+
79990
+ let nextoneResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 1).toString();
79991
+ let nexttwoResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 2).toString();
79992
+ let nextthreeResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 3).toString();
79993
+
79994
+ if(ic.residues.hasOwnProperty(nextoneResid)) {
79995
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
79996
+ if(nextAtom !== undefined && nextAtom.ssbegin) { // include the residue
79997
+ nextoneResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 2).toString();
79998
+ nexttwoResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 3).toString();
79999
+
80000
+ pnts.push(nextAtom.coord);
80001
+ if(bCustom) {
80002
+ radii.push(this.getCustomtubesize(nextoneResid));
80003
+ }
80004
+ else {
80005
+ radii.push(this.getRadius(radius, nextAtom));
80006
+ }
80007
+ colors.push(nextAtom.color);
80008
+ }
80009
+ }
80010
+
80011
+ // add one more residue if only one residue is available and it's not part of helix/sheet
80012
+ if(pnts.length == 1 && ic.residues.hasOwnProperty(nextoneResid) && atom.ss == 'coil') {
80013
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
80014
+
80015
+ if(nextAtom) {
80016
+ pnts.push(nextAtom.coord);
80017
+ colors.push(nextAtom.color);
80018
+
80019
+ let radiusFinal = this.getRadius(radius, atom);
80020
+ radii.push(radiusFinal);
80021
+
80022
+ nextoneResid = nexttwoResid;
80023
+ nexttwoResid = nextthreeResid;
80024
+ }
80025
+ }
80026
+
80027
+ let nextoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nextoneResid, atomName);
80028
+ if(nextoneCoord !== undefined) {
80029
+ nexttwo.push(nextoneCoord);
80030
+ }
80031
+
80032
+ let nexttwoCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nexttwoResid, atomName);
80033
+ if(nexttwoCoord !== undefined) {
80034
+ nexttwo.push(nexttwoCoord);
80035
+ }
80036
+ }
80037
+ */
79969
80038
  pnts_colors_radii.push({'pnts':pnts, 'colors':colors, 'radii':radii});
79970
80039
  }
79971
80040
  }
@@ -79989,6 +80058,24 @@ class Tube {
79989
80058
  }
79990
80059
  }
79991
80060
  else { // b factor, etc
80061
+ /*
80062
+ if(pnts.length == 0 && !isNaN(atom.resi)) {
80063
+ let prevoneResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) - 1).toString();
80064
+ if(ic.residues.hasOwnProperty(prevoneResid)) {
80065
+ prevAtom = ic.firstAtomObjCls.getAtomFromResi(prevoneResid, atomName);
80066
+ if(prevAtom !== undefined && prevAtom.ssend) { // include the residue
80067
+ pnts.push(prevAtom.coord);
80068
+ if(bCustom) {
80069
+ radii.push(this.getCustomtubesize(prevoneResid));
80070
+ }
80071
+ else {
80072
+ radii.push(this.getRadius(radius, prevAtom));
80073
+ }
80074
+ colors.push(prevAtom.color);
80075
+ }
80076
+ }
80077
+ }
80078
+ */
79992
80079
  pnts.push(atom.coord);
79993
80080
 
79994
80081
  let radiusFinal;
@@ -80037,6 +80124,47 @@ class Tube {
80037
80124
  }
80038
80125
  }
80039
80126
  else {
80127
+ /*
80128
+ prevone = [];
80129
+ if(firstAtom !== undefined && !isNaN(firstAtom.resi)) {
80130
+ let prevoneResid = firstAtom.structure + '_' + firstAtom.chain + '_' + (parseInt(firstAtom.resi) - 1).toString();
80131
+ let prevoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(prevoneResid, atomName);
80132
+ prevone = (prevoneCoord !== undefined) ? [prevoneCoord] : [];
80133
+ }
80134
+
80135
+ nexttwo = [];
80136
+ if(atom !== undefined && !isNaN(atom.resi)) {
80137
+ let nextoneResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 1).toString();
80138
+ let nexttwoResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 2).toString();
80139
+ let nextthreeResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 3).toString();
80140
+
80141
+ // add one more residue if only one residue is available
80142
+ if(pnts.length == 1 && ic.residues.hasOwnProperty(nextoneResid)) {
80143
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
80144
+
80145
+ if(nextAtom) {
80146
+ pnts.push(nextAtom.coord);
80147
+ colors.push(nextAtom.color);
80148
+
80149
+ let radiusFinal = this.getRadius(radius, atom);
80150
+ radii.push(radiusFinal);
80151
+
80152
+ nextoneResid = nexttwoResid;
80153
+ nexttwoResid = nextthreeResid;
80154
+ }
80155
+ }
80156
+
80157
+ let nextoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nextoneResid, atomName);
80158
+ if(nextoneCoord !== undefined) {
80159
+ nexttwo.push(nextoneCoord);
80160
+ }
80161
+
80162
+ let nexttwoCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nexttwoResid, atomName);
80163
+ if(nexttwoCoord !== undefined) {
80164
+ nexttwo.push(nexttwoCoord);
80165
+ }
80166
+ }
80167
+ */
80040
80168
  pnts_colors_radii.push({'pnts':pnts, 'colors':colors, 'radii':radii});
80041
80169
  }
80042
80170
  }
@@ -80046,7 +80174,12 @@ class Tube {
80046
80174
  let colors = pnts_colors_radii[i].colors;
80047
80175
  let radii = pnts_colors_radii[i].radii;
80048
80176
 
80049
- this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil);
80177
+ if(tubePosArray) {
80178
+ this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil);
80179
+ }
80180
+ else {
80181
+ this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil, true);
80182
+ }
80050
80183
  }
80051
80184
 
80052
80185
  pnts_colors_radii = [];
@@ -80105,7 +80238,7 @@ class Tube {
80105
80238
  };
80106
80239
 
80107
80240
  // modified from iview (http://istar.cse.cuhk.edu.hk/iview/)
80108
- createTubeSub(_pnts, colors, radii, bHighlight, bNonCoil) { let ic = this.icn3d, me = ic.icn3dui;
80241
+ createTubeSub(_pnts, colors, radii, bHighlight, bNonCoil, bSubdivide) { let ic = this.icn3d, me = ic.icn3dui;
80109
80242
  if(me.bNode) return;
80110
80243
 
80111
80244
  if (_pnts.length < 2) return;
@@ -80118,9 +80251,10 @@ class Tube {
80118
80251
  let offset = 0, offset2 = 0, offset3 = 0;
80119
80252
 
80120
80253
  let pnts;
80121
- /*
80122
- if(!bSubdivided) {
80123
- let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv);
80254
+
80255
+ if(bSubdivide) {
80256
+ let bOld = true;
80257
+ let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv, bOld);
80124
80258
 
80125
80259
  pnts = pnts_clrs[0];
80126
80260
  colors = pnts_clrs[2];
@@ -80128,8 +80262,6 @@ class Tube {
80128
80262
  else {
80129
80263
  pnts = _pnts;
80130
80264
  }
80131
- */
80132
- pnts = _pnts;
80133
80265
 
80134
80266
  let constRadiius;
80135
80267
  // a threshold to stop drawing the tube if it's less than this ratio of radius
@@ -80369,7 +80501,7 @@ class Strand {
80369
80501
  let pntsCAAllSub = [], prevCOArrayAllSub = [], positionsSub = [], colorsAllSub = [];
80370
80502
 
80371
80503
  let currentChain, currentStyle, currentCA = null, currentColor = null, prevCoorCA = null, prevCoorO = null, prevColor = null;
80372
- let prevCO = null, ss = null, ssend = false, ssJoint = false, prevResi = null, prevResid = null;
80504
+ let prevCO = null, ss = null, ssend = false, prevResi = null, prevResid = null;
80373
80505
  let strandWidth, bSheetSegment = false, bHelixSegment = false;
80374
80506
  let atom, tubeAtoms = [];
80375
80507
 
@@ -80471,10 +80603,15 @@ class Strand {
80471
80603
  let delta = -1 + numM1Inv2 * j;
80472
80604
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
80473
80605
  // no smoothen for the last two residues in sheet
80474
- if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(atom.ssend)) v.smoothen = true;
80606
+ // if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(atom.ssend)) v.smoothen = true;
80607
+ if (!doNotSmoothen && ss === 'sheet') v.smoothen = true;
80475
80608
  pntsAll[j].push(v);
80476
80609
  }
80477
80610
 
80611
+ if (!doNotSmoothen && ss === 'sheet') {
80612
+ prevCoorCA.smoothen = true;
80613
+ prevCO.smoothen = true;
80614
+ }
80478
80615
  pntsCAAll.push(prevCoorCA);
80479
80616
  prevCOArrayAll.push(prevCO);
80480
80617
  }
@@ -80488,7 +80625,7 @@ class Strand {
80488
80625
 
80489
80626
  ss = atom.ss;
80490
80627
  ssend = atom.ssend;
80491
- ssJoint = atom.ssbegin || atom.ssend;
80628
+ atom.ssbegin || atom.ssend;
80492
80629
  } // end if (atom.name === 'O' || (ic.bCalphaOnly && atom.name === 'CA') ) {
80493
80630
  } // end if ((atom.name === 'O' || atom.name === 'CA') && !atom.het) {
80494
80631
  } // end for
@@ -80502,9 +80639,14 @@ class Strand {
80502
80639
  let delta = -1 + numM1Inv2 * j;
80503
80640
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
80504
80641
  // no smoothen for the last two residues in sheet
80505
- if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(ssend)) v.smoothen = true;
80642
+ //if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(ssend)) v.smoothen = true;
80643
+ if (!doNotSmoothen && ss === 'sheet') v.smoothen = true;
80506
80644
  pntsAll[j].push(v);
80507
80645
  }
80646
+ if (!doNotSmoothen && ss === 'sheet') {
80647
+ prevCoorCA.smoothen = true;
80648
+ prevCO.smoothen = true;
80649
+ }
80508
80650
  pntsCAAll.push(prevCoorCA);
80509
80651
  prevCOArrayAll.push(prevCO);
80510
80652
 
@@ -80528,7 +80670,6 @@ class Strand {
80528
80670
  prevCoorCA = null;
80529
80671
  ss = null;
80530
80672
  ssend = false;
80531
- ssJoint = false;
80532
80673
 
80533
80674
  index = 0;
80534
80675
  let bLastResDrawn = false;
@@ -80612,7 +80753,10 @@ class Strand {
80612
80753
 
80613
80754
  bSheetSegment = prevCoorO ? (ss === 'sheet') : (atom.ss === 'sheet');
80614
80755
  bHelixSegment = prevCoorO ? (ss === 'helix') : (atom.ss === 'helix');
80615
- this.createStrand_base(posArray, pntsAllSub, pntsCAAllSub, prevCOArrayAllSub, colorsAllSub, positionsSub, missingResArray, fill, bHighlight, bRibbon, num, bSheetSegment, bHelixSegment, bFullAtom, thickness);
80756
+ // skip the 2-residue joint between two adjacent SS (sheet end -> helix begin)
80757
+ if(!(ssend && atom.ssbegin)) {
80758
+ this.createStrand_base(posArray, pntsAllSub, pntsCAAllSub, prevCOArrayAllSub, colorsAllSub, positionsSub, missingResArray, fill, bHighlight, bRibbon, num, bSheetSegment, bHelixSegment, bFullAtom, thickness);
80759
+ }
80616
80760
  posArray = [];
80617
80761
  missingResArray = [];
80618
80762
  } // end if (atom.ssbegin || atom.ssend)
@@ -104681,9 +104825,37 @@ class WebGLPathTracer {
104681
104825
  ic.impostorCls.clearImpostors();
104682
104826
 
104683
104827
  if(ic.bRender && (!ic.hAtoms || Object.keys(ic.hAtoms) == 0)) ic.hAtoms = me.hashUtilsCls.cloneHash(ic.atoms);
104684
-
104828
+ /*
104829
+ // save the current view when the URL used |||pos:...
104830
+ let cam = (ic.bControlGl && !me.bNode) ? window.cam : ic.cam;
104831
+ let controls = (ic.bControlGl && !me.bNode) ? window.controls : ic.controls;
104832
+ let bKeepCamera = (!ic.bSetCamera || ic.bKeepCamera) && cam && controls && !me.bNode;
104833
+
104834
+ let camState;
104835
+ if(bKeepCamera) {
104836
+ camState = {
104837
+ pos: cam.position.clone(), up: cam.up.clone(), quat: cam.quaternion.clone(),
104838
+ target: controls.target.clone(), fov: cam.fov, zoom: cam.zoom,
104839
+ left: cam.left, right: cam.right, top: cam.top, bottom: cam.bottom
104840
+ };
104841
+ }
104842
+ */
104685
104843
  ic.sceneCls.rebuildScene();
104686
-
104844
+ /*
104845
+ // restore the saved cam state
104846
+ if(bKeepCamera) {
104847
+ // setCamera() created new controls, so re-read them
104848
+ //controls = (ic.bControlGl && !me.bNode) ? window.controls : ic.controls;
104849
+ cam.position.copy(camState.pos);
104850
+ cam.up.copy(camState.up);
104851
+ cam.quaternion.copy(camState.quat);
104852
+ controls.target.copy(camState.target);
104853
+ cam.zoom = camState.zoom;
104854
+ if(cam.isPerspectiveCamera) cam.fov = camState.fov;
104855
+ cam.updateProjectionMatrix();
104856
+ cam.updateMatrixWorld(true);
104857
+ }
104858
+ */
104687
104859
  // Impostor display using the saved arrays
104688
104860
  if(ic.bImpo) {
104689
104861
  ic.impostorCls.drawImpostorShader(); // target
@@ -104717,7 +104889,13 @@ class WebGLPathTracer {
104717
104889
  if($("#" + ic.pre + "cmdlog")) $("#" + ic.pre + "cmdlog").show();
104718
104890
  }
104719
104891
 
104720
- this.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
104892
+ if(ic.bSetCamera) {
104893
+ this.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
104894
+ }
104895
+ else {
104896
+ let commandTransformation = ic.commands[ic.commands.length-1].split('|||');
104897
+ ic.transformCls.resetOrientation_base(commandTransformation);
104898
+ }
104721
104899
 
104722
104900
  this.render(bVrAr, bPathTracer);
104723
104901
  }