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.module.js CHANGED
@@ -57387,6 +57387,10 @@ class ClickMenu {
57387
57387
  me.htmlCls.dialogCls.openDlg('dl_state', 'Please input the state file');
57388
57388
  });
57389
57389
 
57390
+ me.myEventCls.onIds("#" + me.pre + "mn1_bcfviewpoint", "click", function(e) { me.icn3d; //e.preventDefault();
57391
+ me.htmlCls.dialogCls.openDlg('dl_bcfviewpoint', 'Please input the BCF viewpoint file');
57392
+ });
57393
+
57390
57394
  me.myEventCls.onIds("#" + me.pre + "mn1_selection", "click", function(e) { me.icn3d; //e.preventDefault();
57391
57395
  me.htmlCls.dialogCls.openDlg('dl_selection', 'Please input the selection file');
57392
57396
  });
@@ -60300,6 +60304,7 @@ class SetMenu {
60300
60304
  html += this.getLink('mn1_fixedversion', 'Share Link in Archived Ver. ' + me.htmlCls.wifiStr, undefined, 2);
60301
60305
  html += this.getLink('mn1_selection', 'Selection File', undefined, 2);
60302
60306
  html += this.getLink("mn1_collection", "Collection File", undefined, 2);
60307
+ html += this.getLink('mn1_bcfviewpoint', 'BCF Viewpoint File', undefined, 2);
60303
60308
 
60304
60309
  html += this.getMenuSep();
60305
60310
 
@@ -62788,6 +62793,12 @@ class SetDialog {
62788
62793
  html += me.htmlCls.buttonStr + "reload_state' style='margin-top: 6px;'>Load</button>";
62789
62794
  html += "</div>";
62790
62795
 
62796
+ html += me.htmlCls.divStr + "dl_bcfviewpoint' class='" + dialogClass + "'>";
62797
+ html += this.addNotebookTitle('dl_bcfviewpoint', 'Please input a BCF viewpoint file');
62798
+ html += "BCF viewpoint file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "bcfviewpoint'><br/>";
62799
+ html += me.htmlCls.buttonStr + "reload_bcfviewpoint' style='margin-top: 6px;'>Load</button>";
62800
+ html += "</div>";
62801
+
62791
62802
  html += me.htmlCls.divStr + "dl_video' class='" + dialogClass + "'>";
62792
62803
  html += this.addNotebookTitle('dl_video', 'Save canvas changes in a video');
62793
62804
  html += "State file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "state'><br/>";
@@ -64282,6 +64293,67 @@ class Events {
64282
64293
  }
64283
64294
  }
64284
64295
 
64296
+ async openBcf(file) { let me = this.icn3dui, ic = me.icn3d;
64297
+ let url = './script/jszip.min.js';
64298
+ await me.getAjaxPromise(url, 'script');
64299
+
64300
+ let jszip = new JSZip();
64301
+
64302
+ me.htmlCls.setHtmlCls.fileSupport();
64303
+
64304
+ jszip.loadAsync(file).then(function(zip) {
64305
+ zip.forEach(function (relativePath, zipEntry) {
64306
+ if (zipEntry.dir) {
64307
+ // Handle directory creation
64308
+ let folder = jszip.folder(relativePath);
64309
+ folder.forEach(function (filename, zipEntry2) {
64310
+ if(filename.substr(0, 9) == 'viewpoint') {
64311
+ zipEntry2.async('string') // or 'blob', 'arraybuffer'
64312
+ .then(function(fileData) {
64313
+ let parser = new DOMParser();
64314
+ let xmlDoc = parser.parseFromString(fileData, "text/xml");
64315
+
64316
+ // Accessing elements
64317
+ //const author = xmlDoc.getElementsByTagName("author")[0].textContent;
64318
+ //const author = xmlDoc.querySelector("author").textContent;
64319
+ let viewpoint = xmlDoc.querySelector("CameraViewPoint");
64320
+ let direction = xmlDoc.querySelector("CameraDirection");
64321
+ let upvector = xmlDoc.querySelector("CameraUpVector");
64322
+ let fov = xmlDoc.querySelector("FieldOfView").textContent;
64323
+ xmlDoc.querySelector("AspectRatio").textContent;
64324
+
64325
+ let childNodes, viewpointArray = [], directionArray = [], upvectorArray = [];
64326
+
64327
+ childNodes = viewpoint.children;
64328
+ viewpointArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
64329
+ childNodes = direction.children;
64330
+ directionArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
64331
+ childNodes = upvector.children;
64332
+ upvectorArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
64333
+
64334
+ ic.cam.position.set(viewpointArray[0], viewpointArray[1], viewpointArray[2]);
64335
+ ic.cam.quaternion.setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(directionArray[0], directionArray[1], directionArray[2]));
64336
+ ic.cam.up.set(upvectorArray[0], upvectorArray[1], upvectorArray[2]);
64337
+ ic.cam.fov = fov;
64338
+ //ic.container.whratio = aspect;
64339
+
64340
+ ic.drawCls.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
64341
+ ic.drawCls.render();
64342
+ });
64343
+ }
64344
+ });
64345
+ }
64346
+ // else {
64347
+ // // Handle file extraction
64348
+ // zipEntry.async("string").then(function (content) {
64349
+ // });
64350
+ // }
64351
+ });
64352
+ }, function (e) {
64353
+ console.error("Error loading BCF viewpoint file:", e);
64354
+ });
64355
+ }
64356
+
64285
64357
  //Hold all functions related to click events.
64286
64358
  allEventFunctions() { let me = this.icn3dui, ic = me.icn3d;
64287
64359
  let thisClass = this;
@@ -64708,7 +64780,7 @@ class Events {
64708
64780
  let v2Y = $("#" + me.pre + "v2Y").val();
64709
64781
  let v2Z = $("#" + me.pre + "v2Z").val();
64710
64782
 
64711
- let angleRad = new THREE.Vector3(parseFloat(v1X), parseFloat(v1Y), parseFloat(v1Z)).angleTo(new THREE.Vector3(parseFloat(v2X), parseFloat(v2Y), parseFloat(v2Z)));
64783
+ let angleRad = new Vector3$1(parseFloat(v1X), parseFloat(v1Y), parseFloat(v1Z)).angleTo(new Vector3$1(parseFloat(v2X), parseFloat(v2Y), parseFloat(v2Z)));
64712
64784
  let angle = angleRad / 3.1416 * 180;
64713
64785
  angle = Math.abs(angle).toFixed(0);
64714
64786
  if(angle > 180) angle -= 180;
@@ -65374,6 +65446,19 @@ class Events {
65374
65446
  }
65375
65447
  });
65376
65448
 
65449
+ me.myEventCls.onIds("#" + me.pre + "reload_bcfviewpoint", "click", async function(e) { me.icn3d;
65450
+ e.preventDefault();
65451
+ if(!me.cfg.notebook) dialog.dialog( "close" );
65452
+
65453
+ let file = $("#" + me.pre + "bcfviewpoint")[0].files[0];
65454
+ if(!file) {
65455
+ var aaa = 1; //alert("Please select a file before clicking 'Load'");
65456
+ }
65457
+ else {
65458
+ await thisClass.openBcf(file);
65459
+ }
65460
+ });
65461
+
65377
65462
  me.myEventCls.onIds("#" + me.pre + "reload_selectionfile", "click", function(e) { let ic = me.icn3d;
65378
65463
  e.preventDefault();
65379
65464
  if(!me.cfg.notebook) dialog.dialog( "close" );
@@ -66809,8 +66894,8 @@ class Events {
66809
66894
  let posArray1 = ic.contactCls.getExtent(atomSet1);
66810
66895
  let posArray2 = ic.contactCls.getExtent(atomSet2);
66811
66896
 
66812
- let pos1 = new THREE.Vector3(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
66813
- let pos2 = new THREE.Vector3(posArray2[2][0], posArray2[2][1], posArray2[2][2]);
66897
+ let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
66898
+ let pos2 = new Vector3$1(posArray2[2][0], posArray2[2][1], posArray2[2][2]);
66814
66899
 
66815
66900
  let radius = $("#" + me.pre + "linebtwsets_radius").val();
66816
66901
  let color = $("#" + me.pre + "linebtwsets_customcolor").val();
@@ -66834,7 +66919,7 @@ class Events {
66834
66919
  let nameArray = $("#" + me.pre + "cartoonshape").val();
66835
66920
  let atomSet1 = ic.definedSetsCls.getAtomsFromNameArray(nameArray);
66836
66921
  let posArray1 = ic.contactCls.getExtent(atomSet1);
66837
- let pos1 = new THREE.Vector3(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
66922
+ let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
66838
66923
 
66839
66924
  let shape = $("#" + me.pre + "cartoonshape_shape").val(); // Sphere or Cube
66840
66925
  let radius = $("#" + me.pre + "cartoonshape_radius").val();
@@ -67295,6 +67380,32 @@ class Events {
67295
67380
  thisClass.setLogCmd("set theme black", true);
67296
67381
  });
67297
67382
 
67383
+ // dragover and drop
67384
+ me.myEventCls.onIds("#" + me.pre + "viewer", "dragover", function(e) { me.icn3d;
67385
+ e.preventDefault();
67386
+ $("#" + me.pre + "viewer")[0].style.border = "5px solid blue";
67387
+ });
67388
+ me.myEventCls.onIds("#" + me.pre + "viewer", "drop", async function(e) { me.icn3d;
67389
+ e.preventDefault();
67390
+
67391
+ let files = e.dataTransfer.files;
67392
+
67393
+ for(let i = 0, il = e.dataTransfer.files.length; i < il; ++i) {
67394
+ let file = e.dataTransfer.files[i];
67395
+ let fileName = file.name;
67396
+
67397
+ let fileType = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
67398
+ if(fileType == 'pdb' || fileType == 'mmcif' || fileType == 'png') {
67399
+ await me.htmlCls.eventsCls.readFile(true, files, i, '', (fileType == 'mmcif'), (fileType == 'png'));
67400
+ }
67401
+ else if(fileType == 'bcf') {
67402
+ await thisClass.openBcf(file);
67403
+ }
67404
+ }
67405
+
67406
+ $("#" + me.pre + "viewer")[0].style.border = "0px solid black";
67407
+ });
67408
+
67298
67409
  $(document).on("click", "." + me.pre + "snpin3d", async function(e) { let ic = me.icn3d;
67299
67410
  e.stopImmediatePropagation();
67300
67411
 
@@ -133461,7 +133572,7 @@ class iCn3DUI {
133461
133572
  //even when multiple iCn3D viewers are shown together.
133462
133573
  this.pre = this.cfg.divid + "_";
133463
133574
 
133464
- this.REVISION = '3.44.1';
133575
+ this.REVISION = '3.44.2';
133465
133576
 
133466
133577
  // In nodejs, iCn3D defines "window = {navigator: {}}"
133467
133578
  this.bNode = (Object.keys(window).length < 2) ? true : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.44.1",
3
+ "version": "3.44.2",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {