icn3d 3.25.0 → 3.25.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
@@ -2302,7 +2302,7 @@ THREE.TrackballControls = function ( object, domElement, icn3d ) {
2302
2302
  this.screen.width = window.innerWidth;
2303
2303
  this.screen.height = window.innerHeight;
2304
2304
 
2305
- } else {
2305
+ } else if(this.domElement) {
2306
2306
 
2307
2307
  var box = this.domElement.getBoundingClientRect();
2308
2308
  // adjustments come from similar code in the jquery offset() function
@@ -2872,7 +2872,7 @@ THREE.TrackballControls = function ( object, domElement, icn3d ) {
2872
2872
 
2873
2873
  }
2874
2874
 
2875
- if(Object.keys(window).length >= 2) {
2875
+ if(Object.keys(window).length >= 2 && this.domElement) {
2876
2876
  this.domElement.addEventListener( 'contextmn', function ( event ) {
2877
2877
  //event.preventDefault();
2878
2878
  }, false );
@@ -2998,7 +2998,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement, icn3d ) { v
2998
2998
  this.screen.width = window.innerWidth;
2999
2999
  this.screen.height = window.innerHeight;
3000
3000
 
3001
- } else {
3001
+ } else if(this.domElement) {
3002
3002
 
3003
3003
  var box = this.domElement.getBoundingClientRect();
3004
3004
  // adjustments come from similar code in the jquery offset() function
@@ -3548,7 +3548,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement, icn3d ) { v
3548
3548
 
3549
3549
  }
3550
3550
 
3551
- if(Object.keys(window).length >= 2) {
3551
+ if(Object.keys(window).length >= 2 && this.domElement) {
3552
3552
  this.domElement.addEventListener( 'contextmn', function ( event ) {
3553
3553
  //event.preventDefault();
3554
3554
  }, false );
@@ -21921,7 +21921,7 @@ class Scene {
21921
21921
 
21922
21922
  //This core function sets up the scene and display the structure according to the input
21923
21923
  //options (shown above), which is a hash containing values for different keys.
21924
- rebuildScene(options) { let ic = this.icn3d; ic.icn3dui;
21924
+ rebuildScene(options) { let ic = this.icn3d, me = ic.icn3dui;
21925
21925
  if(options === undefined) options = ic.opts;
21926
21926
 
21927
21927
  this.rebuildSceneBase(options);
@@ -21933,7 +21933,7 @@ class Scene {
21933
21933
  // }
21934
21934
 
21935
21935
  // if(!ic.bSetVrArButtons) { // call once
21936
- this.setVrArButtons();
21936
+ if(!me.cfg.imageonly) this.setVrArButtons();
21937
21937
  // }
21938
21938
 
21939
21939
  // if((ic.bVr || ic.bAr) && !ic.bSetVrAr) { // call once
@@ -42020,71 +42020,79 @@ class ShowSeq {
42020
42020
  }
42021
42021
  }
42022
42022
 
42023
- if(parseInt(currResi) < parseInt(strandArray[strandCnt].startResi)) {
42024
- ic.residIgLoop[residueid] = 1;
42023
+ let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[residueid]);
42025
42024
 
42026
- if(bNterminal) { // make it continuous to the 1st strand
42027
- if(bStart) {
42028
- currRefnum = strandArray[strandCnt].startRefnum - strandArray[strandCnt].loopResCnt + loopCnt;
42029
- refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42030
- refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42031
- }
42032
- }
42033
- else {
42034
- //currStrand = strandArray[prevStrandCnt].strand;
42025
+ // skip non-protein residues
42026
+ if(!atom || !ic.proteins.hasOwnProperty(atom.serial)) {
42027
+ refnumLabel = undefined;
42028
+ }
42029
+ else {
42030
+ if(parseInt(currResi) < parseInt(strandArray[strandCnt].startResi)) {
42031
+ ic.residIgLoop[residueid] = 1;
42035
42032
 
42036
- if(prevStrandCnt >= 0 && strandArray[prevStrandCnt].strand.substr(0, 1) == 'G') {
42037
- if(bStart && ic.resid2refnum[residueid]) {
42038
- currRefnum = strandArray[prevStrandCnt].endRefnum + loopCnt;
42039
- refnumLabelNoPostfix = strandArray[prevStrandCnt].strand + currRefnum;
42040
- refnumLabel = refnumLabelNoPostfix + strandArray[prevStrandCnt].strandPostfix;
42041
- }
42042
- else {
42043
- bStart = false;
42044
- bNterminal = true;
42045
- loopCnt = 0;
42046
- }
42033
+ if(bNterminal) { // make it continuous to the 1st strand
42034
+ if(bStart) {
42035
+ currRefnum = strandArray[strandCnt].startRefnum - strandArray[strandCnt].loopResCnt + loopCnt;
42036
+ refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42037
+ refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42038
+ }
42047
42039
  }
42048
42040
  else {
42049
- let len = strandArray[strandCnt].loopResCnt;
42050
- let halfLen = parseInt(len / 2.0 + 0.5);
42051
-
42052
- if(loopCnt <= halfLen) {
42053
- currRefnum = strandArray[prevStrandCnt].endRefnum + loopCnt;
42054
- refnumLabelNoPostfix = strandArray[prevStrandCnt].strand + currRefnum;
42055
- refnumLabel = refnumLabelNoPostfix + strandArray[prevStrandCnt].strandPostfix;
42041
+ //currStrand = strandArray[prevStrandCnt].strand;
42042
+
42043
+ if(prevStrandCnt >= 0 && strandArray[prevStrandCnt].strand.substr(0, 1) == 'G') {
42044
+ if(bStart && ic.resid2refnum[residueid]) {
42045
+ currRefnum = strandArray[prevStrandCnt].endRefnum + loopCnt;
42046
+ refnumLabelNoPostfix = strandArray[prevStrandCnt].strand + currRefnum;
42047
+ refnumLabel = refnumLabelNoPostfix + strandArray[prevStrandCnt].strandPostfix;
42048
+ }
42049
+ else {
42050
+ bStart = false;
42051
+ bNterminal = true;
42052
+ loopCnt = 0;
42053
+ }
42056
42054
  }
42057
42055
  else {
42058
- currRefnum = strandArray[strandCnt].startRefnum - len + loopCnt - 1;
42059
- refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42060
- refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42056
+ let len = strandArray[strandCnt].loopResCnt;
42057
+ let halfLen = parseInt(len / 2.0 + 0.5);
42058
+
42059
+ if(loopCnt <= halfLen) {
42060
+ currRefnum = strandArray[prevStrandCnt].endRefnum + loopCnt;
42061
+ refnumLabelNoPostfix = strandArray[prevStrandCnt].strand + currRefnum;
42062
+ refnumLabel = refnumLabelNoPostfix + strandArray[prevStrandCnt].strandPostfix;
42063
+ }
42064
+ else {
42065
+ currRefnum = strandArray[strandCnt].startRefnum - len + loopCnt - 1;
42066
+ refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42067
+ refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42068
+ }
42061
42069
  }
42062
42070
  }
42063
42071
  }
42064
- }
42065
- else if(parseInt(currResi) >= parseInt(strandArray[strandCnt].startResi) && parseInt(currResi) <= parseInt(strandArray[strandCnt].endResi)) {
42066
- bNterminal = false;
42072
+ else if(parseInt(currResi) >= parseInt(strandArray[strandCnt].startResi) && parseInt(currResi) <= parseInt(strandArray[strandCnt].endResi)) {
42073
+ bNterminal = false;
42067
42074
 
42068
- if(currResi == strandArray[strandCnt].endResi) {
42069
- ++strandCnt; // next strand
42070
- loopCnt = 0;
42075
+ if(currResi == strandArray[strandCnt].endResi) {
42076
+ ++strandCnt; // next strand
42077
+ loopCnt = 0;
42071
42078
 
42072
- if(!strandArray[strandCnt]) { // last strand
42073
- --strandCnt;
42079
+ if(!strandArray[strandCnt]) { // last strand
42080
+ --strandCnt;
42081
+ }
42074
42082
  }
42075
42083
  }
42076
- }
42077
- else if(parseInt(currResi) > parseInt(strandArray[strandCnt].endResi)) {
42078
- ic.residIgLoop[residueid] = 1;
42084
+ else if(parseInt(currResi) > parseInt(strandArray[strandCnt].endResi)) {
42085
+ ic.residIgLoop[residueid] = 1;
42079
42086
 
42080
- // C-terminal
42081
- if(!ic.resid2refnum[residueid]) {
42082
- break;
42083
- }
42084
- else {
42085
- currRefnum = strandArray[strandCnt].endRefnum + loopCnt;
42086
- refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42087
- refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42087
+ // C-terminal
42088
+ if(!ic.resid2refnum[residueid]) {
42089
+ break;
42090
+ }
42091
+ else {
42092
+ currRefnum = strandArray[strandCnt].endRefnum + loopCnt;
42093
+ refnumLabelNoPostfix = strandArray[strandCnt].strand + currRefnum;
42094
+ refnumLabel = refnumLabelNoPostfix + strandArray[strandCnt].strandPostfix;
42095
+ }
42088
42096
  }
42089
42097
  }
42090
42098
 
@@ -59121,9 +59129,10 @@ class LoadScript {
59121
59129
 
59122
59130
  // load pdb, mmcif, mmdb, cid
59123
59131
  let id = loadStr.substr(loadStr.lastIndexOf(' ') + 1);
59132
+ if(id.length == 4) id = id.toUpperCase();
59124
59133
 
59125
59134
  // skip loading the structure if it was loaded before
59126
- if(ic.structures.hasOwnProperty(id)) return;
59135
+ if(ic.structures && ic.structures.hasOwnProperty(id)) return;
59127
59136
 
59128
59137
  ic.inputid = id;
59129
59138
  if(command.indexOf('load mmtf') !== -1) {
@@ -66306,7 +66315,7 @@ class SaveFile {
66306
66315
  if(me.utilsCls.isIE()) {
66307
66316
  blob = ic.renderer.domElement.msToBlob();
66308
66317
 
66309
- if(bAddURL) {
66318
+ if(bAddURL && typeof(blob) == 'Blob') {
66310
66319
  let reader = new FileReader();
66311
66320
  reader.onload = function(e) {
66312
66321
  let arrayBuffer = e.target.result; // or = reader.result;
@@ -66332,7 +66341,7 @@ class SaveFile {
66332
66341
  }
66333
66342
  else {
66334
66343
  ic.renderer.domElement.toBlob(function(data) {
66335
- if(bAddURL) {
66344
+ if(bAddURL && typeof(blob) == 'data') {
66336
66345
  let reader = new FileReader();
66337
66346
  reader.onload = function(e) {
66338
66347
  let arrayBuffer = e.target.result; // or = reader.result;
@@ -66404,7 +66413,30 @@ class SaveFile {
66404
66413
 
66405
66414
  let url = ic.shareLinkCls.shareLinkUrl();
66406
66415
 
66416
+ url = url.replace(/imageonly=1/g, '');
66417
+
66407
66418
  let bTooLong =(url.length > 4000 || url.indexOf('http') !== 0) ? true : false;
66419
+ /*
66420
+ if(bTooLong || (ic.bInputfile && !ic.bInputUrlfile)) {
66421
+ // $("#" + ic.pre + "viewer").html("<img src='" + imageUrl + "'/>");
66422
+ $("#" + ic.pre + "mnlist").html("<img src='" + imageUrl + "'/>");
66423
+ }
66424
+ else {
66425
+ // $("#" + ic.pre + "viewer").html("<a href='" + url + "' target='_blank'><img src='" + imageUrl + "'/></a>");
66426
+ $("#" + ic.pre + "mnlist").html("<a href='" + url + "' target='_blank'><img src='" + imageUrl + "'/></a>");
66427
+ }
66428
+
66429
+ // $("#" + ic.pre + "viewer").width(width);
66430
+ // $("#" + ic.pre + "viewer").height(height);
66431
+ $("#" + ic.pre + "mnlist").width(width);
66432
+ $("#" + ic.pre + "mnlist").height(height);
66433
+
66434
+ $("#" + ic.pre + "cmdlog").hide();
66435
+ $("#" + ic.pre + "title").hide();
66436
+
66437
+ //$("#" + ic.pre + "mnlist").hide();
66438
+ $("#" + ic.pre + "canvas").hide(); // "load mmdbid ..." may cause problems if canvas was removed
66439
+ */
66408
66440
 
66409
66441
  if(bTooLong || (ic.bInputfile && !ic.bInputUrlfile)) {
66410
66442
  $("#" + ic.pre + "viewer").html("<img src='" + imageUrl + "'/>");
@@ -66412,11 +66444,15 @@ class SaveFile {
66412
66444
  else {
66413
66445
  $("#" + ic.pre + "viewer").html("<a href='" + url + "' target='_blank'><img src='" + imageUrl + "'/></a>");
66414
66446
  }
66415
-
66447
+
66448
+ $("#" + ic.pre + "viewer").width(width);
66416
66449
  $("#" + ic.pre + "viewer").height(height);
66417
- $("#" + ic.pre + "mnlist").hide();
66450
+
66418
66451
  $("#" + ic.pre + "cmdlog").hide();
66419
66452
  $("#" + ic.pre + "title").hide();
66453
+ $("#" + ic.pre + "mnlist").hide();
66454
+
66455
+ if($("#" + ic.pre + "fullscreen").length > 0) $("#" + ic.pre + "fullscreen").hide();
66420
66456
 
66421
66457
  // clear memory
66422
66458
  ic = {};
@@ -67365,6 +67401,10 @@ class ShareLink {
67365
67401
  if(key_value.length == 2) paraHash[key_value[0]] = key_value[1];
67366
67402
  }
67367
67403
 
67404
+ if(me.cfg.idname && !paraHash[me.cfg.idname]) { // somehow it is not included
67405
+ url += me.cfg.idname + '=' + me.cfg.idvalue + '&';
67406
+ }
67407
+
67368
67408
  for(let key in paraHash) {
67369
67409
  if(key === 'v') continue;
67370
67410
 
@@ -67404,7 +67444,7 @@ class ShareLink {
67404
67444
  transformation.quaternion = ic.quaternion;
67405
67445
 
67406
67446
  let statefile = "";
67407
- let prevCommandStr = undefined;
67447
+ let prevCommandStr = "";
67408
67448
 
67409
67449
  let toggleStr = 'toggle highlight';
67410
67450
  let cntToggle = 0;