icn3d 3.44.1 → 3.44.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
@@ -56486,6 +56486,10 @@ class ClickMenu {
56486
56486
  me.htmlCls.dialogCls.openDlg('dl_state', 'Please input the state file');
56487
56487
  });
56488
56488
 
56489
+ me.myEventCls.onIds("#" + me.pre + "mn1_bcfviewpoint", "click", function(e) { me.icn3d; //e.preventDefault();
56490
+ me.htmlCls.dialogCls.openDlg('dl_bcfviewpoint', 'Please input the BCF viewpoint file');
56491
+ });
56492
+
56489
56493
  me.myEventCls.onIds("#" + me.pre + "mn1_selection", "click", function(e) { me.icn3d; //e.preventDefault();
56490
56494
  me.htmlCls.dialogCls.openDlg('dl_selection', 'Please input the selection file');
56491
56495
  });
@@ -59399,6 +59403,7 @@ class SetMenu {
59399
59403
  html += this.getLink('mn1_fixedversion', 'Share Link in Archived Ver. ' + me.htmlCls.wifiStr, undefined, 2);
59400
59404
  html += this.getLink('mn1_selection', 'Selection File', undefined, 2);
59401
59405
  html += this.getLink("mn1_collection", "Collection File", undefined, 2);
59406
+ html += this.getLink('mn1_bcfviewpoint', 'BCF Viewpoint File', undefined, 2);
59402
59407
 
59403
59408
  html += this.getMenuSep();
59404
59409
 
@@ -61887,6 +61892,12 @@ class SetDialog {
61887
61892
  html += me.htmlCls.buttonStr + "reload_state' style='margin-top: 6px;'>Load</button>";
61888
61893
  html += "</div>";
61889
61894
 
61895
+ html += me.htmlCls.divStr + "dl_bcfviewpoint' class='" + dialogClass + "'>";
61896
+ html += this.addNotebookTitle('dl_bcfviewpoint', 'Please input a BCF viewpoint file');
61897
+ html += "BCF viewpoint file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "bcfviewpoint'><br/>";
61898
+ html += me.htmlCls.buttonStr + "reload_bcfviewpoint' style='margin-top: 6px;'>Load</button>";
61899
+ html += "</div>";
61900
+
61890
61901
  html += me.htmlCls.divStr + "dl_video' class='" + dialogClass + "'>";
61891
61902
  html += this.addNotebookTitle('dl_video', 'Save canvas changes in a video');
61892
61903
  html += "State file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "state'><br/>";
@@ -63381,6 +63392,67 @@ class Events {
63381
63392
  }
63382
63393
  }
63383
63394
 
63395
+ async openBcf(file) { let me = this.icn3dui, ic = me.icn3d;
63396
+ let url = './script/jszip.min.js';
63397
+ await me.getAjaxPromise(url, 'script');
63398
+
63399
+ let jszip = new JSZip();
63400
+
63401
+ me.htmlCls.setHtmlCls.fileSupport();
63402
+
63403
+ jszip.loadAsync(file).then(function(zip) {
63404
+ zip.forEach(function (relativePath, zipEntry) {
63405
+ if (zipEntry.dir) {
63406
+ // Handle directory creation
63407
+ let folder = jszip.folder(relativePath);
63408
+ folder.forEach(function (filename, zipEntry2) {
63409
+ if(filename.substr(0, 9) == 'viewpoint') {
63410
+ zipEntry2.async('string') // or 'blob', 'arraybuffer'
63411
+ .then(function(fileData) {
63412
+ let parser = new DOMParser();
63413
+ let xmlDoc = parser.parseFromString(fileData, "text/xml");
63414
+
63415
+ // Accessing elements
63416
+ //const author = xmlDoc.getElementsByTagName("author")[0].textContent;
63417
+ //const author = xmlDoc.querySelector("author").textContent;
63418
+ let viewpoint = xmlDoc.querySelector("CameraViewPoint");
63419
+ let direction = xmlDoc.querySelector("CameraDirection");
63420
+ let upvector = xmlDoc.querySelector("CameraUpVector");
63421
+ let fov = xmlDoc.querySelector("FieldOfView").textContent;
63422
+ xmlDoc.querySelector("AspectRatio").textContent;
63423
+
63424
+ let childNodes, viewpointArray = [], directionArray = [], upvectorArray = [];
63425
+
63426
+ childNodes = viewpoint.children;
63427
+ viewpointArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
63428
+ childNodes = direction.children;
63429
+ directionArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
63430
+ childNodes = upvector.children;
63431
+ upvectorArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
63432
+
63433
+ ic.cam.position.set(viewpointArray[0], viewpointArray[1], viewpointArray[2]);
63434
+ ic.cam.quaternion.setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(directionArray[0], directionArray[1], directionArray[2]));
63435
+ ic.cam.up.set(upvectorArray[0], upvectorArray[1], upvectorArray[2]);
63436
+ ic.cam.fov = fov;
63437
+ //ic.container.whratio = aspect;
63438
+
63439
+ ic.drawCls.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
63440
+ ic.drawCls.render();
63441
+ });
63442
+ }
63443
+ });
63444
+ }
63445
+ // else {
63446
+ // // Handle file extraction
63447
+ // zipEntry.async("string").then(function (content) {
63448
+ // });
63449
+ // }
63450
+ });
63451
+ }, function (e) {
63452
+ console.error("Error loading BCF viewpoint file:", e);
63453
+ });
63454
+ }
63455
+
63384
63456
  //Hold all functions related to click events.
63385
63457
  allEventFunctions() { let me = this.icn3dui, ic = me.icn3d;
63386
63458
  let thisClass = this;
@@ -63807,7 +63879,7 @@ class Events {
63807
63879
  let v2Y = $("#" + me.pre + "v2Y").val();
63808
63880
  let v2Z = $("#" + me.pre + "v2Z").val();
63809
63881
 
63810
- let angleRad = new THREE.Vector3(parseFloat(v1X), parseFloat(v1Y), parseFloat(v1Z)).angleTo(new THREE.Vector3(parseFloat(v2X), parseFloat(v2Y), parseFloat(v2Z)));
63882
+ let angleRad = new Vector3$1(parseFloat(v1X), parseFloat(v1Y), parseFloat(v1Z)).angleTo(new Vector3$1(parseFloat(v2X), parseFloat(v2Y), parseFloat(v2Z)));
63811
63883
  let angle = angleRad / 3.1416 * 180;
63812
63884
  angle = Math.abs(angle).toFixed(0);
63813
63885
  if(angle > 180) angle -= 180;
@@ -64473,6 +64545,19 @@ class Events {
64473
64545
  }
64474
64546
  });
64475
64547
 
64548
+ me.myEventCls.onIds("#" + me.pre + "reload_bcfviewpoint", "click", async function(e) { me.icn3d;
64549
+ e.preventDefault();
64550
+ if(!me.cfg.notebook) dialog.dialog( "close" );
64551
+
64552
+ let file = $("#" + me.pre + "bcfviewpoint")[0].files[0];
64553
+ if(!file) {
64554
+ var aaa = 1; //alert("Please select a file before clicking 'Load'");
64555
+ }
64556
+ else {
64557
+ await thisClass.openBcf(file);
64558
+ }
64559
+ });
64560
+
64476
64561
  me.myEventCls.onIds("#" + me.pre + "reload_selectionfile", "click", function(e) { let ic = me.icn3d;
64477
64562
  e.preventDefault();
64478
64563
  if(!me.cfg.notebook) dialog.dialog( "close" );
@@ -65908,8 +65993,8 @@ class Events {
65908
65993
  let posArray1 = ic.contactCls.getExtent(atomSet1);
65909
65994
  let posArray2 = ic.contactCls.getExtent(atomSet2);
65910
65995
 
65911
- let pos1 = new THREE.Vector3(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
65912
- let pos2 = new THREE.Vector3(posArray2[2][0], posArray2[2][1], posArray2[2][2]);
65996
+ let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
65997
+ let pos2 = new Vector3$1(posArray2[2][0], posArray2[2][1], posArray2[2][2]);
65913
65998
 
65914
65999
  let radius = $("#" + me.pre + "linebtwsets_radius").val();
65915
66000
  let color = $("#" + me.pre + "linebtwsets_customcolor").val();
@@ -65933,7 +66018,7 @@ class Events {
65933
66018
  let nameArray = $("#" + me.pre + "cartoonshape").val();
65934
66019
  let atomSet1 = ic.definedSetsCls.getAtomsFromNameArray(nameArray);
65935
66020
  let posArray1 = ic.contactCls.getExtent(atomSet1);
65936
- let pos1 = new THREE.Vector3(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
66021
+ let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
65937
66022
 
65938
66023
  let shape = $("#" + me.pre + "cartoonshape_shape").val(); // Sphere or Cube
65939
66024
  let radius = $("#" + me.pre + "cartoonshape_radius").val();
@@ -66394,6 +66479,32 @@ class Events {
66394
66479
  thisClass.setLogCmd("set theme black", true);
66395
66480
  });
66396
66481
 
66482
+ // dragover and drop
66483
+ me.myEventCls.onIds("#" + me.pre + "viewer", "dragover", function(e) { me.icn3d;
66484
+ e.preventDefault();
66485
+ $("#" + me.pre + "viewer")[0].style.border = "5px solid blue";
66486
+ });
66487
+ me.myEventCls.onIds("#" + me.pre + "viewer", "drop", async function(e) { me.icn3d;
66488
+ e.preventDefault();
66489
+
66490
+ let files = e.dataTransfer.files;
66491
+
66492
+ for(let i = 0, il = e.dataTransfer.files.length; i < il; ++i) {
66493
+ let file = e.dataTransfer.files[i];
66494
+ let fileName = file.name;
66495
+
66496
+ let fileType = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
66497
+ if(fileType == 'pdb' || fileType == 'mmcif' || fileType == 'png') {
66498
+ await me.htmlCls.eventsCls.readFile(true, files, i, '', (fileType == 'mmcif'), (fileType == 'png'));
66499
+ }
66500
+ else if(fileType == 'bcf') {
66501
+ await thisClass.openBcf(file);
66502
+ }
66503
+ }
66504
+
66505
+ $("#" + me.pre + "viewer")[0].style.border = "0px solid black";
66506
+ });
66507
+
66397
66508
  $(document).on("click", "." + me.pre + "snpin3d", async function(e) { let ic = me.icn3d;
66398
66509
  e.stopImmediatePropagation();
66399
66510
 
@@ -132560,7 +132671,7 @@ class iCn3DUI {
132560
132671
  //even when multiple iCn3D viewers are shown together.
132561
132672
  this.pre = this.cfg.divid + "_";
132562
132673
 
132563
- this.REVISION = '3.44.1';
132674
+ this.REVISION = '3.44.2';
132564
132675
 
132565
132676
  // In nodejs, iCn3D defines "window = {navigator: {}}"
132566
132677
  this.bNode = (Object.keys(window).length < 2) ? true : false;