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.module.js CHANGED
@@ -57640,7 +57640,7 @@ class SubdivideCls {
57640
57640
 
57641
57641
  // cubic splines for four points: http://thalestriangles.blogspot.com/2014/02/a-bit-of-ex-spline-ation.html
57642
57642
  // https://math.stackexchange.com/questions/577641/how-to-calculate-interpolating-splines-in-3d-space
57643
- subdivide(_pnts, _clrs, DIV) { let me = this.icn3dui;
57643
+ subdivide(_pnts, _clrs, DIV, bOld) { let me = this.icn3dui;
57644
57644
 
57645
57645
  let ret = [];
57646
57646
  let pos = [];
@@ -57723,6 +57723,16 @@ class SubdivideCls {
57723
57723
  savedColor = [];
57724
57724
  pnts = [];
57725
57725
 
57726
+ // adjust the color
57727
+ if(!bOld) {
57728
+ let half = Math.floor(DIV / 2);
57729
+ for(let i = 0, il = color.length; i < il; ++i) {
57730
+ let j = i + half;
57731
+ if(j > il - 1) j = il - 1;
57732
+ color[i] = color[j];
57733
+ }
57734
+ }
57735
+
57726
57736
  pnts_positions.push(ret);
57727
57737
  pnts_positions.push(pos);
57728
57738
  pnts_positions.push(color);
@@ -79134,6 +79144,7 @@ class CurveStripArrow {
79134
79144
  // use the sheet coord for n-2 residues
79135
79145
  let colorsTmp = [];
79136
79146
  let extraArrow = (bStrip) ? 2 : 0; // extend the tube by 5 sub-points into a preceding/following helix/sheet
79147
+ // let extraArrow = (bStrip) ? 0 : 0; // extend the tube by 5 sub-points into a preceding/following helix/sheet
79137
79148
 
79138
79149
  let i, lastIndex = (bShowArrow === undefined || bShowArrow) ? pntsCA.length - ic.axisDIV + extraArrow : pntsCA.length;
79139
79150
 
@@ -79149,20 +79160,22 @@ class CurveStripArrow {
79149
79160
  posIndex.push(positions[i]);
79150
79161
  }
79151
79162
 
79152
- if(bStrip) {
79153
- if(bHelix) {
79154
- ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
79155
- undefined, posIndex, pntsCATmp, prevCOArrayTmp);
79163
+ // if(!(bShowArrow === undefined || bShowArrow)) {
79164
+ if(bStrip) {
79165
+ if(bHelix) {
79166
+ ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
79167
+ undefined, posIndex, pntsCATmp, prevCOArrayTmp);
79168
+ }
79169
+ else {
79170
+ ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
79171
+ undefined, posIndex);
79172
+ }
79156
79173
  }
79157
79174
  else {
79158
- ic.stripCls.createStrip(pnts[0], pnts[1], colorsTmp, div, thickness, bHighlight, true,
79159
- undefined, posIndex);
79175
+ ic.curveCls.createCurveSub(pnts[0], width, colorsTmp, div, bHighlight, bRibbon, true,
79176
+ undefined, posIndex);
79160
79177
  }
79161
- }
79162
- else {
79163
- ic.curveCls.createCurveSub(pnts[0], width, colorsTmp, div, bHighlight, bRibbon, true,
79164
- undefined, posIndex);
79165
- }
79178
+ // }
79166
79179
 
79167
79180
  if(bShowArrow === undefined || bShowArrow) {
79168
79181
  // draw the arrow
@@ -79179,6 +79192,8 @@ class CurveStripArrow {
79179
79192
  let scale = 1.8; // scale of the arrow width
79180
79193
  delta = delta * scale * (ic.axisDIV - cnt) / ic.axisDIV;
79181
79194
 
79195
+ if(!pntsCA[i] || !prevCOArray[i]) continue;
79196
+
79182
79197
  let v = new Vector3$1(pntsCA[i].x + prevCOArray[i].x * delta,
79183
79198
  pntsCA[i].y + prevCOArray[i].y * delta,
79184
79199
  pntsCA[i].z + prevCOArray[i].z * delta);
@@ -79200,7 +79215,7 @@ class CurveStripArrow {
79200
79215
  pntsCA[lastCAIndex].z + prevCOArray[lastCAIndex].z * delta);
79201
79216
 
79202
79217
  pnts[index].push(v);
79203
- colorsTmp.push(colors[i]);
79218
+ colorsTmp.push(colors[lastCAIndex]);
79204
79219
  if(index === 0) posIndex.push(positions[lastCAIndex]);
79205
79220
  }
79206
79221
 
@@ -80833,13 +80848,13 @@ class Tube {
80833
80848
  let maxDist2 = 3.0; // avoid tube between the residues in 3 residue helix
80834
80849
 
80835
80850
  let pnts_colors_radii = [];
80836
- let firstAtom, firstPos, prevAtom, prevPos;
80851
+ let firstAtom, firstPos, atom, prevAtom, prevPos;
80837
80852
  let half = Math.floor(ic.axisDIV / 2) - 1;
80838
80853
 
80839
80854
  for (let i = 0, il = atoms.length; i < il; ++i) {
80840
80855
  let pos = (tubePosArray) ? tubePosArray[i] : undefined;
80841
80856
 
80842
- let atom = atoms[i];
80857
+ atom = atoms[i];
80843
80858
  if ((atom.name === atomName) && !atom.het) {
80844
80859
  if(index == 0) {
80845
80860
  firstAtom = atom;
@@ -80866,7 +80881,61 @@ class Tube {
80866
80881
 
80867
80882
  pnts_colors_radii.push(result);
80868
80883
  }
80869
- else {
80884
+ else {
80885
+ /*
80886
+ if(!isNaN(firstAtom.resi) && !isNaN(prevAtom.resi)) {
80887
+ let prevoneResid = firstAtom.structure + '_' + firstAtom.chain + '_' + (parseInt(firstAtom.resi) - 1).toString();
80888
+ let prevoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(prevoneResid, atomName);
80889
+ prevone = (prevoneCoord !== undefined) ? [prevoneCoord] : [];
80890
+
80891
+ let nextoneResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 1).toString();
80892
+ let nexttwoResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 2).toString();
80893
+ let nextthreeResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 3).toString();
80894
+
80895
+ if(ic.residues.hasOwnProperty(nextoneResid)) {
80896
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
80897
+ if(nextAtom !== undefined && nextAtom.ssbegin) { // include the residue
80898
+ nextoneResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 2).toString();
80899
+ nexttwoResid = prevAtom.structure + '_' + prevAtom.chain + '_' + (parseInt(prevAtom.resi) + 3).toString();
80900
+
80901
+ pnts.push(nextAtom.coord);
80902
+ if(bCustom) {
80903
+ radii.push(this.getCustomtubesize(nextoneResid));
80904
+ }
80905
+ else {
80906
+ radii.push(this.getRadius(radius, nextAtom));
80907
+ }
80908
+ colors.push(nextAtom.color);
80909
+ }
80910
+ }
80911
+
80912
+ // add one more residue if only one residue is available and it's not part of helix/sheet
80913
+ if(pnts.length == 1 && ic.residues.hasOwnProperty(nextoneResid) && atom.ss == 'coil') {
80914
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
80915
+
80916
+ if(nextAtom) {
80917
+ pnts.push(nextAtom.coord);
80918
+ colors.push(nextAtom.color);
80919
+
80920
+ let radiusFinal = this.getRadius(radius, atom);
80921
+ radii.push(radiusFinal);
80922
+
80923
+ nextoneResid = nexttwoResid;
80924
+ nexttwoResid = nextthreeResid;
80925
+ }
80926
+ }
80927
+
80928
+ let nextoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nextoneResid, atomName);
80929
+ if(nextoneCoord !== undefined) {
80930
+ nexttwo.push(nextoneCoord);
80931
+ }
80932
+
80933
+ let nexttwoCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nexttwoResid, atomName);
80934
+ if(nexttwoCoord !== undefined) {
80935
+ nexttwo.push(nexttwoCoord);
80936
+ }
80937
+ }
80938
+ */
80870
80939
  pnts_colors_radii.push({'pnts':pnts, 'colors':colors, 'radii':radii});
80871
80940
  }
80872
80941
  }
@@ -80890,6 +80959,24 @@ class Tube {
80890
80959
  }
80891
80960
  }
80892
80961
  else { // b factor, etc
80962
+ /*
80963
+ if(pnts.length == 0 && !isNaN(atom.resi)) {
80964
+ let prevoneResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) - 1).toString();
80965
+ if(ic.residues.hasOwnProperty(prevoneResid)) {
80966
+ prevAtom = ic.firstAtomObjCls.getAtomFromResi(prevoneResid, atomName);
80967
+ if(prevAtom !== undefined && prevAtom.ssend) { // include the residue
80968
+ pnts.push(prevAtom.coord);
80969
+ if(bCustom) {
80970
+ radii.push(this.getCustomtubesize(prevoneResid));
80971
+ }
80972
+ else {
80973
+ radii.push(this.getRadius(radius, prevAtom));
80974
+ }
80975
+ colors.push(prevAtom.color);
80976
+ }
80977
+ }
80978
+ }
80979
+ */
80893
80980
  pnts.push(atom.coord);
80894
80981
 
80895
80982
  let radiusFinal;
@@ -80938,6 +81025,47 @@ class Tube {
80938
81025
  }
80939
81026
  }
80940
81027
  else {
81028
+ /*
81029
+ prevone = [];
81030
+ if(firstAtom !== undefined && !isNaN(firstAtom.resi)) {
81031
+ let prevoneResid = firstAtom.structure + '_' + firstAtom.chain + '_' + (parseInt(firstAtom.resi) - 1).toString();
81032
+ let prevoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(prevoneResid, atomName);
81033
+ prevone = (prevoneCoord !== undefined) ? [prevoneCoord] : [];
81034
+ }
81035
+
81036
+ nexttwo = [];
81037
+ if(atom !== undefined && !isNaN(atom.resi)) {
81038
+ let nextoneResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 1).toString();
81039
+ let nexttwoResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 2).toString();
81040
+ let nextthreeResid = atom.structure + '_' + atom.chain + '_' + (parseInt(atom.resi) + 3).toString();
81041
+
81042
+ // add one more residue if only one residue is available
81043
+ if(pnts.length == 1 && ic.residues.hasOwnProperty(nextoneResid)) {
81044
+ let nextAtom = ic.firstAtomObjCls.getAtomFromResi(nextoneResid, atomName);
81045
+
81046
+ if(nextAtom) {
81047
+ pnts.push(nextAtom.coord);
81048
+ colors.push(nextAtom.color);
81049
+
81050
+ let radiusFinal = this.getRadius(radius, atom);
81051
+ radii.push(radiusFinal);
81052
+
81053
+ nextoneResid = nexttwoResid;
81054
+ nexttwoResid = nextthreeResid;
81055
+ }
81056
+ }
81057
+
81058
+ let nextoneCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nextoneResid, atomName);
81059
+ if(nextoneCoord !== undefined) {
81060
+ nexttwo.push(nextoneCoord);
81061
+ }
81062
+
81063
+ let nexttwoCoord = ic.firstAtomObjCls.getAtomCoordFromResi(nexttwoResid, atomName);
81064
+ if(nexttwoCoord !== undefined) {
81065
+ nexttwo.push(nexttwoCoord);
81066
+ }
81067
+ }
81068
+ */
80941
81069
  pnts_colors_radii.push({'pnts':pnts, 'colors':colors, 'radii':radii});
80942
81070
  }
80943
81071
  }
@@ -80947,7 +81075,12 @@ class Tube {
80947
81075
  let colors = pnts_colors_radii[i].colors;
80948
81076
  let radii = pnts_colors_radii[i].radii;
80949
81077
 
80950
- this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil);
81078
+ if(tubePosArray) {
81079
+ this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil);
81080
+ }
81081
+ else {
81082
+ this.createTubeSub(pnts, colors, radii, bHighlight, bNonCoil, true);
81083
+ }
80951
81084
  }
80952
81085
 
80953
81086
  pnts_colors_radii = [];
@@ -81006,7 +81139,7 @@ class Tube {
81006
81139
  };
81007
81140
 
81008
81141
  // modified from iview (http://istar.cse.cuhk.edu.hk/iview/)
81009
- createTubeSub(_pnts, colors, radii, bHighlight, bNonCoil) { let ic = this.icn3d, me = ic.icn3dui;
81142
+ createTubeSub(_pnts, colors, radii, bHighlight, bNonCoil, bSubdivide) { let ic = this.icn3d, me = ic.icn3dui;
81010
81143
  if(me.bNode) return;
81011
81144
 
81012
81145
  if (_pnts.length < 2) return;
@@ -81019,9 +81152,10 @@ class Tube {
81019
81152
  let offset = 0, offset2 = 0, offset3 = 0;
81020
81153
 
81021
81154
  let pnts;
81022
- /*
81023
- if(!bSubdivided) {
81024
- let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv);
81155
+
81156
+ if(bSubdivide) {
81157
+ let bOld = true;
81158
+ let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv, bOld);
81025
81159
 
81026
81160
  pnts = pnts_clrs[0];
81027
81161
  colors = pnts_clrs[2];
@@ -81029,8 +81163,6 @@ class Tube {
81029
81163
  else {
81030
81164
  pnts = _pnts;
81031
81165
  }
81032
- */
81033
- pnts = _pnts;
81034
81166
 
81035
81167
  let constRadiius;
81036
81168
  // a threshold to stop drawing the tube if it's less than this ratio of radius
@@ -81270,7 +81402,7 @@ class Strand {
81270
81402
  let pntsCAAllSub = [], prevCOArrayAllSub = [], positionsSub = [], colorsAllSub = [];
81271
81403
 
81272
81404
  let currentChain, currentStyle, currentCA = null, currentColor = null, prevCoorCA = null, prevCoorO = null, prevColor = null;
81273
- let prevCO = null, ss = null, ssend = false, ssJoint = false, prevResi = null, prevResid = null;
81405
+ let prevCO = null, ss = null, ssend = false, prevResi = null, prevResid = null;
81274
81406
  let strandWidth, bSheetSegment = false, bHelixSegment = false;
81275
81407
  let atom, tubeAtoms = [];
81276
81408
 
@@ -81372,10 +81504,15 @@ class Strand {
81372
81504
  let delta = -1 + numM1Inv2 * j;
81373
81505
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
81374
81506
  // no smoothen for the last two residues in sheet
81375
- if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(atom.ssend)) v.smoothen = true;
81507
+ // if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(atom.ssend)) v.smoothen = true;
81508
+ if (!doNotSmoothen && ss === 'sheet') v.smoothen = true;
81376
81509
  pntsAll[j].push(v);
81377
81510
  }
81378
81511
 
81512
+ if (!doNotSmoothen && ss === 'sheet') {
81513
+ prevCoorCA.smoothen = true;
81514
+ prevCO.smoothen = true;
81515
+ }
81379
81516
  pntsCAAll.push(prevCoorCA);
81380
81517
  prevCOArrayAll.push(prevCO);
81381
81518
  }
@@ -81389,7 +81526,7 @@ class Strand {
81389
81526
 
81390
81527
  ss = atom.ss;
81391
81528
  ssend = atom.ssend;
81392
- ssJoint = atom.ssbegin || atom.ssend;
81529
+ atom.ssbegin || atom.ssend;
81393
81530
  } // end if (atom.name === 'O' || (ic.bCalphaOnly && atom.name === 'CA') ) {
81394
81531
  } // end if ((atom.name === 'O' || atom.name === 'CA') && !atom.het) {
81395
81532
  } // end for
@@ -81403,9 +81540,14 @@ class Strand {
81403
81540
  let delta = -1 + numM1Inv2 * j;
81404
81541
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
81405
81542
  // no smoothen for the last two residues in sheet
81406
- if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(ssend)) v.smoothen = true;
81543
+ //if (!doNotSmoothen && ss === 'sheet' && !ssJoint && !(ssend)) v.smoothen = true;
81544
+ if (!doNotSmoothen && ss === 'sheet') v.smoothen = true;
81407
81545
  pntsAll[j].push(v);
81408
81546
  }
81547
+ if (!doNotSmoothen && ss === 'sheet') {
81548
+ prevCoorCA.smoothen = true;
81549
+ prevCO.smoothen = true;
81550
+ }
81409
81551
  pntsCAAll.push(prevCoorCA);
81410
81552
  prevCOArrayAll.push(prevCO);
81411
81553
 
@@ -81429,7 +81571,6 @@ class Strand {
81429
81571
  prevCoorCA = null;
81430
81572
  ss = null;
81431
81573
  ssend = false;
81432
- ssJoint = false;
81433
81574
 
81434
81575
  index = 0;
81435
81576
  let bLastResDrawn = false;
@@ -81513,7 +81654,10 @@ class Strand {
81513
81654
 
81514
81655
  bSheetSegment = prevCoorO ? (ss === 'sheet') : (atom.ss === 'sheet');
81515
81656
  bHelixSegment = prevCoorO ? (ss === 'helix') : (atom.ss === 'helix');
81516
- this.createStrand_base(posArray, pntsAllSub, pntsCAAllSub, prevCOArrayAllSub, colorsAllSub, positionsSub, missingResArray, fill, bHighlight, bRibbon, num, bSheetSegment, bHelixSegment, bFullAtom, thickness);
81657
+ // skip the 2-residue joint between two adjacent SS (sheet end -> helix begin)
81658
+ if(!(ssend && atom.ssbegin)) {
81659
+ this.createStrand_base(posArray, pntsAllSub, pntsCAAllSub, prevCOArrayAllSub, colorsAllSub, positionsSub, missingResArray, fill, bHighlight, bRibbon, num, bSheetSegment, bHelixSegment, bFullAtom, thickness);
81660
+ }
81517
81661
  posArray = [];
81518
81662
  missingResArray = [];
81519
81663
  } // end if (atom.ssbegin || atom.ssend)
@@ -105582,9 +105726,37 @@ class WebGLPathTracer {
105582
105726
  ic.impostorCls.clearImpostors();
105583
105727
 
105584
105728
  if(ic.bRender && (!ic.hAtoms || Object.keys(ic.hAtoms) == 0)) ic.hAtoms = me.hashUtilsCls.cloneHash(ic.atoms);
105585
-
105729
+ /*
105730
+ // save the current view when the URL used |||pos:...
105731
+ let cam = (ic.bControlGl && !me.bNode) ? window.cam : ic.cam;
105732
+ let controls = (ic.bControlGl && !me.bNode) ? window.controls : ic.controls;
105733
+ let bKeepCamera = (!ic.bSetCamera || ic.bKeepCamera) && cam && controls && !me.bNode;
105734
+
105735
+ let camState;
105736
+ if(bKeepCamera) {
105737
+ camState = {
105738
+ pos: cam.position.clone(), up: cam.up.clone(), quat: cam.quaternion.clone(),
105739
+ target: controls.target.clone(), fov: cam.fov, zoom: cam.zoom,
105740
+ left: cam.left, right: cam.right, top: cam.top, bottom: cam.bottom
105741
+ };
105742
+ }
105743
+ */
105586
105744
  ic.sceneCls.rebuildScene();
105587
-
105745
+ /*
105746
+ // restore the saved cam state
105747
+ if(bKeepCamera) {
105748
+ // setCamera() created new controls, so re-read them
105749
+ //controls = (ic.bControlGl && !me.bNode) ? window.controls : ic.controls;
105750
+ cam.position.copy(camState.pos);
105751
+ cam.up.copy(camState.up);
105752
+ cam.quaternion.copy(camState.quat);
105753
+ controls.target.copy(camState.target);
105754
+ cam.zoom = camState.zoom;
105755
+ if(cam.isPerspectiveCamera) cam.fov = camState.fov;
105756
+ cam.updateProjectionMatrix();
105757
+ cam.updateMatrixWorld(true);
105758
+ }
105759
+ */
105588
105760
  // Impostor display using the saved arrays
105589
105761
  if(ic.bImpo) {
105590
105762
  ic.impostorCls.drawImpostorShader(); // target
@@ -105618,7 +105790,13 @@ class WebGLPathTracer {
105618
105790
  if($("#" + ic.pre + "cmdlog")) $("#" + ic.pre + "cmdlog").show();
105619
105791
  }
105620
105792
 
105621
- this.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
105793
+ if(ic.bSetCamera) {
105794
+ this.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
105795
+ }
105796
+ else {
105797
+ let commandTransformation = ic.commands[ic.commands.length-1].split('|||');
105798
+ ic.transformCls.resetOrientation_base(commandTransformation);
105799
+ }
105622
105800
 
105623
105801
  this.render(bVrAr, bPathTracer);
105624
105802
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.54.0",
3
+ "version": "3.54.2",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {