icn3d 3.54.1 → 3.54.3

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
@@ -81141,7 +81154,8 @@ class Tube {
81141
81154
  let pnts;
81142
81155
 
81143
81156
  if(bSubdivide) {
81144
- let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv);
81157
+ let bOld = true;
81158
+ let pnts_clrs = me.subdivideCls.subdivide(_pnts, colors, axisDiv, bOld);
81145
81159
 
81146
81160
  pnts = pnts_clrs[0];
81147
81161
  colors = pnts_clrs[2];
@@ -81388,7 +81402,7 @@ class Strand {
81388
81402
  let pntsCAAllSub = [], prevCOArrayAllSub = [], positionsSub = [], colorsAllSub = [];
81389
81403
 
81390
81404
  let currentChain, currentStyle, currentCA = null, currentColor = null, prevCoorCA = null, prevCoorO = null, prevColor = null;
81391
- 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;
81392
81406
  let strandWidth, bSheetSegment = false, bHelixSegment = false;
81393
81407
  let atom, tubeAtoms = [];
81394
81408
 
@@ -81490,10 +81504,15 @@ class Strand {
81490
81504
  let delta = -1 + numM1Inv2 * j;
81491
81505
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
81492
81506
  // no smoothen for the last two residues in sheet
81493
- 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;
81494
81509
  pntsAll[j].push(v);
81495
81510
  }
81496
81511
 
81512
+ if (!doNotSmoothen && ss === 'sheet') {
81513
+ prevCoorCA.smoothen = true;
81514
+ prevCO.smoothen = true;
81515
+ }
81497
81516
  pntsCAAll.push(prevCoorCA);
81498
81517
  prevCOArrayAll.push(prevCO);
81499
81518
  }
@@ -81507,7 +81526,7 @@ class Strand {
81507
81526
 
81508
81527
  ss = atom.ss;
81509
81528
  ssend = atom.ssend;
81510
- ssJoint = atom.ssbegin || atom.ssend;
81529
+ atom.ssbegin || atom.ssend;
81511
81530
  } // end if (atom.name === 'O' || (ic.bCalphaOnly && atom.name === 'CA') ) {
81512
81531
  } // end if ((atom.name === 'O' || atom.name === 'CA') && !atom.het) {
81513
81532
  } // end for
@@ -81521,9 +81540,14 @@ class Strand {
81521
81540
  let delta = -1 + numM1Inv2 * j;
81522
81541
  let v = new Vector3$1(prevCoorCA.x + prevCO.x * delta, prevCoorCA.y + prevCO.y * delta, prevCoorCA.z + prevCO.z * delta);
81523
81542
  // no smoothen for the last two residues in sheet
81524
- 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;
81525
81545
  pntsAll[j].push(v);
81526
81546
  }
81547
+ if (!doNotSmoothen && ss === 'sheet') {
81548
+ prevCoorCA.smoothen = true;
81549
+ prevCO.smoothen = true;
81550
+ }
81527
81551
  pntsCAAll.push(prevCoorCA);
81528
81552
  prevCOArrayAll.push(prevCO);
81529
81553
 
@@ -81547,7 +81571,6 @@ class Strand {
81547
81571
  prevCoorCA = null;
81548
81572
  ss = null;
81549
81573
  ssend = false;
81550
- ssJoint = false;
81551
81574
 
81552
81575
  index = 0;
81553
81576
  let bLastResDrawn = false;
@@ -105703,9 +105726,37 @@ class WebGLPathTracer {
105703
105726
  ic.impostorCls.clearImpostors();
105704
105727
 
105705
105728
  if(ic.bRender && (!ic.hAtoms || Object.keys(ic.hAtoms) == 0)) ic.hAtoms = me.hashUtilsCls.cloneHash(ic.atoms);
105706
-
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
+ */
105707
105744
  ic.sceneCls.rebuildScene();
105708
-
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
+ */
105709
105760
  // Impostor display using the saved arrays
105710
105761
  if(ic.bImpo) {
105711
105762
  ic.impostorCls.drawImpostorShader(); // target
@@ -105739,7 +105790,13 @@ class WebGLPathTracer {
105739
105790
  if($("#" + ic.pre + "cmdlog")) $("#" + ic.pre + "cmdlog").show();
105740
105791
  }
105741
105792
 
105742
- 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
+ }
105743
105800
 
105744
105801
  this.render(bVrAr, bPathTracer);
105745
105802
  }
@@ -105892,14 +105949,7 @@ class WebGLPathTracer {
105892
105949
  ic.setOptionCls.setStyle("proteins", atom.style);
105893
105950
  }
105894
105951
 
105895
- //Render the scene and objects into pixels.
105896
- render_base(bPathTracer) { let ic = this.icn3d, me = ic.icn3dui;
105897
- let thisClass = this;
105898
-
105899
- if(me.bNode) return;
105900
-
105901
- let cam = (ic.bControlGl && !me.bNode) ? window.cam : ic.cam;
105902
-
105952
+ setDirectLight(cam) { let ic = this.icn3d; ic.icn3dui;
105903
105953
  if(ic.directionalLight) {
105904
105954
  let quaternion = new Quaternion();
105905
105955
  quaternion.setFromUnitVectors( new Vector3$1(0, 0, ic.cam_z).normalize(), cam.position.clone().normalize() );
@@ -105914,6 +105964,19 @@ class WebGLPathTracer {
105914
105964
  ic.directionalLight3.applyMatrix4(cam.matrixWorld);
105915
105965
  }
105916
105966
 
105967
+ return cam;
105968
+ }
105969
+
105970
+ //Render the scene and objects into pixels.
105971
+ render_base(bPathTracer) { let ic = this.icn3d, me = ic.icn3dui;
105972
+ let thisClass = this;
105973
+
105974
+ if(me.bNode) return;
105975
+
105976
+ let cam = (ic.bControlGl && !me.bNode) ? window.cam : ic.cam;
105977
+
105978
+ cam = this.setDirectLight(cam);
105979
+
105917
105980
  if(!ic.bVr) ic.renderer.setPixelRatio( window.devicePixelRatio ); // r71
105918
105981
 
105919
105982
  if(ic.bVr) {
@@ -105955,8 +106018,14 @@ class WebGLPathTracer {
105955
106018
  else {
105956
106019
  if(bPathTracer) {
105957
106020
  ic.bImpo = false; // disable impostor for path tracing
106021
+ // remove the highlights since they are not 3D objects
106022
+ ic.hlUpdateCls.clearHighlight();
106023
+
105958
106024
  const pathTracer = new WebGLPathTracer(ic.renderer);
105959
106025
  pathTracer.setScene(ic.scene, cam);
106026
+
106027
+ cam = this.setDirectLight(cam);
106028
+
105960
106029
  //pathTracer.renderUpdates(); // Updates samples if the scene/camera changes
105961
106030
  //pathTracer.render(ic.scene, cam);
105962
106031
 
@@ -154564,7 +154633,7 @@ class iCn3DUI {
154564
154633
  //even when multiple iCn3D viewers are shown together.
154565
154634
  this.pre = this.cfg.divid + "_";
154566
154635
 
154567
- this.REVISION = '3.54.0';
154636
+ this.REVISION = '3.54.1';
154568
154637
 
154569
154638
  // In nodejs, iCn3D defines "window = {navigator: {}}", and added window = {navigator: {}, "__THREE__":"177"}
154570
154639
  this.bNode = (Object.keys(window).length < 3) ? true : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.54.1",
3
+ "version": "3.54.3",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {